PolicyEngineUtil { public CheckPolicyResponseType checkAssertionAttributeStatement(AssertionType assertion) { StringBuilder sBuilder = new StringBuilder(); boolean passesPolicyCheck; if (assertion != null) { passesPolicyCheck = checkUserInfo(assertion.getUserInfo(), sBuilder) && checkPurposeOfDisclosure(assertion.getPurposeOfDisclosureCoded(), sBuilder) && checkHomeCommunity(assertion.getHomeCommunity(), sBuilder); } else { sBuilder.append("| Assertion check failed. |"); passesPolicyCheck = false; } DecisionType decision; if (passesPolicyCheck) { decision = DecisionType.PERMIT; sBuilder.append("Exiting out from CheckPolicyResponseType without any error"); } else { decision = DecisionType.DENY; } return createPolicyResponse(decision, sBuilder.toString()); }  CheckPolicyResponseType checkAssertionAttributeStatement(AssertionType assertion);  }
@Test public void testEmtpy() { AssertionType assertion = new AssertionType(); PolicyEngineUtil util = new PolicyEngineUtil(); CheckPolicyResponseType resp = util.checkAssertionAttributeStatement(assertion); assertDeny(resp); }
@Test public void testAll() { AssertionType assertion = getFullAssertion(); PolicyEngineUtil util = new PolicyEngineUtil(); CheckPolicyResponseType resp = util.checkAssertionAttributeStatement(assertion); assertPermit(resp); }
@Test public void testNoOrgId() { AssertionType assertion = getFullAssertion(); assertion.getUserInfo().getOrg().setHomeCommunityId(null); PolicyEngineUtil util = new PolicyEngineUtil(); CheckPolicyResponseType resp = util.checkAssertionAttributeStatement(assertion); assertDeny(resp); }
@Test public void testMissingMultiple() { AssertionType assertion = getFullAssertion(); assertion.getPurposeOfDisclosureCoded().setCodeSystem(null); assertion.getUserInfo().getPersonName().setSecondNameOrInitials(null); assertion.getHomeCommunity().setHomeCommunityId(null); PolicyEngineUtil util = new PolicyEngineUtil(); CheckPolicyResponseType resp = util.checkAssertionAttributeStatement(assertion); assertDeny(resp); }