@Test public void validates_proper_configuration_by_bolt_uri() { Collection<String> errors = datasourceConfigurationValidator.validate( Optional.of("jdbc:neo4j:bolt: Optional.empty(), Optional.empty()); assertThat(errors).isEmpty(); }
public Collection<String> validate(Optional<String> uri, Optional<DataSource> dataSource, Optional<String> database) { if (uri.isPresent() == dataSource.isPresent()) { return Collections.singletonList("Exactly one of JDBC URI or DataSource need to be configured"); } if (database.isPresent() && dataSource.isPresent()) { return Collections.singletonList("Database instance cannot be configured when configuring a DataSource"); } return uri.map(DatasourceConfigurationValidator::validateConnectionString).orElse(emptyList()); }
DatasourceConfigurationValidator { public Collection<String> validate(Optional<String> uri, Optional<DataSource> dataSource, Optional<String> database) { if (uri.isPresent() == dataSource.isPresent()) { return Collections.singletonList("Exactly one of JDBC URI or DataSource need to be configured"); } if (database.isPresent() && dataSource.isPresent()) { return Collections.singletonList("Database instance cannot be configured when configuring a DataSource"); } return uri.map(DatasourceConfigurationValidator::validateConnectionString).orElse(emptyList()); } }
DatasourceConfigurationValidator { public Collection<String> validate(Optional<String> uri, Optional<DataSource> dataSource, Optional<String> database) { if (uri.isPresent() == dataSource.isPresent()) { return Collections.singletonList("Exactly one of JDBC URI or DataSource need to be configured"); } if (database.isPresent() && dataSource.isPresent()) { return Collections.singletonList("Database instance cannot be configured when configuring a DataSource"); } return uri.map(DatasourceConfigurationValidator::validateConnectionString).orElse(emptyList()); }  }
DatasourceConfigurationValidator { public Collection<String> validate(Optional<String> uri, Optional<DataSource> dataSource, Optional<String> database) { if (uri.isPresent() == dataSource.isPresent()) { return Collections.singletonList("Exactly one of JDBC URI or DataSource need to be configured"); } if (database.isPresent() && dataSource.isPresent()) { return Collections.singletonList("Database instance cannot be configured when configuring a DataSource"); } return uri.map(DatasourceConfigurationValidator::validateConnectionString).orElse(emptyList()); }  Collection<String> validate(Optional<String> uri, Optional<DataSource> dataSource, Optional<String> database); }
DatasourceConfigurationValidator { public Collection<String> validate(Optional<String> uri, Optional<DataSource> dataSource, Optional<String> database) { if (uri.isPresent() == dataSource.isPresent()) { return Collections.singletonList("Exactly one of JDBC URI or DataSource need to be configured"); } if (database.isPresent() && dataSource.isPresent()) { return Collections.singletonList("Database instance cannot be configured when configuring a DataSource"); } return uri.map(DatasourceConfigurationValidator::validateConnectionString).orElse(emptyList()); }  Collection<String> validate(Optional<String> uri, Optional<DataSource> dataSource, Optional<String> database);  }