MQRoutingAssertionBuilder implements PolicyAssertionBuilder { @Override public void buildAssertionElement(Element assertionElement, PolicyBuilderContext policyBuilderContext) { final Bundle bundle = policyBuilderContext.getBundle(); final IdGenerator idGenerator = policyBuilderContext.getIdGenerator(); final Element activeConnectorNameElement = getSingleChildElement(assertionElement, ACTIVE_CONNECTOR_NAME, true); if (activeConnectorNameElement != null) { final String activeConnectorName = activeConnectorNameElement.getAttributes().getNamedItem(STRING_VALUE).getTextContent(); activeConnectorNameElement.setAttribute(STRING_VALUE, bundle.applyUniqueName(activeConnectorName, ENVIRONMENT)); final SsgActiveConnector ssgActiveConnector = bundle.getSsgActiveConnectors().get(activeConnectorName); final String id = ssgActiveConnector != null && ssgActiveConnector.getAnnotatedEntity() != null && ssgActiveConnector.getAnnotatedEntity().getId() != null ? ssgActiveConnector.getAnnotatedEntity().getId() : idGenerator.generate(); Element activeConnectorGoidElement = createElementWithAttribute( policyBuilderContext.getPolicyDocument(), ACTIVE_CONNECTOR_GOID, GOID_VALUE, id ); assertionElement.insertBefore(activeConnectorGoidElement, activeConnectorNameElement); Element activeConnectorIdElement = createElementWithAttribute( policyBuilderContext.getPolicyDocument(), ACTIVE_CONNECTOR_ID, GOID_VALUE, id ); assertionElement.insertBefore(activeConnectorIdElement, activeConnectorNameElement); } }  @Override void buildAssertionElement(Element assertionElement, PolicyBuilderContext policyBuilderContext); @Override String getAssertionTagName();  }
@Test void testPrepareMqRoutingAssertionIds() { bundle.putAllSsgActiveConnectors(ImmutableMap.of("activeConnector1", createActiveConnectorWithAnnotation(AnnotationType.BUNDLE_HINTS, "2cd473fe16d98cd6b9348ffb404517bc"))); Element mqRoutingAssertionElement = createMqRoutingAssertion(document); policyBuilderContext = new PolicyBuilderContext("path.xml", document, bundle, new IdGenerator()); policyBuilderContext.withPolicy(policy); mqRoutingAssertionBuilder.buildAssertionElement(mqRoutingAssertionElement, policyBuilderContext); final Element connectorGoid = getSingleChildElement(mqRoutingAssertionElement, ACTIVE_CONNECTOR_GOID, true); final Element connectorid = getSingleChildElement(mqRoutingAssertionElement, ACTIVE_CONNECTOR_ID, true); final Element connectorName = getSingleChildElement(mqRoutingAssertionElement, ACTIVE_CONNECTOR_NAME, true); assertNotNull(connectorGoid); assertNotNull(connectorid); assertNotNull(connectorName); assertEquals("2cd473fe16d98cd6b9348ffb404517bc", connectorGoid.getAttributes().getNamedItem(GOID_VALUE).getTextContent()); assertEquals("2cd473fe16d98cd6b9348ffb404517bc", connectorid.getAttributes().getNamedItem(GOID_VALUE).getTextContent()); assertEquals("::" + projectInfo.getGroupName() + "::" + "activeConnector1" + "::1.0", connectorName.getAttributes().getNamedItem(STRING_VALUE).getTextContent()); }