JdbcConnectionEntityBuilder implements EntityBuilder { public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { Map<String, JdbcConnection> jdbcConnectionMap = Optional.ofNullable(bundle.getJdbcConnections()).orElse(Collections.emptyMap()); return buildEntities(jdbcConnectionMap, bundle, bundleType, document); } @Inject  JdbcConnectionEntityBuilder(IdGenerator idGenerator); List<Entity> build(Bundle bundle, BundleType bundleType, Document document); @Override @NotNull Integer getOrder();  }
@Test void buildFromEmptyBundle_noConnections() { JdbcConnectionEntityBuilder builder = new JdbcConnectionEntityBuilder(ID_GENERATOR); final List<Entity> entities = builder.build(new Bundle(), BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertTrue(entities.isEmpty()); }
@Test void buildWithConnection_checkBundleContainsConnection() { JdbcConnectionEntityBuilder builder = new JdbcConnectionEntityBuilder(ID_GENERATOR); final Bundle bundle = new Bundle(projectInfo); bundle.putAllJdbcConnections(ImmutableMap.of(TEST_JDBC_CONNECTION, buildJdbcConnection(emptyMap()))); final List<Entity> entities = builder.build(bundle, BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertFalse(entities.isEmpty()); assertEquals(1, entities.size()); }