use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testImportFailByWithoutJobType.
@Test
public void testImportFailByWithoutJobType() throws SaturnJobConsoleException, IOException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
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 testAddJobFailByHasDownStreamButIsAncestor.
@Test
public void testAddJobFailByHasDownStreamButIsAncestor() throws Exception {
JobConfig jobConfig = new JobConfig();
jobConfig.setJobName(jobName);
jobConfig.setJobType(JobType.PASSIVE_SHELL_JOB.name());
jobConfig.setShardingTotalCount(1);
jobConfig.setShardingItemParameters("0=0");
jobConfig.setUpStream("test1");
jobConfig.setDownStream("test1");
JobConfig4DB test1 = new JobConfig4DB();
test1.setJobName("test1");
test1.setJobType(JobType.PASSIVE_SHELL_JOB.name());
test1.setShardingTotalCount(1);
test1.setShardingItemParameters("0=0");
when(currentJobConfigService.findConfigsByNamespace(eq(namespace))).thenReturn(Arrays.asList(test1));
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
when(curatorFrameworkOp.inTransaction()).thenReturn(curatorTransactionOp);
when(curatorTransactionOp.replaceIfChanged(anyString(), anyString())).thenReturn(curatorTransactionOp);
when(curatorTransactionOp.create(anyString(), anyString())).thenReturn(curatorTransactionOp);
expectedException.expect(SaturnJobConsoleException.class);
expectedException.expectMessage(String.format("该域(%s)作业编排有误,存在环: %s", namespace, "[testJob, test1, testJob]"));
jobService.addJob(namespace, jobConfig, userName);
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testGetJobConfigVoSuccess.
@Test
public void testGetJobConfigVoSuccess() throws SaturnJobConsoleException {
when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName)).thenReturn(new JobConfig4DB());
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
assertNotNull(jobService.getJobConfigVo(namespace, jobName));
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testAddJobFailByHasDownStreamButIsAncestor2.
@Test
public void testAddJobFailByHasDownStreamButIsAncestor2() throws Exception {
JobConfig jobConfig = new JobConfig();
jobConfig.setJobName(jobName);
jobConfig.setJobType(JobType.PASSIVE_SHELL_JOB.name());
jobConfig.setShardingTotalCount(1);
jobConfig.setShardingItemParameters("0=0");
jobConfig.setUpStream("test2");
jobConfig.setDownStream("test1");
JobConfig4DB test1 = new JobConfig4DB();
test1.setJobName("test1");
test1.setJobType(JobType.PASSIVE_SHELL_JOB.name());
test1.setShardingTotalCount(1);
test1.setShardingItemParameters("0=0");
test1.setDownStream("test2");
JobConfig4DB test2 = new JobConfig4DB();
test2.setJobName("test2");
test2.setJobType(JobType.PASSIVE_SHELL_JOB.name());
test2.setShardingTotalCount(1);
test2.setShardingItemParameters("0=0");
test2.setUpStream("test1");
when(currentJobConfigService.findConfigsByNamespace(eq(namespace))).thenReturn(Arrays.asList(test1, test2));
when(registryCenterService.getCuratorFrameworkOp(namespace)).thenReturn(curatorFrameworkOp);
when(curatorFrameworkOp.inTransaction()).thenReturn(curatorTransactionOp);
when(curatorTransactionOp.replaceIfChanged(anyString(), anyString())).thenReturn(curatorTransactionOp);
when(curatorTransactionOp.create(anyString(), anyString())).thenReturn(curatorTransactionOp);
expectedException.expect(SaturnJobConsoleException.class);
expectedException.expectMessage(String.format("该域(%s)作业编排有误,存在环: %s", namespace, "[testJob, test2, test1, testJob]"));
jobService.addJob(namespace, jobConfig, userName);
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testSetPreferListFailByLocalModeNotStop.
@Test
public void testSetPreferListFailByLocalModeNotStop() throws SaturnJobConsoleException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
jobConfig4DB.setEnabled(true);
jobConfig4DB.setLocalMode(true);
when(currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName)).thenReturn(jobConfig4DB);
expectedException.expect(SaturnJobConsoleException.class);
expectedException.expectMessage(String.format("启用状态的本地模式作业(%s),不能设置优先Executor,请先禁用它", jobName));
jobService.setPreferList(namespace, jobName, "preferList", userName);
}
Aggregations