### Question:
RunEventNormalizer implements RunListener { @Override public void onTestFound(TestId testId, String name) { if (hasNotBeenFoundBefore(testId)) { checkParentWasFoundFirst(testId); rememberFoundTest(testId, name); listener.onTestFound(testFile, testId, name); } else { checkNameIsSameAsBefore(testId, name); } } RunEventNormalizer(SuiteListener listener, TestFile testFile); @Override String toString(); @Override void onTestFound(TestId testId, String name); @Override void onInternalError(String message, Throwable cause); @Override void onRunStarted(RunId runId); @Override void onTestStarted(RunId runId, TestId testId); @Override void onPrintedOut(RunId runId, String text); @Override void onPrintedErr(RunId runId, String text); @Override void onFailure(RunId runId, TestId testId, Throwable cause); @Override void onTestFinished(RunId runId, TestId testId); @Override void onRunFinished(RunId runId);  }### Answer:
@Test public void removes_duplicate_onTestFound_events() { normalizer.onTestFound(TestId.ROOT, "root"); normalizer.onTestFound(TestId.ROOT, "root"); verify(target, times(1)).onTestFound(testFile, TestId.ROOT, "root"); verifyNoMoreInteractions(target); }
@Test public void tests_must_be_found_always_with_the_same_name() { normalizer.onTestFound(TestId.ROOT, "first name"); thrown.expect(IllegalArgumentException.class); thrown.expectMessage(INFORMATION_ABOUT_THE_CURRENT_CONTEXT); thrown.expectMessage("test TestId() was already found with another name: first name"); normalizer.onTestFound(TestId.ROOT, "second name"); }
@Test public void parents_must_be_found_before_their_children() { thrown.expect(IllegalStateException.class); thrown.expectMessage(INFORMATION_ABOUT_THE_CURRENT_CONTEXT); thrown.expectMessage("parent of TestId(0) must be found first"); normalizer.onTestFound(TestId.of(0), "child"); }
@Test public void forwards_unique_onTestFound_events() { normalizer.onTestFound(TestId.ROOT, "root"); normalizer.onTestFound(TestId.of(1), "testOne"); verify(target).onTestFound(testFile, TestId.ROOT, "root"); verify(target).onTestFound(testFile, TestId.of(1), "testOne"); verifyNoMoreInteractions(target); }