HtmlProcessor extends SimpleCallback { @Override public CallbackResult onPreVisitPolicySet(PolicySetType parent, PolicySetType policySet) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId() + " Version: " + policySet.getVersion()); } if (parent != null && LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId() + "Parent PolicySet: " + parent.getPolicySetId() + " Version: " + parent.getVersion()); } String description = policySet.getDescription(); if (description != null && LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId() + " Description: " + policySet.getDescription()); } if (parent == null) { policySet(policySet, "dl"); } else { policySet(policySet, "li"); } if (!policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) { htmlOut.println("<ol>"); } return super.onPreVisitPolicySet(parent, policySet); } 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();  }
@Test public void testHtmlProcessorOnPreVisitPolicySet() { PolicySetType mockPolicySetType = Mockito.mock(PolicySetType.class); PolicySetType mockPolicyParent = Mockito.mock(PolicySetType.class); processor = new HtmlProcessor(temp, mockPolicySetType); when(mockPolicySetType.getPolicySetOrPolicyOrPolicySetIdReference()).thenReturn(Collections.emptyList()); when(mockPolicySetType.getDescription()).thenReturn(null); CallbackResult preResult = processor.onPreVisitPolicySet(mockPolicyParent, mockPolicySetType); assertEquals("CONTINUE", preResult.name()); verify(mockPolicySetType, atLeast(1)).getPolicySetOrPolicyOrPolicySetIdReference(); verify(mockPolicySetType, atLeast(1)).getDescription(); }
@Test public void testHtmlProcessorOnPreVisitPolicySetNullParent() { PolicySetType mockPolicySetType = Mockito.mock(PolicySetType.class); PolicySetType mockPolicyParent = null; JAXBElement<?> mockElement = Mockito.mock(JAXBElement.class); List<JAXBElement<?>> testList = new ArrayList<JAXBElement<?>>(); testList.add(mockElement); processor = new HtmlProcessor(temp, mockPolicySetType); when(mockPolicySetType.getPolicySetOrPolicyOrPolicySetIdReference()).thenReturn(testList); when(mockPolicySetType.getDescription()).thenReturn(""); CallbackResult preResult = processor.onPreVisitPolicySet(mockPolicyParent, mockPolicySetType); assertEquals("CONTINUE", preResult.name()); verify(mockPolicySetType, atLeast(1)).getPolicySetOrPolicyOrPolicySetIdReference(); verify(mockPolicySetType, atLeast(1)).getDescription(); }