use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testDisableJobSuccess.
@Test
public void testDisableJobSuccess() throws Exception {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
jobConfig4DB.setEnabled(Boolean.TRUE);
when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName)).thenReturn(jobConfig4DB);
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
jobService.disableJob(namespace, jobName, userName);
verify(currentJobConfigService).updateByPrimaryKey(jobConfig4DB);
verify(curatorFrameworkOp).update(eq(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_ENABLED)), eq(false));
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testImportFailByWithoutJobName.
@Test
public void testImportFailByWithoutJobName() throws SaturnJobConsoleException, IOException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
when(currentJobConfigService.findConfigsByNamespace(namespace)).thenReturn(Lists.newArrayList(jobConfig4DB));
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
File file = jobService.exportJobs(namespace);
MultipartFile data = new MockMultipartFile("test.xls", new FileInputStream(file));
expectedException.expect(SaturnJobConsoleException.class);
expectedException.expectMessage(StringContains.containsString("作业名必填。"));
jobService.importJobs(namespace, data, userName);
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testRemoveJobFailByHaveDownStream.
@Test
public void testRemoveJobFailByHaveDownStream() throws SaturnJobConsoleException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
jobConfig4DB.setDownStream("downStreamJob");
when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName)).thenReturn(jobConfig4DB);
expectedException.expect(SaturnJobConsoleException.class);
expectedException.expectMessage(String.format("不能删除该作业(%s),因为该作业存在下游作业(%s),请先断开上下游关系再删除", jobName, "downStreamJob"));
jobService.removeJob(namespace, jobName);
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testDisableJobFailByUpdateError.
@Test
public void testDisableJobFailByUpdateError() throws Exception {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
jobConfig4DB.setEnabled(Boolean.TRUE);
when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName)).thenReturn(jobConfig4DB);
when(currentJobConfigService.updateByPrimaryKey(jobConfig4DB)).thenThrow(new SaturnJobConsoleException("update error"));
expectedException.expect(SaturnJobConsoleException.class);
expectedException.expectMessage("update error");
jobService.disableJob(namespace, jobName, userName);
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testGetExecutionStatusByJobHasStopped.
@Test
public void testGetExecutionStatusByJobHasStopped() throws SaturnJobConsoleException {
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
// test get execution status by job has stopped
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
jobConfig4DB.setEnabled(false);
when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName)).thenReturn(jobConfig4DB);
assertTrue(jobService.getExecutionStatus(namespace, jobName).isEmpty());
}
Aggregations