private ChangeNotificationDto createNotification(ProfileFilterDto profileFilter, HistoryDto historyDto) { LOG.debug("Create notification after profile filter update."); ChangeNotificationDto changeNotificationDto = null; if (historyDto != null) { changeNotificationDto = new ChangeNotificationDto(); changeNotificationDto.setAppId(profileFilter.getApplicationId()); changeNotificationDto.setAppSeqNumber(historyDto.getSequenceNumber()); String endpointGroupId = profileFilter.getEndpointGroupId(); if (isValidId(endpointGroupId)) { EndpointGroup group = endpointGroupDao.findById(endpointGroupId); if (group != null) { changeNotificationDto.setGroupId(group.getId().toString()); 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; }
private HistoryDto addHistory(ProfileFilterDto dto, ChangeType type) { LOG.debug("Add history information about profile filter update with change type {} ", type); HistoryDto history = new HistoryDto(); history.setApplicationId(dto.getApplicationId()); ChangeDto change = new ChangeDto(); change.setProfileFilterId(dto.getId()); change.setProfileFilterId(dto.getId()); change.setEndpointGroupId(dto.getEndpointGroupId()); change.setType(type); history.setChange(change); return historyService.saveHistory(history); }
@Test public void findProfileFilterByAppIdAndVersionTest() { List<ProfileFilterDto> generated = generateFilterDto(null, null, null, 1, true); ProfileFilterDto first = generated.get(0); List<ProfileFilterDto> filters = profileService.findProfileFiltersByAppIdAndVersionsCombination(first.getApplicationId(), first.getEndpointProfileSchemaVersion(), first.getServerProfileSchemaVersion()); Assert.assertNotNull(filters); Assert.assertFalse(filters.isEmpty()); }
@Test public void deactivateProfileFilterTest() { List<ProfileFilterDto> filterList = generateFilterDto(null, null, null, 1, true); ProfileFilterDto pf = filterList.get(0); String appId = pf.getApplicationId(); List<ProfileFilterDto> filters = profileService.findProfileFiltersByAppIdAndVersionsCombination(pf.getApplicationId(), pf.getEndpointProfileSchemaVersion(), pf.getServerProfileSchemaVersion()); Assert.assertNotNull(filters); ProfileFilterDto filter = filters.get(0); filter.setId(null); EndpointGroupDto group = generateEndpointGroupDto(appId); filter.setEndpointGroupId(group.getId()); ProfileFilterDto dto = profileService.saveProfileFilter(filter); ChangeProfileFilterNotification change = profileService.activateProfileFilter(dto.getId(), null); Assert.assertNotNull(change); Assert.assertEquals(UpdateStatus.ACTIVE, change.getProfileFilterDto().getStatus()); change = profileService.deactivateProfileFilter(dto.getId(), null); Assert.assertNotNull(change); Assert.assertEquals(UpdateStatus.DEPRECATED, change.getProfileFilterDto().getStatus()); }