@Test public void testHtmlProcessorPolicySetNotEmpty() { PolicySetType mockPolicySetType = Mockito.mock(PolicySetType.class); TargetType mockTargetType = Mockito.mock(TargetType.class); List<AnyOfType> anyOfList = new ArrayList<AnyOfType>(); anyOfList.add(new AnyOfType()); when(mockPolicySetType.getTarget()).thenReturn(mockTargetType); when(mockTargetType.getAnyOf()).thenReturn(anyOfList); when(mockPolicySetType.getPolicySetOrPolicyOrPolicySetIdReference()).thenReturn(null); processor = new HtmlProcessor(temp, mockPolicySetType); processor.policySet(mockPolicySetType, ""); verify(mockPolicySetType, atLeast(1)).getTarget(); verify(mockTargetType, atLeast(1)).getAnyOf(); verify(mockPolicySetType, atLeast(1)).getPolicySetOrPolicyOrPolicySetIdReference(); }
public void policySet(PolicySetType policySet, String htmlListElement) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId()); } String combiningAlgorithm = "-"; String id = "-"; String version = "-"; if (policySet.getPolicyCombiningAlgId() != null) { combiningAlgorithm = extractLastIdentifier(policySet.getPolicyCombiningAlgId(), ":"); } if (policySet.getPolicySetId() != null) { id = extractLastIdentifier(policySet.getPolicySetId(), ":"); } if (policySet.getVersion() != null) { version = policySet.getVersion(); } htmlOut.println("<" + htmlListElement + "><b>Policy Set ID</b>: <i>" + id + "</i> (v" + version + ") " + "</" + htmlListElement + ">"); if (policySet.getTarget() == null || policySet.getTarget().getAnyOf() == null || policySet.getTarget().getAnyOf().isEmpty()) { htmlOut.println("<p>This policy set applies to all requests.</p>"); } else { htmlOut.print("<p>"); htmlOut.print("This policy set applies to requests with attributes "); target(policySet.getTarget().getAnyOf()); htmlOut.println(".</p>"); } if (policySet.getPolicySetOrPolicyOrPolicySetIdReference() != null && !policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) { String algoDesc = combiningAlgo2human.get(combiningAlgorithm); if (algoDesc != null) { algoDesc = algoDesc.replace("$placeholder$", "policy") + " (" + "<i>" + combiningAlgorithm + "</i>)"; } else { algoDesc = combiningAlgorithm; } htmlOut.println("<p>The result is " + algoDesc + ": </p>"); } }
HtmlProcessor extends SimpleCallback { public void policySet(PolicySetType policySet, String htmlListElement) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId()); } String combiningAlgorithm = "-"; String id = "-"; String version = "-"; if (policySet.getPolicyCombiningAlgId() != null) { combiningAlgorithm = extractLastIdentifier(policySet.getPolicyCombiningAlgId(), ":"); } if (policySet.getPolicySetId() != null) { id = extractLastIdentifier(policySet.getPolicySetId(), ":"); } if (policySet.getVersion() != null) { version = policySet.getVersion(); } htmlOut.println("<" + htmlListElement + "><b>Policy Set ID</b>: <i>" + id + "</i> (v" + version + ") " + "</" + htmlListElement + ">"); if (policySet.getTarget() == null || policySet.getTarget().getAnyOf() == null || policySet.getTarget().getAnyOf().isEmpty()) { htmlOut.println("<p>This policy set applies to all requests.</p>"); } else { htmlOut.print("<p>"); htmlOut.print("This policy set applies to requests with attributes "); target(policySet.getTarget().getAnyOf()); htmlOut.println(".</p>"); } if (policySet.getPolicySetOrPolicyOrPolicySetIdReference() != null && !policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) { String algoDesc = combiningAlgo2human.get(combiningAlgorithm); if (algoDesc != null) { algoDesc = algoDesc.replace("$placeholder$", "policy") + " (" + "<i>" + combiningAlgorithm + "</i>)"; } else { algoDesc = combiningAlgorithm; } htmlOut.println("<p>The result is " + algoDesc + ": </p>"); } } }
HtmlProcessor extends SimpleCallback { public void policySet(PolicySetType policySet, String htmlListElement) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId()); } String combiningAlgorithm = "-"; String id = "-"; String version = "-"; if (policySet.getPolicyCombiningAlgId() != null) { combiningAlgorithm = extractLastIdentifier(policySet.getPolicyCombiningAlgId(), ":"); } if (policySet.getPolicySetId() != null) { id = extractLastIdentifier(policySet.getPolicySetId(), ":"); } if (policySet.getVersion() != null) { version = policySet.getVersion(); } htmlOut.println("<" + htmlListElement + "><b>Policy Set ID</b>: <i>" + id + "</i> (v" + version + ") " + "</" + htmlListElement + ">"); if (policySet.getTarget() == null || policySet.getTarget().getAnyOf() == null || policySet.getTarget().getAnyOf().isEmpty()) { htmlOut.println("<p>This policy set applies to all requests.</p>"); } else { htmlOut.print("<p>"); htmlOut.print("This policy set applies to requests with attributes "); target(policySet.getTarget().getAnyOf()); htmlOut.println(".</p>"); } if (policySet.getPolicySetOrPolicyOrPolicySetIdReference() != null && !policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) { String algoDesc = combiningAlgo2human.get(combiningAlgorithm); if (algoDesc != null) { algoDesc = algoDesc.replace("$placeholder$", "policy") + " (" + "<i>" + combiningAlgorithm + "</i>)"; } else { algoDesc = combiningAlgorithm; } htmlOut.println("<p>The result is " + algoDesc + ": </p>"); } } HtmlProcessor(File policyFile, Object policyObject); }
HtmlProcessor extends SimpleCallback { public void policySet(PolicySetType policySet, String htmlListElement) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId()); } String combiningAlgorithm = "-"; String id = "-"; String version = "-"; if (policySet.getPolicyCombiningAlgId() != null) { combiningAlgorithm = extractLastIdentifier(policySet.getPolicyCombiningAlgId(), ":"); } if (policySet.getPolicySetId() != null) { id = extractLastIdentifier(policySet.getPolicySetId(), ":"); } if (policySet.getVersion() != null) { version = policySet.getVersion(); } htmlOut.println("<" + htmlListElement + "><b>Policy Set ID</b>: <i>" + id + "</i> (v" + version + ") " + "</" + htmlListElement + ">"); if (policySet.getTarget() == null || policySet.getTarget().getAnyOf() == null || policySet.getTarget().getAnyOf().isEmpty()) { htmlOut.println("<p>This policy set applies to all requests.</p>"); } else { htmlOut.print("<p>"); htmlOut.print("This policy set applies to requests with attributes "); target(policySet.getTarget().getAnyOf()); htmlOut.println(".</p>"); } if (policySet.getPolicySetOrPolicyOrPolicySetIdReference() != null && !policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) { String algoDesc = combiningAlgo2human.get(combiningAlgorithm); if (algoDesc != null) { algoDesc = algoDesc.replace("$placeholder$", "policy") + " (" + "<i>" + combiningAlgorithm + "</i>)"; } else { algoDesc = combiningAlgorithm; } htmlOut.println("<p>The result is " + algoDesc + ": </p>"); } } HtmlProcessor(File policyFile, Object policyObject); Map<String, AttributeIdentifiers> getAttributeIdentifiersMap(); @Override void onFinishScan(Object root); @Override CallbackResult onPreVisitPolicySet(PolicySetType parent, PolicySetType policySet); @Override CallbackResult onPostVisitPolicySet(PolicySetType parent, PolicySetType policySet); void policySet(PolicySetType policySet, String htmlListElement); @Override CallbackResult onPreVisitPolicy(PolicySetType parent, PolicyType policy); @Override CallbackResult onPostVisitPolicy(PolicySetType parent, PolicyType policy); void policy(PolicyType policy); @Override CallbackResult onPreVisitRule(PolicyType parent, RuleType rule); @Override CallbackResult onPostVisitRule(PolicyType parent, RuleType rule); void rule(RuleType rule); void target(List<AnyOfType> anyOfList); String html(); }
HtmlProcessor extends SimpleCallback { public void policySet(PolicySetType policySet, String htmlListElement) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId()); } String combiningAlgorithm = "-"; String id = "-"; String version = "-"; if (policySet.getPolicyCombiningAlgId() != null) { combiningAlgorithm = extractLastIdentifier(policySet.getPolicyCombiningAlgId(), ":"); } if (policySet.getPolicySetId() != null) { id = extractLastIdentifier(policySet.getPolicySetId(), ":"); } if (policySet.getVersion() != null) { version = policySet.getVersion(); } htmlOut.println("<" + htmlListElement + "><b>Policy Set ID</b>: <i>" + id + "</i> (v" + version + ") " + "</" + htmlListElement + ">"); if (policySet.getTarget() == null || policySet.getTarget().getAnyOf() == null || policySet.getTarget().getAnyOf().isEmpty()) { htmlOut.println("<p>This policy set applies to all requests.</p>"); } else { htmlOut.print("<p>"); htmlOut.print("This policy set applies to requests with attributes "); target(policySet.getTarget().getAnyOf()); htmlOut.println(".</p>"); } if (policySet.getPolicySetOrPolicyOrPolicySetIdReference() != null && !policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) { String algoDesc = combiningAlgo2human.get(combiningAlgorithm); if (algoDesc != null) { algoDesc = algoDesc.replace("$placeholder$", "policy") + " (" + "<i>" + combiningAlgorithm + "</i>)"; } else { algoDesc = combiningAlgorithm; } htmlOut.println("<p>The result is " + algoDesc + ": </p>"); } } HtmlProcessor(File policyFile, Object policyObject); Map<String, AttributeIdentifiers> getAttributeIdentifiersMap(); @Override void onFinishScan(Object root); @Override CallbackResult onPreVisitPolicySet(PolicySetType parent, PolicySetType policySet); @Override CallbackResult onPostVisitPolicySet(PolicySetType parent, PolicySetType policySet); void policySet(PolicySetType policySet, String htmlListElement); @Override CallbackResult onPreVisitPolicy(PolicySetType parent, PolicyType policy); @Override CallbackResult onPostVisitPolicy(PolicySetType parent, PolicyType policy); void policy(PolicyType policy); @Override CallbackResult onPreVisitRule(PolicyType parent, RuleType rule); @Override CallbackResult onPostVisitRule(PolicyType parent, RuleType rule); void rule(RuleType rule); void target(List<AnyOfType> anyOfList); String html();  }