SsgActiveConnectorLoader implements BundleEntityLoader { @Override public void load(final Bundle bundle, final Element element) { final Element activeConnectorElement = getSingleChildElement(getSingleChildElement(element, RESOURCE), ACTIVE_CONNECTOR); final String name = getSingleChildElementTextContent(activeConnectorElement, NAME); final String type = getSingleChildElementTextContent(activeConnectorElement, TYPE); final String targetServiceReference = getSingleChildElementTextContent(activeConnectorElement, HARDWIRED); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(activeConnectorElement, PROPERTIES, true), PROPERTIES); SsgActiveConnector ssgActiveConnector = new SsgActiveConnector(); ssgActiveConnector.setName(name); ssgActiveConnector.setConnectorType(type); ssgActiveConnector.setProperties(properties); ssgActiveConnector.setTargetServiceReference(targetServiceReference); ssgActiveConnector.setId(activeConnectorElement.getAttribute(ATTRIBUTE_ID)); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(activeConnectorElement.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); ssgActiveConnector.setAnnotations(annotations); Optional<Map.Entry<String, Object>> entryOptional = properties.entrySet().stream().filter(entry -> entry.getKey().endsWith("SslKeystoreId")).findFirst(); entryOptional.ifPresent(entry -> { properties.remove(entry.getKey()); }); bundle.getSsgActiveConnectors().put(name, ssgActiveConnector); } @VisibleForTesting  SsgActiveConnectorLoader(); @Override void load(final Bundle bundle, final Element element); @Override String getEntityType();  }
@Test public void testLoad() throws DocumentParseException { SsgActiveConnectorLoader ssgActiveConnectorLoader = new SsgActiveConnectorLoader(); Bundle bundle = new Bundle(); Document document = DocumentTools.INSTANCE.parse(ACTIVE_CONNECTOR); ssgActiveConnectorLoader.load(bundle, document.getDocumentElement()); SsgActiveConnector ssgActiveConnector = bundle.getSsgActiveConnectors().get("MQNativeTest"); Assert.assertEquals("MqNative", ssgActiveConnector.getConnectorType()); Assert.assertNull(ssgActiveConnector.getTargetServiceReference()); Assert.assertTrue(ssgActiveConnector.getAnnotations().contains(new Annotation(AnnotationType.BUNDLE_HINTS))); }