AdminDistributionTransformHelper { public CheckPolicyRequestType transformEntityAlertToCheckPolicy(RespondingGatewaySendAlertMessageType message, String target) { CheckPolicyRequestType result = new CheckPolicyRequestType(); if (message == null) { LOG.error("Request is null."); return result; } if (target == null || target.isEmpty()) { LOG.error("target is missing"); return result; } if (message.getEDXLDistribution() == null) { LOG.error("missing body"); return result; } if (message.getAssertion() == null) { LOG.error("missing assertion"); return result; } if (message.getAssertion().getHomeCommunity() == null) { LOG.error("missing home community"); return result; } RequestType request = new RequestType(); AttributeHelper attrHelper = new AttributeHelper(); LOG.debug("transformEntityAlertToCheckPolicy - adding subject"); SubjectType subject = new SubjectType(); subject.setSubjectCategory(SubjectHelper.SubjectCategory); LOG.debug("transformEntityAlertToCheckPolicy - adding subject"); request.getSubject().add(subject); ResourceType resource = new ResourceType(); resource.getAttribute().add(attrHelper.attributeFactory(Constants.HomeCommunityAttributeId, Constants.DataTypeString, message.getAssertion().getHomeCommunity().getHomeCommunityId())); request.getResource().add(resource); LOG.debug("transformEntityAlertToCheckPolicy - adding assertion data"); AssertionHelper assertHelp = new AssertionHelper(); assertHelp.appendAssertionDataToRequest(request, message.getAssertion()); request.setAction(ActionHelper.actionFactory(ActionOutValue)); result.setAssertion(message.getAssertion()); result.setRequest(request); return result; }  CheckPolicyRequestType transformNhinAlertToCheckPolicy(EDXLDistribution message, AssertionType assertion); CheckPolicyRequestType transformEntityAlertToCheckPolicy(RespondingGatewaySendAlertMessageType message,
            String target);  }
@Test public void testTransformEntityAlertToCheckPolicy_NoTarget() { AdminDistributionTransformHelper instance = new AdminDistributionTransformHelper() { @Override protected oasis.names.tc.xacml._2_0.context.schema.os.SubjectType createSubject(HomeCommunityType hc, AssertionType assertion) { return new oasis.names.tc.xacml._2_0.context.schema.os.SubjectType(); } }; RespondingGatewaySendAlertMessageType message = new RespondingGatewaySendAlertMessageType(); message.setAssertion(new AssertionType()); message.setEDXLDistribution(new EDXLDistribution()); CheckPolicyRequestType result = instance.transformEntityAlertToCheckPolicy(message, ""); assertNotNull(result); }
@Test public void testTransformEntityAlertToCheckPolicy_NoBody() { AdminDistributionTransformHelper instance = new AdminDistributionTransformHelper() { @Override protected oasis.names.tc.xacml._2_0.context.schema.os.SubjectType createSubject(HomeCommunityType hc, AssertionType assertion) { return new oasis.names.tc.xacml._2_0.context.schema.os.SubjectType(); } }; RespondingGatewaySendAlertMessageType message = new RespondingGatewaySendAlertMessageType(); message.setAssertion(new AssertionType()); String target = "121"; CheckPolicyRequestType result = instance.transformEntityAlertToCheckPolicy(message, target); assertNotNull(result); }
@Test public void testTransformEntityAlertToCheckPolicy_NoAssertion() { AdminDistributionTransformHelper instance = new AdminDistributionTransformHelper() { @Override protected oasis.names.tc.xacml._2_0.context.schema.os.SubjectType createSubject(HomeCommunityType hc, AssertionType assertion) { return new oasis.names.tc.xacml._2_0.context.schema.os.SubjectType(); } }; RespondingGatewaySendAlertMessageType message = new RespondingGatewaySendAlertMessageType(); message.setEDXLDistribution(new EDXLDistribution()); String target = "121"; CheckPolicyRequestType result = instance.transformEntityAlertToCheckPolicy(message, target); assertNotNull(result); }