@Test public void acceptsNoDatabases() { ClusterV4Request request = requestWithDatabases(); subject.validateRdsConfigs(request, null, workspace); }
public void validateRdsConfigs(ClusterV4Request request, User user, Workspace workspace) { if (request.getDatabases() != null) { Set<String> multipleTypes = request.getDatabases().stream() .map(rdsConfigName -> rdsConfigService.getByNameForWorkspace(rdsConfigName, workspace)) .collect(groupingBy(RDSConfig::getType, counting())) .entrySet().stream() .filter(e -> e.getValue() > 1L) .map(Map.Entry::getKey) .collect(toCollection(TreeSet::new)); if (!multipleTypes.isEmpty()) { throw new BadRequestException("Multiple databases are defined for the following types: " + String.join(",", multipleTypes)); } } }
RdsConfigValidator { public void validateRdsConfigs(ClusterV4Request request, User user, Workspace workspace) { if (request.getDatabases() != null) { Set<String> multipleTypes = request.getDatabases().stream() .map(rdsConfigName -> rdsConfigService.getByNameForWorkspace(rdsConfigName, workspace)) .collect(groupingBy(RDSConfig::getType, counting())) .entrySet().stream() .filter(e -> e.getValue() > 1L) .map(Map.Entry::getKey) .collect(toCollection(TreeSet::new)); if (!multipleTypes.isEmpty()) { throw new BadRequestException("Multiple databases are defined for the following types: " + String.join(",", multipleTypes)); } } } }
RdsConfigValidator { public void validateRdsConfigs(ClusterV4Request request, User user, Workspace workspace) { if (request.getDatabases() != null) { Set<String> multipleTypes = request.getDatabases().stream() .map(rdsConfigName -> rdsConfigService.getByNameForWorkspace(rdsConfigName, workspace)) .collect(groupingBy(RDSConfig::getType, counting())) .entrySet().stream() .filter(e -> e.getValue() > 1L) .map(Map.Entry::getKey) .collect(toCollection(TreeSet::new)); if (!multipleTypes.isEmpty()) { throw new BadRequestException("Multiple databases are defined for the following types: " + String.join(",", multipleTypes)); } } }  }
RdsConfigValidator { public void validateRdsConfigs(ClusterV4Request request, User user, Workspace workspace) { if (request.getDatabases() != null) { Set<String> multipleTypes = request.getDatabases().stream() .map(rdsConfigName -> rdsConfigService.getByNameForWorkspace(rdsConfigName, workspace)) .collect(groupingBy(RDSConfig::getType, counting())) .entrySet().stream() .filter(e -> e.getValue() > 1L) .map(Map.Entry::getKey) .collect(toCollection(TreeSet::new)); if (!multipleTypes.isEmpty()) { throw new BadRequestException("Multiple databases are defined for the following types: " + String.join(",", multipleTypes)); } } }  void validateRdsConfigs(ClusterV4Request request, User user, Workspace workspace); }
RdsConfigValidator { public void validateRdsConfigs(ClusterV4Request request, User user, Workspace workspace) { if (request.getDatabases() != null) { Set<String> multipleTypes = request.getDatabases().stream() .map(rdsConfigName -> rdsConfigService.getByNameForWorkspace(rdsConfigName, workspace)) .collect(groupingBy(RDSConfig::getType, counting())) .entrySet().stream() .filter(e -> e.getValue() > 1L) .map(Map.Entry::getKey) .collect(toCollection(TreeSet::new)); if (!multipleTypes.isEmpty()) { throw new BadRequestException("Multiple databases are defined for the following types: " + String.join(",", multipleTypes)); } } }  void validateRdsConfigs(ClusterV4Request request, User user, Workspace workspace);  }