-
-
Notifications
You must be signed in to change notification settings - Fork 616
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...-controller/src/test/java/org/cloud/sonic/controller/service/impl/JobServiceImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.cloud.sonic.controller.service.impl; | ||
|
||
import com.alibaba.fastjson.JSONObject; | ||
import org.cloud.sonic.controller.ControllerApplication; | ||
import org.cloud.sonic.controller.models.domain.Jobs; | ||
import org.cloud.sonic.controller.models.interfaces.JobStatus; | ||
import org.cloud.sonic.controller.services.JobsService; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import java.util.List; | ||
|
||
@SpringBootTest(classes = ControllerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@RunWith(SpringRunner.class) | ||
public class JobServiceImplTest { | ||
@Autowired | ||
private JobsService jobsService; | ||
|
||
@Test | ||
public void testFindSysJob() { | ||
List<JSONObject> list = jobsService.findSysJobs(); | ||
Assert.assertEquals(4, list.size()); | ||
} | ||
|
||
@Test | ||
public void testSaveJob() { | ||
Jobs jobs = new Jobs(); | ||
jobs.setName("Hello"); | ||
jobs.setSuiteId(1); | ||
jobs.setProjectId(1); | ||
jobs.setCronExpression("0 0 0 * * ?"); | ||
jobsService.saveJobs(jobs); | ||
Assert.assertEquals("testJob", jobs.getType()); | ||
Assert.assertEquals(JobStatus.ENABLE, (int) jobs.getStatus()); | ||
Assert.assertEquals(jobs, jobsService.findById(jobs.getId())); | ||
jobsService.delete(jobs.getId()); | ||
} | ||
} |