use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testImportFailByTimeZoneInvalid.
@Test
public void testImportFailByTimeZoneInvalid() throws SaturnJobConsoleException, IOException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
when(currentJobConfigService.findConfigsByNamespace(namespace)).thenReturn(Lists.newArrayList(jobConfig4DB));
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE))).thenReturn(JobType.SHELL_JOB.name());
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CRON))).thenReturn("0 */2 * * * ?");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_CLASS))).thenReturn("vip");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_TOTAL_COUNT))).thenReturn("1");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_ITEM_PARAMETERS))).thenReturn("0=1");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_TIME_ZONE))).thenReturn("error");
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 testImportFailByLocalJobNotSupportFailover.
@Test
public void testImportFailByLocalJobNotSupportFailover() throws SaturnJobConsoleException, IOException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
when(currentJobConfigService.findConfigsByNamespace(namespace)).thenReturn(Lists.newArrayList(jobConfig4DB));
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE))).thenReturn(JobType.SHELL_JOB.name());
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_CRON))).thenReturn("0 */2 * * * ?");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_CLASS))).thenReturn("vip");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_TOTAL_COUNT))).thenReturn("1");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_SHARDING_ITEM_PARAMETERS))).thenReturn("*=1");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_LOCAL_MODE))).thenReturn("true");
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_FAILOVER))).thenReturn("true");
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("本地模式不支持failover"));
jobService.importJobs(namespace, data, userName);
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testImportFailByUnknownJobType.
@Test
public void testImportFailByUnknownJobType() throws SaturnJobConsoleException, IOException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName(jobName);
when(currentJobConfigService.findConfigsByNamespace(namespace)).thenReturn(Lists.newArrayList(jobConfig4DB));
when(curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, CONFIG_ITEM_JOB_TYPE))).thenReturn("xxx");
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 buildSystemJobConfig4DBList.
private List<JobConfig4DB> buildSystemJobConfig4DBList(String namespace, String jobName, int count) {
List<JobConfig4DB> config4DBList = new ArrayList<>();
for (int i = 0; i < count; i++) {
JobConfig4DB config = new JobConfig4DB();
config.setNamespace(namespace);
config.setJobName(jobName + i);
config.setEnabled(true);
config.setEnabledReport(true);
config.setJobType(JobType.JAVA_JOB.toString());
config.setJobMode("system_test");
config4DBList.add(config);
}
return config4DBList;
}
use of com.vip.saturn.job.console.mybatis.entity.JobConfig4DB in project Saturn by vipshop.
the class JobServiceImplTest method testImportFailByJobNameInvalid.
@Test
public void testImportFailByJobNameInvalid() throws SaturnJobConsoleException, IOException {
JobConfig4DB jobConfig4DB = new JobConfig4DB();
jobConfig4DB.setJobName("!@avb");
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("作业名只允许包含:数字0-9、小写字符a-z、大写字符A-Z、下划线_。"));
jobService.importJobs(namespace, data, userName);
}
Aggregations