HtmlProcessor extends SimpleCallback { @Override public CallbackResult onPreVisitPolicy(PolicySetType parent, PolicyType policy) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policy.getPolicyId() + " Version: " + policy.getVersion()); } if (parent != null && LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policy.getPolicyId() + "Parent PolicySet: " + parent.getPolicySetId() + " Version: " + parent.getVersion()); } String description = policy.getDescription(); if (description != null && LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policy.getPolicyId() + " Description: " + policy.getDescription()); } policy(policy); if (!policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty()) { htmlOut.println("<ol type=\"i\">"); } return super.onPreVisitPolicy(parent, policy); } 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 testHtmlProcessorOnPreVisitPolicy() { PolicySetType mockPolicySetType = Mockito.mock(PolicySetType.class); PolicyType mockPolicyType = Mockito.mock(PolicyType.class); List<Object> testList = new ArrayList<Object>(); processor = new HtmlProcessor(temp, mockPolicySetType); when(mockPolicyType.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition()).thenReturn(testList); when(mockPolicySetType.getDescription()).thenReturn(null); CallbackResult preResult = processor.onPreVisitPolicy(mockPolicySetType, mockPolicyType); assertEquals("CONTINUE", preResult.name()); verify(mockPolicyType, atLeast(1)).getCombinerParametersOrRuleCombinerParametersOrVariableDefinition(); verify(mockPolicyType, atLeast(1)).getDescription(); }
@Test public void testHtmlProcessorOnPreVisitPolicyNullParent() { PolicyType mockPolicyType = Mockito.mock(PolicyType.class); PolicySetType mockPolicyParent = null; List<Object> testList = new ArrayList<Object>(); testList.add(new Object()); processor = new HtmlProcessor(temp, mockPolicyType); when(mockPolicyType.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition()).thenReturn(testList); when(mockPolicyType.getDescription()).thenReturn(""); CallbackResult preResult = processor.onPreVisitPolicy(mockPolicyParent, mockPolicyType); assertEquals("CONTINUE", preResult.name()); verify(mockPolicyType, atLeast(1)).getCombinerParametersOrRuleCombinerParametersOrVariableDefinition(); verify(mockPolicyType, atLeast(1)).getDescription(); }