protected EndpointGroupDto generateEndpointGroup(String applicationId, String endpointGroupName) { EndpointGroupDto group = new EndpointGroupDto(); if (isBlank(applicationId)) { applicationId = generateApplication(null).getId(); } group.setApplicationId(applicationId); group.setName(endpointGroupName); group.setWeight(random.nextInt()); return endpointService.saveEndpointGroup(group); } }
public void addTopicToEndpointGroup(EndpointGroupDto endpointGroup, TopicDto topic) throws Exception { addTopicToEndpointGroup(endpointGroup.getId(), topic.getId()); }
/** * Create instance of <code>EndpointGroup</code>. * * @param dto data transfer object */ public EndpointGroup(EndpointGroupDto dto) { if (dto != null) { this.id = getLongId(dto); this.name = dto.getName(); this.sequenceNumber = dto.getSequenceNumber(); this.weight = dto.getWeight(); this.description = dto.getDescription(); this.createdUsername = dto.getCreatedUsername(); this.createdTime = dto.getCreatedTime(); Long appId = getLongId(dto.getApplicationId()); this.application = appId != null ? new Application(appId) : null; this.topics = getTopic(dto.getTopics()); } }
@Override protected EndpointGroupDto newEntity() { EndpointGroupDto endpointGroup = new EndpointGroupDto(); endpointGroup.setApplicationId(applicationId); return endpointGroup; }
private EndpointGroupDto createDefaultGroup(String appId, String createdUsername) { EndpointGroupDto endpointGroup = new EndpointGroupDto(); endpointGroup.setName(GROUP_ALL); endpointGroup.setCreatedUsername(createdUsername); endpointGroup.setApplicationId(appId); return endpointService.saveEndpointGroup(endpointGroup); }
@Override public EndpointGroupDto toDto() { EndpointGroupDto dto = createDto(); dto.setId(getStringId()); dto.setDescription(description); dto.setCreatedUsername(createdUsername); dto.setCreatedTime(createdTime); if (application != null) { dto.setApplicationId(application.getStringId()); } dto.setName(name); dto.setSequenceNumber(sequenceNumber); dto.setWeight(weight); dto.setTopics(getTopicIds(topics)); return dto; }
@Test(expected = IncorrectParameterException.class) public void saveEndpointGroupWithSameNameTest() { EndpointGroupDto group = generateEndpointGroupDto(null); EndpointGroupDto found = endpointService.findEndpointGroupById(group.getId()); found.setId(null); found.setWeight(found.getWeight() + 1); endpointService.saveEndpointGroup(found); }
EndpointProfilesPageDto found; EndpointGroupDto endpointGroupDto = new EndpointGroupDto(); endpointGroupDto.setWeight(1); cfGroupStateSave.add(new EndpointGroupStateDto("111", null, null)); cfGroupStateSave.add(new EndpointGroupStateDto("222", null, null));
+ endpointGroupDto); EndpointGroupDto savedGroup = null; String appId = endpointGroupDto.getApplicationId(); if (isValidId(appId)) { String id = endpointGroupDto.getId(); EndpointGroup groupWithSameWeight = endpointGroupDao.findByAppIdAndWeight(appId, endpointGroupDto.getWeight()); EndpointGroup groupWithSameName = endpointGroupDao.findByAppIdAndName(appId, endpointGroupDto.getName()); if (StringUtils.isBlank(id)) { if (groupWithSameWeight + "application id"); } else { endpointGroupDto.setCreatedTime(System.currentTimeMillis()); savedGroup = getDto(endpointGroupDao.save(new EndpointGroup(endpointGroupDto))); != savedGroup.getWeight()) { addHistory(savedGroup, ChangeType.UPDATE_WEIGHT);
@Override public EndpointGroupDto editEndpointGroup(EndpointGroupDto endpointGroup) throws KaaAdminServiceException { checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { checkEndpointGroupWeight(endpointGroup.getWeight()); if (isEmpty(endpointGroup.getId())) { endpointGroup.setCreatedUsername(getCurrentUser().getUsername()); checkApplicationId(endpointGroup.getApplicationId()); } else { checkEndpointGroupId(endpointGroup.getId()); } return controlService.editEndpointGroup(endpointGroup); } catch (Exception ex) { throw Utils.handleException(ex); } }
@Override protected void onEntityRetrieved() { detailsView.getName().setValue(entity.getName()); if (!create) { detailsView.getWeight().setValue(entity.getWeight()); detailsView.setProfileFiltersVisible(entity.getWeight() > 0); } detailsView.getDescription().setValue(entity.getDescription()); detailsView.getCreatedUsername().setValue(entity.getCreatedUsername()); detailsView .getCreatedDateTime() .setValue(Utils.millisecondsToDateTimeString(entity.getCreatedTime())); if (entity.getWeight() == 0 && !create) { detailsView.setReadOnly(); } }
@Override protected void onSave() { entity.setName(detailsView.getName().getValue()); entity.setWeight(detailsView.getWeight().getValue()); entity.setDescription(detailsView.getDescription().getValue()); }
@Test(expected = IncorrectParameterException.class) public void saveEndpointGroupWithExistingNameTest() { ApplicationDto app = generateApplicationDto(); List<EndpointGroupDto> groups = endpointService.findEndpointGroupsByAppId(app.getId()); Assert.assertFalse(groups.isEmpty()); EndpointGroupDto group = groups.get(0); group.setId(null); group.setWeight(group.getWeight() + 1); endpointService.saveEndpointGroup(group); }
@Override public String getValue(EndpointGroupDto item) { return item.getWeight() + ""; } }, 40);
private HistoryDto addHistory(EndpointGroupDto dto, ChangeType type, String topicId) { LOG.debug("Add history information about endpoint group update"); HistoryDto history = new HistoryDto(); history.setApplicationId(dto.getApplicationId()); ChangeDto change = new ChangeDto(); change.setEndpointGroupId(dto.getId()); change.setType(type); change.setTopicId(topicId); history.setChange(change); return historyService.saveHistory(history); }
protected EndpointGroupDto createDto() { return new EndpointGroupDto(); }
@Test(expected = IncorrectParameterException.class) public void saveEndpointGroupWithSameWeightTest() { EndpointGroupDto group = generateEndpointGroupDto(null); EndpointGroupDto found = endpointService.findEndpointGroupById(group.getId()); found.setId(null); endpointService.saveEndpointGroup(found); }
EndpointGroupDto checkEndpointGroupId(String endpointGroupId) throws KaaAdminServiceException { try { if (isEmpty(endpointGroupId)) { throw new IllegalArgumentException("The endpointGroupId parameter is empty."); } EndpointGroupDto endpointGroup = controlService.getEndpointGroup(endpointGroupId); checkNotNull(endpointGroup); checkApplicationId(endpointGroup.getApplicationId()); return endpointGroup; } catch (Exception ex) { throw Utils.handleException(ex); } }
@Test(expected = IncorrectParameterException.class) public void saveEndpointGroupWithExistingWeightTest() { ApplicationDto app = generateApplicationDto(); List<EndpointGroupDto> groups = endpointService.findEndpointGroupsByAppId(app.getId()); Assert.assertFalse(groups.isEmpty()); EndpointGroupDto group = groups.get(0); group.setId(null); group.setName("Updated Group Name"); endpointService.saveEndpointGroup(group); }