### Question:
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);  }### Answer:
@Test public void acceptsNoDatabases() { ClusterV4Request request = requestWithDatabases(); subject.validateRdsConfigs(request, null, workspace); }
@Test public void acceptsMultipleDatabasesOfDifferentType() { ClusterV4Request request = requestWithDatabases(DatabaseType.HIVE, DatabaseType.HUE, DatabaseType.RANGER); subject.validateRdsConfigs(request, null, workspace); }
@Test public void rejectsMultipleDatabasesOfSameType() { ClusterV4Request request = requestWithDatabases(DatabaseType.HIVE, DatabaseType.HUE, DatabaseType.HIVE, DatabaseType.RANGER, DatabaseType.RANGER); BadRequestException exception = assertThrows(BadRequestException.class, () -> subject.validateRdsConfigs(request, null, workspace)); assertTrue(exception.getMessage().contains("HIVE")); assertFalse(exception.getMessage().contains("HUE")); assertTrue(exception.getMessage().contains("RANGER")); }