HtmlProcessor extends SimpleCallback { @Override public CallbackResult onPreVisitRule(PolicyType parent, RuleType rule) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Rule: " + rule.getRuleId()); } if (parent != null && LOGGER.isTraceEnabled()) { LOGGER.trace("Parent Policy: " + parent.getPolicyId() + " Version: " + parent.getVersion()); } String description = rule.getDescription(); if (description != null && LOGGER.isTraceEnabled()) { LOGGER.trace("Rule: " + rule.getRuleId() + " Description: " + rule.getDescription()); } rule(rule); return super.onPreVisitRule(parent, rule); } 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 testHtmlProcessorOnPreVisitRule() { PolicySetType mockPolicySetType = Mockito.mock(PolicySetType.class); PolicyType mockPolicyType = null; RuleType mockRuleType = Mockito.mock(RuleType.class); EffectType effectTypePermit = EffectType.PERMIT; TargetType mockTargetType = Mockito.mock(TargetType.class); processor = new HtmlProcessor(temp, mockPolicySetType); List<AnyOfType> anyOfList = new ArrayList<AnyOfType>(); anyOfList.add(new AnyOfType()); when(mockRuleType.getCondition()).thenReturn(null); when(mockRuleType.getDescription()).thenReturn(null); when(mockRuleType.getEffect()).thenReturn(effectTypePermit); when(mockRuleType.getTarget()).thenReturn(mockTargetType); when(mockTargetType.getAnyOf()).thenReturn(anyOfList); CallbackResult callbackResult = processor.onPreVisitRule(mockPolicyType, mockRuleType); assertNotNull(callbackResult); verify(mockRuleType, atLeast(1)).getCondition(); verify(mockRuleType, atLeast(1)).getDescription(); verify(mockRuleType, atLeast(1)).getEffect(); verify(mockRuleType, atLeast(1)).getTarget(); verify(mockRuleType, atLeast(1)).getAdviceExpressions(); verify(mockTargetType, atLeast(1)).getAnyOf(); mockPolicyType = Mockito.mock(PolicyType.class); when(mockRuleType.getDescription()).thenReturn(""); callbackResult = processor.onPreVisitRule(mockPolicyType, mockRuleType); assertNotNull(callbackResult); }