CronTaskDataServiceImpl implements CronTaskDataService { @Override public UUID save(final CronTaskConfigurationDto dto) throws IOException { setUuidIfNull(dto); setNameIfBlank(dto); modifyInLock(configuration -> { if (isDuplicate(dto, configuration)) { return; } removePreviousIncarnation(dto, configuration); configuration.getCronTaskConfigurations().add(dto); }); return dto.getUuid(); } @Inject  CronTaskDataServiceImpl(CronTasksConfigurationFileManager cronTasksConfigurationFileManager,
                            CronJobsDefinitionsRegistry cronJobsDefinitionsRegistry,
                            CronJobDuplicationCheckStrategiesRegistry cronJobDuplicationCheckStrategiesRegistry); @Override CronTasksConfigurationDto getTasksConfigurationDto(); @Override CronTaskConfigurationDto getTaskConfigurationDto(UUID cronTaskConfigurationUuid); @Override List<CronTaskConfiguration> findMatching(CronTaskConfigurationSearchCriteria searchCriteria); @Override UUID save(final CronTaskConfigurationDto dto); @Override void delete(final UUID cronTaskConfigurationUuid);  }
@Test void shouldForbidDuplications() throws IOException { assertSingleInitialInstance(); CronTaskConfigurationDto newDto = new CronTaskConfigurationDto(); newDto.setJobClass(TestJavaCronJob.class.getName()); newDto.setProperties( ImmutableMap.of(PROPERTY_REPOSITORY_ID, REPOSITORY_RELEASES, PROPERTY_STORAGE_ID, STORAGE_0)); cronTaskDataService.save(newDto); assertSingleInitialInstance(); }