JobConfigurationPOJO { public JobConfiguration toJobConfiguration() { JobConfiguration result = JobConfiguration.newBuilder(jobName, shardingTotalCount) .cron(cron).shardingItemParameters(shardingItemParameters).jobParameter(jobParameter) .monitorExecution(monitorExecution).failover(failover).misfire(misfire) .maxTimeDiffSeconds(maxTimeDiffSeconds).reconcileIntervalMinutes(reconcileIntervalMinutes) .jobShardingStrategyType(jobShardingStrategyType).jobExecutorServiceHandlerType(jobExecutorServiceHandlerType).jobErrorHandlerType(jobErrorHandlerType) .jobListenerTypes(jobListenerTypes.toArray(new String[]{})).description(description).disabled(disabled).overwrite(overwrite).build(); for (Object each : props.keySet()) { result.getProps().setProperty(each.toString(), props.get(each.toString()).toString()); } return result; }  JobConfiguration toJobConfiguration(); static JobConfigurationPOJO fromJobConfiguration(final JobConfiguration jobConfiguration);  }
@Test public void assertToJobConfiguration() { JobConfigurationPOJO pojo = new JobConfigurationPOJO(); pojo.setJobName("test_job"); pojo.setCron("0/1 * * * * ?"); pojo.setShardingTotalCount(3); pojo.setShardingItemParameters("0=A,1=B,2=C"); pojo.setJobParameter("param"); pojo.setMonitorExecution(true); pojo.setFailover(true); pojo.setMisfire(true); pojo.setJobShardingStrategyType("AVG_ALLOCATION"); pojo.setJobExecutorServiceHandlerType("CPU"); pojo.setJobErrorHandlerType("IGNORE"); pojo.setJobListenerTypes(Arrays.asList("LOG")); pojo.setDescription("Job description"); pojo.getProps().setProperty("key", "value"); pojo.setDisabled(true); pojo.setOverwrite(true); JobConfiguration actual = pojo.toJobConfiguration(); assertThat(actual.getJobName(), is("test_job")); assertThat(actual.getCron(), is("0/1 * * * * ?")); assertThat(actual.getShardingTotalCount(), is(3)); assertThat(actual.getShardingItemParameters(), is("0=A,1=B,2=C")); assertThat(actual.getJobParameter(), is("param")); assertTrue(actual.isMonitorExecution()); assertTrue(actual.isFailover()); assertTrue(actual.isMisfire()); assertThat(actual.getJobShardingStrategyType(), is("AVG_ALLOCATION")); assertThat(actual.getJobExecutorServiceHandlerType(), is("CPU")); assertThat(actual.getJobErrorHandlerType(), is("IGNORE")); assertThat(actual.getJobListenerTypes(), hasItem("LOG")); assertThat(actual.getDescription(), is("Job description")); assertThat(actual.getProps().getProperty("key"), is("value")); assertTrue(actual.isDisabled()); assertTrue(actual.isOverwrite()); }