@Test public void testBuildAssertionElement() { String connectionName = "jmsConnection"; Element assertion = createAssertion(document, connectionName); policyBuilderContext = new PolicyBuilderContext("path.xml", document, bundle, new IdGenerator()); policyBuilderContext.withPolicy(policy); jmsAssertionBuilder.buildAssertionElement(assertion, policyBuilderContext); Element connectionNameEle = getSingleChildElement(assertion, JMS_ENDPOINT_NAME, true); assertNotNull(connectionNameEle); assertEquals("::" + projectInfo.getGroupName() + "::" + connectionName + "::1.0", connectionNameEle.getAttributes().getNamedItem(STRING_VALUE).getTextContent()); }
@Override public void buildAssertionElement(Element assertionElement, PolicyBuilderContext policyBuilderContext) { final Bundle bundle = policyBuilderContext.getBundle(); final IdGenerator idGenerator = policyBuilderContext.getIdGenerator(); final Element connectionNameElement = getSingleChildElement(assertionElement, JMS_ENDPOINT_NAME, true); if (connectionNameElement != null) { final String connectionName = connectionNameElement.getAttributes().getNamedItem(STRING_VALUE).getTextContent(); connectionNameElement.setAttribute(STRING_VALUE, bundle.applyUniqueName(connectionName, ENVIRONMENT)); final JmsDestination jmsDestination = bundle.getJmsDestinations().get(connectionName); String id; if (jmsDestination != null) { if (jmsDestination.getAnnotatedEntity() != null && jmsDestination.getAnnotatedEntity().getId() != null) { id = jmsDestination.getAnnotatedEntity().getId(); } else { id = jmsDestination.getId(); } } else { id = idGenerator.generate(); } Element jmdDestinationGoidElement = createElementWithAttribute( policyBuilderContext.getPolicyDocument(), JMS_ENDPOINT_OID, GOID_VALUE, id ); assertionElement.insertBefore(jmdDestinationGoidElement, connectionNameElement); } }
JmsAssertionBuilder implements PolicyAssertionBuilder { @Override public void buildAssertionElement(Element assertionElement, PolicyBuilderContext policyBuilderContext) { final Bundle bundle = policyBuilderContext.getBundle(); final IdGenerator idGenerator = policyBuilderContext.getIdGenerator(); final Element connectionNameElement = getSingleChildElement(assertionElement, JMS_ENDPOINT_NAME, true); if (connectionNameElement != null) { final String connectionName = connectionNameElement.getAttributes().getNamedItem(STRING_VALUE).getTextContent(); connectionNameElement.setAttribute(STRING_VALUE, bundle.applyUniqueName(connectionName, ENVIRONMENT)); final JmsDestination jmsDestination = bundle.getJmsDestinations().get(connectionName); String id; if (jmsDestination != null) { if (jmsDestination.getAnnotatedEntity() != null && jmsDestination.getAnnotatedEntity().getId() != null) { id = jmsDestination.getAnnotatedEntity().getId(); } else { id = jmsDestination.getId(); } } else { id = idGenerator.generate(); } Element jmdDestinationGoidElement = createElementWithAttribute( policyBuilderContext.getPolicyDocument(), JMS_ENDPOINT_OID, GOID_VALUE, id ); assertionElement.insertBefore(jmdDestinationGoidElement, connectionNameElement); } } }
JmsAssertionBuilder implements PolicyAssertionBuilder { @Override public void buildAssertionElement(Element assertionElement, PolicyBuilderContext policyBuilderContext) { final Bundle bundle = policyBuilderContext.getBundle(); final IdGenerator idGenerator = policyBuilderContext.getIdGenerator(); final Element connectionNameElement = getSingleChildElement(assertionElement, JMS_ENDPOINT_NAME, true); if (connectionNameElement != null) { final String connectionName = connectionNameElement.getAttributes().getNamedItem(STRING_VALUE).getTextContent(); connectionNameElement.setAttribute(STRING_VALUE, bundle.applyUniqueName(connectionName, ENVIRONMENT)); final JmsDestination jmsDestination = bundle.getJmsDestinations().get(connectionName); String id; if (jmsDestination != null) { if (jmsDestination.getAnnotatedEntity() != null && jmsDestination.getAnnotatedEntity().getId() != null) { id = jmsDestination.getAnnotatedEntity().getId(); } else { id = jmsDestination.getId(); } } else { id = idGenerator.generate(); } Element jmdDestinationGoidElement = createElementWithAttribute( policyBuilderContext.getPolicyDocument(), JMS_ENDPOINT_OID, GOID_VALUE, id ); assertionElement.insertBefore(jmdDestinationGoidElement, connectionNameElement); } }  }
JmsAssertionBuilder implements PolicyAssertionBuilder { @Override public void buildAssertionElement(Element assertionElement, PolicyBuilderContext policyBuilderContext) { final Bundle bundle = policyBuilderContext.getBundle(); final IdGenerator idGenerator = policyBuilderContext.getIdGenerator(); final Element connectionNameElement = getSingleChildElement(assertionElement, JMS_ENDPOINT_NAME, true); if (connectionNameElement != null) { final String connectionName = connectionNameElement.getAttributes().getNamedItem(STRING_VALUE).getTextContent(); connectionNameElement.setAttribute(STRING_VALUE, bundle.applyUniqueName(connectionName, ENVIRONMENT)); final JmsDestination jmsDestination = bundle.getJmsDestinations().get(connectionName); String id; if (jmsDestination != null) { if (jmsDestination.getAnnotatedEntity() != null && jmsDestination.getAnnotatedEntity().getId() != null) { id = jmsDestination.getAnnotatedEntity().getId(); } else { id = jmsDestination.getId(); } } else { id = idGenerator.generate(); } Element jmdDestinationGoidElement = createElementWithAttribute( policyBuilderContext.getPolicyDocument(), JMS_ENDPOINT_OID, GOID_VALUE, id ); assertionElement.insertBefore(jmdDestinationGoidElement, connectionNameElement); } }  @Override void buildAssertionElement(Element assertionElement, PolicyBuilderContext policyBuilderContext); @Override String getAssertionTagName(); }
JmsAssertionBuilder implements PolicyAssertionBuilder { @Override public void buildAssertionElement(Element assertionElement, PolicyBuilderContext policyBuilderContext) { final Bundle bundle = policyBuilderContext.getBundle(); final IdGenerator idGenerator = policyBuilderContext.getIdGenerator(); final Element connectionNameElement = getSingleChildElement(assertionElement, JMS_ENDPOINT_NAME, true); if (connectionNameElement != null) { final String connectionName = connectionNameElement.getAttributes().getNamedItem(STRING_VALUE).getTextContent(); connectionNameElement.setAttribute(STRING_VALUE, bundle.applyUniqueName(connectionName, ENVIRONMENT)); final JmsDestination jmsDestination = bundle.getJmsDestinations().get(connectionName); String id; if (jmsDestination != null) { if (jmsDestination.getAnnotatedEntity() != null && jmsDestination.getAnnotatedEntity().getId() != null) { id = jmsDestination.getAnnotatedEntity().getId(); } else { id = jmsDestination.getId(); } } else { id = idGenerator.generate(); } Element jmdDestinationGoidElement = createElementWithAttribute( policyBuilderContext.getPolicyDocument(), JMS_ENDPOINT_OID, GOID_VALUE, id ); assertionElement.insertBefore(jmdDestinationGoidElement, connectionNameElement); } }  @Override void buildAssertionElement(Element assertionElement, PolicyBuilderContext policyBuilderContext); @Override String getAssertionTagName();  }