PeriodicReporter implements Reporter { protected void reset() { nodes.set(0); properties.set(0); } protected  PeriodicReporter(final int nodeLogInterval, final int propertyLogInterval); @Override final void reportNode(@NotNull final ReportingNodeState nodeState); @Override final void reportProperty(@NotNull final ReportingNodeState parent, @NotNull final String propertyName);  }
@Test public void callbackEveryTenNodes() { final AssertingPeriodicReporter reporter = new AssertingPeriodicReporter(10, -1); final NodeState counter = ReportingNodeState.wrap(EmptyNodeState.EMPTY_NODE, reporter) .getChildNode("counter"); reporter.reset(); for (int i = 1; i < 40; i++) { counter.getChildNode(Integer.toString(i)); } assertThat(reporter, hasReportedNode(10, "/counter/10")); assertThat(reporter, hasReportedNode(20, "/counter/20")); assertThat(reporter, hasReportedNode(30, "/counter/30")); }
@Test public void callbackEveryTenProperties() { final NodeBuilder builder = EmptyNodeState.EMPTY_NODE.builder(); for (int i = 1; i < 40; i++) { builder.child("counter").setProperty(Integer.toString(i), i); } final AssertingPeriodicReporter reporter = new AssertingPeriodicReporter(-1, 10); final NodeState counter = ReportingNodeState.wrap(builder.getNodeState(), reporter) .getChildNode("counter"); reporter.reset(); for (int i = 1; i < 40; i++) { counter.getProperty(Integer.toString(i)); } assertThat(reporter, hasReportedProperty(10, "/counter/10")); assertThat(reporter, hasReportedProperty(20, "/counter/20")); assertThat(reporter, hasReportedProperty(30, "/counter/30")); }