Search in sources :

Example 1 with RunningService

use of com.dangdang.ddframe.job.cloud.scheduler.state.running.RunningService in project elastic-job by dangdangdotcom.

the class CloudJobRestfulApiTest method assertFindAllRunningTasks.

@Test
public void assertFindAllRunningTasks() throws Exception {
    RunningService runningService = new RunningService(getRegCenter());
    TaskContext actualTaskContext = TaskContext.from(TaskNode.builder().build().getTaskNodeValue());
    when(getRegCenter().get("/config/job/" + actualTaskContext.getMetaInfo().getJobName())).thenReturn(CloudJsonConstants.getJobJson());
    runningService.add(actualTaskContext);
    assertThat(sentGetRequest("http://127.0.0.1:19000/job/tasks/running"), is(GsonFactory.getGson().toJson(Lists.newArrayList(actualTaskContext))));
}
Also used : TaskContext(com.dangdang.ddframe.job.context.TaskContext) RunningService(com.dangdang.ddframe.job.cloud.scheduler.state.running.RunningService) Test(org.junit.Test)

Example 2 with RunningService

use of com.dangdang.ddframe.job.cloud.scheduler.state.running.RunningService in project elastic-job by dangdangdotcom.

the class SchedulerEngineTest method setUp.

@Before
public void setUp() throws NoSuchFieldException {
    schedulerEngine = new SchedulerEngine(taskScheduler, facadeService, new JobEventBus(), frameworkIDService, statisticManager);
    ReflectionUtils.setFieldValue(schedulerEngine, "facadeService", facadeService);
    when(facadeService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job")));
    new RunningService(Mockito.mock(CoordinatorRegistryCenter.class)).clear();
}
Also used : JobEventBus(com.dangdang.ddframe.job.event.JobEventBus) RunningService(com.dangdang.ddframe.job.cloud.scheduler.state.running.RunningService) Before(org.junit.Before)

Aggregations

RunningService (com.dangdang.ddframe.job.cloud.scheduler.state.running.RunningService)2 TaskContext (com.dangdang.ddframe.job.context.TaskContext)1 JobEventBus (com.dangdang.ddframe.job.event.JobEventBus)1 Before (org.junit.Before)1 Test (org.junit.Test)1