ResourceToDomainMapper { public static Collection<JobConfiguration> map(final JobConfigurations jobConfigurations) { final Collection<JobConfiguration> response = new LinkedList<>(); for (final org.tuxdevelop.spring.batch.lightmin.api.resource.admin.JobConfiguration jobConfiguration : jobConfigurations.getJobConfigurations()) { final JobConfiguration jobConfigurationResponse = map(jobConfiguration); response.add(jobConfigurationResponse); } return response; } private  ResourceToDomainMapper(); static Collection<JobConfiguration> map(final JobConfigurations jobConfigurations); static JobConfiguration map(final org.tuxdevelop.spring.batch.lightmin.api.resource.admin.JobConfiguration jobConfiguration); static org.springframework.batch.core.JobParameters map(final JobParameters jobParameters);  }
@Test public void testMapJobConfigurations() { final Collection<org.tuxdevelop.spring.batch.lightmin.api.resource.admin.JobConfiguration> jobConfigurations = new LinkedList<>(); final org.tuxdevelop.spring.batch.lightmin.api.resource.admin.JobSchedulerConfiguration jobSchedulerConfiguration = ApiTestHelper.createJobSchedulerConfiguration(null, 10L, 10L, org.tuxdevelop.spring.batch.lightmin.api.resource.admin.JobSchedulerType.PERIOD); final org.tuxdevelop.spring.batch.lightmin.api.resource.admin.JobConfiguration jobConfiguration = ApiTestHelper.createJobConfiguration(jobSchedulerConfiguration); jobConfiguration.setJobConfigurationId(1L); final Map<String, JobParameter> parameters = new HashMap<>(); final JobParameter jobParameterDouble = new JobParameter(); jobParameterDouble.setParameter(10.1); jobParameterDouble.setParameterType(ParameterType.DOUBLE); final JobParameter jobParameterLong = new JobParameter(); jobParameterLong.setParameter(20L); jobParameterLong.setParameterType(ParameterType.LONG); final JobParameter jobParameterDate = new JobParameter(); jobParameterDate.setParameter(new Date()); jobParameterDate.setParameterType(ParameterType.DATE); parameters.put("double", jobParameterDouble); parameters.put("long", jobParameterLong); parameters.put("date", jobParameterDate); final JobParameters jobParameters = new JobParameters(); jobParameters.setParameters(parameters); jobConfiguration.setJobParameters(jobParameters); jobConfigurations.add(jobConfiguration); final JobConfigurations jobConfigurationsToMap = new JobConfigurations(); jobConfigurationsToMap.setJobConfigurations(jobConfigurations); final Collection<JobConfiguration> result = ResourceToDomainMapper.map(jobConfigurationsToMap); this.assertJobConfigurations(result, jobConfigurationsToMap); }
@Test public void testMapJobConfigurationsWithListener() { final Collection<org.tuxdevelop.spring.batch.lightmin.api.resource.admin.JobConfiguration> jobConfigurations = new LinkedList<>(); final org.tuxdevelop.spring.batch.lightmin.api.resource.admin.JobListenerConfiguration jobListenerConfiguration = ApiTestHelper.createJobListenerConfiguration ("src/test/", "*.txt", org.tuxdevelop.spring.batch.lightmin.api.resource.admin.JobListenerType.LOCAL_FOLDER_LISTENER); final org.tuxdevelop.spring.batch.lightmin.api.resource.admin.JobConfiguration jobConfiguration = ApiTestHelper.createJobConfiguration(jobListenerConfiguration); jobConfiguration.setJobConfigurationId(1L); final Map<String, JobParameter> parameters = new HashMap<>(); final JobParameter jobParameterDouble = new JobParameter(); jobParameterDouble.setParameter(10.1); jobParameterDouble.setParameterType(ParameterType.DOUBLE); final JobParameter jobParameterLong = new JobParameter(); jobParameterLong.setParameter(20L); jobParameterLong.setParameterType(ParameterType.LONG); parameters.put("double", jobParameterDouble); parameters.put("long", jobParameterLong); final JobParameters jobParameters = new JobParameters(); jobParameters.setParameters(parameters); jobConfiguration.setJobParameters(jobParameters); jobConfigurations.add(jobConfiguration); final JobConfigurations jobConfigurationsToMap = new JobConfigurations(); jobConfigurationsToMap.setJobConfigurations(jobConfigurations); final Collection<JobConfiguration> result = ResourceToDomainMapper.map(jobConfigurationsToMap); this.assertJobConfigurations(result, jobConfigurationsToMap); }
@Test public void testMapDateComparedToParameterParser() { final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DomainParameterParser.DATE_FORMAT_WITH_TIMESTAMP); final Date now = new Date(); final JobParameter jobParameter = new JobParameter(); jobParameter.setParameter(now); jobParameter.setParameterType(ParameterType.DATE); final JobParameter jobParameter2 = new JobParameter(); jobParameter2.setParameter(now); jobParameter2.setParameterType(ParameterType.DATE); final Map<String, JobParameter> parameterMap = new HashMap<>(); parameterMap.put("date_parameter", jobParameter); parameterMap.put("second_date", jobParameter2); final JobParameters jobParameters = new JobParameters(); jobParameters.setParameters(parameterMap); final org.springframework.batch.core.JobParameters result = ResourceToDomainMapper.map(jobParameters); assertThat(result).isNotNull(); assertThat(result.getParameters()).hasSize(2); final Date resultDate = result.getDate("date_parameter"); final Date resultDate2 = result.getDate("second_date"); final Date parserResult = DomainParameterParser.parseDate(simpleDateFormat.format(now)); assertThat(resultDate).isEqualTo(parserResult); assertThat(resultDate2).isEqualTo(parserResult); }