@Test public void dataSourceRelationshipWithDataSourceAvailable() throws SQLException { Assertions.assertThat(detector.detect()) .contains(Dependency.on(Component.of("catalog", ComponentType.RELATIONAL_DATABASE))); }
@Override public Set<Relationship> detect() { if (relationsCache == null) { final Set<Relationship> result = new HashSet<>(); for (DataSource ds : dataSources) { try (Connection connection = ds.getConnection()) { result.add(Dependency.on(Component.of(extractName(connection), extractDatabaseType(connection)))); } catch (SQLException e) { LOGGER.error("Could not fetch the default catalog of the database connection", e); } } relationsCache = result; } return new HashSet<>(relationsCache); }
DataSourceRelationshipDetector implements RelationshipDetector { @Override public Set<Relationship> detect() { if (relationsCache == null) { final Set<Relationship> result = new HashSet<>(); for (DataSource ds : dataSources) { try (Connection connection = ds.getConnection()) { result.add(Dependency.on(Component.of(extractName(connection), extractDatabaseType(connection)))); } catch (SQLException e) { LOGGER.error("Could not fetch the default catalog of the database connection", e); } } relationsCache = result; } return new HashSet<>(relationsCache); } }
DataSourceRelationshipDetector implements RelationshipDetector { @Override public Set<Relationship> detect() { if (relationsCache == null) { final Set<Relationship> result = new HashSet<>(); for (DataSource ds : dataSources) { try (Connection connection = ds.getConnection()) { result.add(Dependency.on(Component.of(extractName(connection), extractDatabaseType(connection)))); } catch (SQLException e) { LOGGER.error("Could not fetch the default catalog of the database connection", e); } } relationsCache = result; } return new HashSet<>(relationsCache); } DataSourceRelationshipDetector(Collection<DataSource> dataSources); }
DataSourceRelationshipDetector implements RelationshipDetector { @Override public Set<Relationship> detect() { if (relationsCache == null) { final Set<Relationship> result = new HashSet<>(); for (DataSource ds : dataSources) { try (Connection connection = ds.getConnection()) { result.add(Dependency.on(Component.of(extractName(connection), extractDatabaseType(connection)))); } catch (SQLException e) { LOGGER.error("Could not fetch the default catalog of the database connection", e); } } relationsCache = result; } return new HashSet<>(relationsCache); } DataSourceRelationshipDetector(Collection<DataSource> dataSources); @Override Set<Relationship> detect(); }
DataSourceRelationshipDetector implements RelationshipDetector { @Override public Set<Relationship> detect() { if (relationsCache == null) { final Set<Relationship> result = new HashSet<>(); for (DataSource ds : dataSources) { try (Connection connection = ds.getConnection()) { result.add(Dependency.on(Component.of(extractName(connection), extractDatabaseType(connection)))); } catch (SQLException e) { LOGGER.error("Could not fetch the default catalog of the database connection", e); } } relationsCache = result; } return new HashSet<>(relationsCache); } DataSourceRelationshipDetector(Collection<DataSource> dataSources); @Override Set<Relationship> detect();  }