@Test public void validateShouldThrowExceptionWhenConnectorNameIsEmpty() { ConnectorDefinition connectorDefinition = new ConnectorDefinition(); connectorDefinition.setName(""); Throwable throwable = catchThrowable( () -> connectorDefinitionService.validate(Collections.singletonList(connectorDefinition)) ); assertThat(throwable) .isInstanceOf(IllegalStateException.class) .hasMessage("connectorDefinition name cannot be null or empty"); }
protected void validate(List<ConnectorDefinition> connectorDefinitions) { if (!connectorDefinitions.isEmpty()) { Set<String> processedNames = new HashSet<>(); for (ConnectorDefinition connectorDefinition : connectorDefinitions) { String name = connectorDefinition.getName(); if (name == null || name.isEmpty()) { throw new IllegalStateException("connectorDefinition name cannot be null or empty"); } if (name.contains(".")) { throw new IllegalStateException("connectorDefinition name cannot have '.' character"); } if (!processedNames.add(name)) { throw new IllegalStateException("More than one connectorDefinition with name '" + name + "' was found. Names must be unique."); } } } }
ConnectorDefinitionService { protected void validate(List<ConnectorDefinition> connectorDefinitions) { if (!connectorDefinitions.isEmpty()) { Set<String> processedNames = new HashSet<>(); for (ConnectorDefinition connectorDefinition : connectorDefinitions) { String name = connectorDefinition.getName(); if (name == null || name.isEmpty()) { throw new IllegalStateException("connectorDefinition name cannot be null or empty"); } if (name.contains(".")) { throw new IllegalStateException("connectorDefinition name cannot have '.' character"); } if (!processedNames.add(name)) { throw new IllegalStateException("More than one connectorDefinition with name '" + name + "' was found. Names must be unique."); } } } } }
ConnectorDefinitionService { protected void validate(List<ConnectorDefinition> connectorDefinitions) { if (!connectorDefinitions.isEmpty()) { Set<String> processedNames = new HashSet<>(); for (ConnectorDefinition connectorDefinition : connectorDefinitions) { String name = connectorDefinition.getName(); if (name == null || name.isEmpty()) { throw new IllegalStateException("connectorDefinition name cannot be null or empty"); } if (name.contains(".")) { throw new IllegalStateException("connectorDefinition name cannot have '.' character"); } if (!processedNames.add(name)) { throw new IllegalStateException("More than one connectorDefinition with name '" + name + "' was found. Names must be unique."); } } } } ConnectorDefinitionService(String connectorRoot, ObjectMapper objectMapper, ResourcePatternResolver resourceLoader); }
ConnectorDefinitionService { protected void validate(List<ConnectorDefinition> connectorDefinitions) { if (!connectorDefinitions.isEmpty()) { Set<String> processedNames = new HashSet<>(); for (ConnectorDefinition connectorDefinition : connectorDefinitions) { String name = connectorDefinition.getName(); if (name == null || name.isEmpty()) { throw new IllegalStateException("connectorDefinition name cannot be null or empty"); } if (name.contains(".")) { throw new IllegalStateException("connectorDefinition name cannot have '.' character"); } if (!processedNames.add(name)) { throw new IllegalStateException("More than one connectorDefinition with name '" + name + "' was found. Names must be unique."); } } } } ConnectorDefinitionService(String connectorRoot, ObjectMapper objectMapper, ResourcePatternResolver resourceLoader); List<ConnectorDefinition> get(); }
ConnectorDefinitionService { protected void validate(List<ConnectorDefinition> connectorDefinitions) { if (!connectorDefinitions.isEmpty()) { Set<String> processedNames = new HashSet<>(); for (ConnectorDefinition connectorDefinition : connectorDefinitions) { String name = connectorDefinition.getName(); if (name == null || name.isEmpty()) { throw new IllegalStateException("connectorDefinition name cannot be null or empty"); } if (name.contains(".")) { throw new IllegalStateException("connectorDefinition name cannot have '.' character"); } if (!processedNames.add(name)) { throw new IllegalStateException("More than one connectorDefinition with name '" + name + "' was found. Names must be unique."); } } } } ConnectorDefinitionService(String connectorRoot, ObjectMapper objectMapper, ResourcePatternResolver resourceLoader); List<ConnectorDefinition> get();  }