CoverageAgendaListener extends DefaultAgendaEventListener { @Override public void beforeMatchFired(BeforeMatchFiredEvent beforeMatchFiredEvent) { InternalRule rule = (InternalRule) beforeMatchFiredEvent.getMatch().getRule(); String ruleKey = prettyFullyQualifiedName(rule); ruleExecuted.compute(ruleKey, (r, counter) -> counter == null ? 1 : counter + 1); auditsMessages.add(ruleKey); }  @Override void beforeMatchFired(BeforeMatchFiredEvent beforeMatchFiredEvent); Map<String, Integer> getRuleExecuted(); List<String> getAuditsMessages();  }
@Test public void beforeMatchFired() { CoverageAgendaListener coverageAgendaListener = new CoverageAgendaListener(); assertTrue(coverageAgendaListener.getRuleExecuted().isEmpty()); assertTrue(coverageAgendaListener.getAuditsMessages().isEmpty()); BeforeMatchFiredEvent beforeMatchFiredEvent = createBeforeMatchFiredEventMock(RULE_NAME); coverageAgendaListener.beforeMatchFired(beforeMatchFiredEvent); Map<String, Integer> ruleExecuted = coverageAgendaListener.getRuleExecuted(); assertEquals(1, ruleExecuted.size()); assertEquals((Integer) 1, ruleExecuted.get(RULE_NAME)); List<String> auditMessages = coverageAgendaListener.getAuditsMessages(); assertEquals(1, auditMessages.size()); assertEquals(RULE_NAME, auditMessages.get(0)); }