@Override public List<TopicDto> findVacantTopicsByEndpointGroupId(String endpointGroupId) { validateId(endpointGroupId, "Can't find vacant topics. Invalid endpoint group id " + endpointGroupId); List<TopicDto> topics = Collections.emptyList(); EndpointGroup endpointGroup = endpointGroupDao.findById(endpointGroupId); String applicationId = null; if (endpointGroup != null) { applicationId = endpointGroup.getApplicationId(); } if (isNotBlank(applicationId)) { topics = convertDtoList(topicDao.findVacantTopicsByGroupId(applicationId, endpointGroupId)); } else { LOG.warn("Can't get application id from endpoint group."); } return topics; }
@Override public List<VersionDto> findVacantSchemasByEndpointGroupId(String endpointGroupId) { validateId(endpointGroupId, "Can't find vacant schemas. Invalid endpoint group id: " + endpointGroupId); EndpointGroup group = endpointGroupDao.findById(endpointGroupId); List<Configuration> configurations = configurationDao.findActualByEndpointGroupId( endpointGroupId); List<String> usedSchemaIds = new ArrayList<>(); for (Configuration configuration : configurations) { ConfigurationSchema schema = configuration.getConfigurationSchema(); if (schema != null) { usedSchemaIds.add(idToString(schema.getId())); } } List<ConfigurationSchema> schemas = configurationSchemaDao.findVacantSchemas( group.getApplicationId(), usedSchemaIds); List<VersionDto> schemaDtoList = new ArrayList<>(); for (ConfigurationSchema schema : schemas) { schemaDtoList.add(schema.toVersionDto()); } return schemaDtoList; }
+ endpointGroupId); EndpointGroup group = endpointGroupDao.findById(endpointGroupId); String appId = group.getApplicationId(); List<ServerProfileSchemaDto> serverSchemas = serverProfileService .findServerProfileSchemasByAppId(appId);
@Test public void findByApplicationId() { EndpointGroup endpointGroup = generateEndpointGroup(null, null); List<EndpointGroup> groups = endpointGroupDao.findByApplicationId(endpointGroup.getApplicationId()); Assert.assertEquals(1, groups.size()); }
@Test public void testFindVacantTopicsByGroupId() { Topic first = generateTopic(null, null, "first"); Application app = first.getApplication(); Topic second = generateTopic(app, null, "second"); Set<Topic> firstTopics = new HashSet<>(); firstTopics.add(first); firstTopics.add(second); Topic third = generateTopic(app, null, "third"); Topic fourth = generateTopic(app, null, "fourth"); Set<Topic> secondTopics = new HashSet<>(); secondTopics.add(third); secondTopics.add(fourth); EndpointGroup firstGroup = generateEndpointGroup(app, firstTopics); EndpointGroup secondGroup = generateEndpointGroup(app, secondTopics); List<Topic> foundOne = topicDao.findVacantTopicsByGroupId(firstGroup.getApplicationId(), firstGroup.getId().toString()); Set<Topic> firstGroupSet = new HashSet<>(); firstGroupSet.addAll(foundOne); List<Topic> foundTwo = topicDao.findVacantTopicsByGroupId(secondGroup.getApplicationId(), secondGroup.getId().toString()); Set<Topic> secondGroupSet = new HashSet<>(); secondGroupSet.addAll(foundTwo); Assert.assertEquals(secondTopics, firstGroupSet); Assert.assertEquals(firstTopics, secondGroupSet); }
HistoryDto historyDto = addHistory(groupDto, ChangeType.REMOVE_GROUP); changeDto = new ChangeNotificationDto(); changeDto.setAppId(endpointGroup.getApplicationId()); changeDto.setAppSeqNumber(historyDto.getSequenceNumber()); changeDto.setGroupId(groupDto.getId());
@Test public void findByAppIdAndWeight() { EndpointGroup endpointGroup = generateEndpointGroup(null, null); EndpointGroup group = endpointGroupDao.findByAppIdAndWeight(endpointGroup.getApplicationId(), endpointGroup.getWeight()); Assert.assertEquals(endpointGroup, group); }
@Test public void findByAppIdAndName() { EndpointGroup endpointGroup = generateEndpointGroup(null, null); EndpointGroup group = endpointGroupDao.findByAppIdAndName(endpointGroup.getApplicationId(), endpointGroup.getName()); Assert.assertEquals(endpointGroup, group); }