SsgActiveConnectorEntityBuilder implements EntityBuilder { @Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, SsgActiveConnector> activeConnectorMap = Optional.ofNullable(bundle.getSsgActiveConnectors()).orElse(Collections.emptyMap()); return buildEntities(activeConnectorMap, ((AnnotatedBundle) bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getSsgActiveConnectors(), bundle, bundleType, document); } } @Inject  SsgActiveConnectorEntityBuilder(IdGenerator idGenerator); @Override List<Entity> build(Bundle bundle, BundleType bundleType, Document document); @Override @NotNull Integer getOrder();  }
@Test public void buildNoActiveConnectors() { final SsgActiveConnectorEntityBuilder builder = new SsgActiveConnectorEntityBuilder(new IdGenerator()); final Bundle bundle = new Bundle(); List<Entity> activeConnectors = builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertEquals(0, activeConnectors.size()); activeConnectors = builder.build(bundle, EntityBuilder.BundleType.DEPLOYMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertEquals(0, activeConnectors.size()); }
@Test public void buildActiveConnectors() { final SsgActiveConnectorEntityBuilder builder = new SsgActiveConnectorEntityBuilder(new IdGenerator()); List<Entity> activeConnectors = builder.build(getTestBundle(), EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertEquals(1, activeConnectors.size()); Entity ssgActiveConnector = activeConnectors.get(0); assertEquals("::testGroup::testName::1.0", ssgActiveConnector.getName()); Element element = ssgActiveConnector.getXml(); assertEquals("testServiceId", DocumentUtils.getSingleChildElementTextContent(element, BundleElementNames.HARDWIRED)); activeConnectors = builder.build(getTestAnnotatedBundle(), EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertEquals(1, activeConnectors.size()); }