CassandraConnectionEntityBuilder implements EntityBuilder { @Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, CassandraConnection> entities = Optional.ofNullable(bundle.getCassandraConnections()).orElse(Collections.emptyMap()); return buildEntities(entities, ((AnnotatedBundle) bundle).getFullBundle(), bundleType, document); } else { Map<String, CassandraConnection> entities = bundle.getCassandraConnections(); return buildEntities(entities, bundle, bundleType, document); } } @Inject  CassandraConnectionEntityBuilder(IdGenerator idGenerator); @Override List<Entity> build(Bundle bundle, BundleType bundleType, Document document); @Override @NotNull Integer getOrder();  }
@Test void buildFromEmptyBundle_noConnections() { CassandraConnectionEntityBuilder builder = new CassandraConnectionEntityBuilder(ID_GENERATOR); final List<Entity> entities = builder.build(new Bundle(), EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertTrue(entities.isEmpty()); }
@Test void buildWithConnection_checkBundleContainsConnection() { CassandraConnectionEntityBuilder builder = new CassandraConnectionEntityBuilder(ID_GENERATOR); final Bundle bundle = new Bundle(projectInfo); addPasswordIfNecessary(true, bundle); bundle.putAllCassandraConnections(ImmutableMap.of(TEST_CASSANDRA_CONNECTION, buildCassandraConnection())); final List<Entity> entities = builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertFalse(entities.isEmpty()); assertEquals(1, entities.size()); }