private ChangeNotificationDto createNotification(ConfigurationDto configurationDto, HistoryDto historyDto) { LOG.debug("Create notification after configuration update."); ChangeNotificationDto changeNotificationDto = null; if (historyDto != null) { changeNotificationDto = new ChangeNotificationDto(); changeNotificationDto.setAppId(configurationDto.getApplicationId()); changeNotificationDto.setAppSeqNumber(historyDto.getSequenceNumber()); String endpointGroupId = configurationDto.getEndpointGroupId(); if (isValidId(endpointGroupId)) { EndpointGroup group = endpointGroupDao.findById(endpointGroupId); if (group != null) { changeNotificationDto.setGroupId(idToString(group)); changeNotificationDto.setGroupSeqNumber(group.getSequenceNumber()); } else { LOG.debug("Can't find endpoint group by id [{}].", endpointGroupId); } } else { LOG.debug("Incorrect endpoint group id [{}].", endpointGroupId); } } else { LOG.debug("Can't save history information."); } return changeNotificationDto; }
@Test public void findLatestConfigurationByAppIdTest() { List<ConfigurationDto> configurations = generateConfigurationDto(null, null, 1, false, false); ConfigurationDto expected = configurations.get(0); ConfigurationDto found = configurationService.findConfigurationByAppIdAndVersion(expected.getApplicationId(), 1); Assert.assertNotNull(found); }
private HistoryDto addHistory(ConfigurationDto dto, ChangeType type) { LOG.debug("Add history information about configuration update"); HistoryDto history = new HistoryDto(); history.setApplicationId(dto.getApplicationId()); ChangeDto change = new ChangeDto(); change.setConfigurationId(dto.getId()); change.setCfVersion(dto.getSchemaVersion()); change.setEndpointGroupId(dto.getEndpointGroupId()); change.setType(type); history.setChange(change); return historyService.saveHistory(history); }
@Test public void editConfigurationObjectTest() { List<ConfigurationDto> configs = generateConfigurationDto(null, null, 1, false, false); ConfigurationDto saved = configurationService.findConfigurationById(configs.get(0).getId()); ConfigurationDto configurationToEdit = new ConfigurationDto(); configurationToEdit.setId(saved.getId()); configurationToEdit.setApplicationId(saved.getApplicationId()); configurationToEdit.setEndpointGroupId(saved.getEndpointGroupId()); configurationToEdit.setSchemaId(saved.getSchemaId()); configurationToEdit.setVersion(saved.getVersion()); configurationToEdit.setBody(saved.getBody()); ConfigurationDto updated = configurationService.saveConfiguration(configurationToEdit); Assert.assertNotNull(saved); Assert.assertNotNull(updated); Assert.assertEquals(saved.getSchemaVersion(), updated.getSchemaVersion()); Assert.assertEquals(saved.getCreatedTime(), updated.getCreatedTime()); Assert.assertEquals(saved.getCreatedUsername(), updated.getCreatedUsername()); }