EventLog implements EventLogInterface { public void addNodeOnlyEvent(NodeEvent e, java.util.logging.Level level) { log.log(level, "Added node only event: " + e.toString()); if (metricUpdater != null) { metricUpdater.recordNewNodeEvent(); } LinkedList<NodeEvent> nodeList = nodeLog.get(e.getNode().getNode()); if (nodeList == null) { nodeList = new LinkedList<>(); nodeLog.put(e.getNode().getNode(), nodeList); } nodeList.add(e); if (nodeList.size() > maxNodeSize) { nodeList.remove(0); } } EventLog(Timer timer, MetricUpdater metricUpdater); void setMaxSize(int size, int nodesize); long getRecentTimePeriod(); void add(Event e); void add(Event e, boolean logInfo); void addNodeOnlyEvent(NodeEvent e, java.util.logging.Level level); int getNodeEventsSince(Node n, long time); List<NodeEvent> getNodeEvents(Node n); void writeHtmlState(StringBuilder sb, Node node); static Logger log; }
@Test public void testMetric() { initialize(metricUpdater); eventLog.addNodeOnlyEvent(nodeEvent, Level.INFO); verify(metricUpdater).recordNewNodeEvent(); verifyNoMoreInteractions(metricUpdater); }
@Test public void testNullMetricReporter() { initialize(null); eventLog.addNodeOnlyEvent(nodeEvent, Level.INFO); verifyNoMoreInteractions(metricUpdater); }