Source:
<code>public void testProgressBar() { EventBus<Event> events = new EventBus<>(); <START> List<Object[]> testContents = Arrays.asList( <END> new Object[]{"Progress bar testing generic String message"}, new Object[]{"Progress bar testing class message", ProgressBarTest.class}, new Object[]{ProgressBarTest.class, "Progress bar testing class message"}, new Object[]{ProgressBarTest.class}, new Object[]{"Progress bar testing mod message", TestMod.class}, new Object[]{TestMod.class, "Progress bar testing mod message"}, new Object[]{TestMod.class}, new Object[]{"Progress bar testing null message", null}, new Object[]{null, "Progress bar testing class message"}, new Object[]{(String) null}, new Object[]{(Class) null}, new Object[]{ProgressBarTest.class, null}, new Object[]{null, ProgressBarTest.class}); List<String> testResults = new LinkedList<>(); events.on(TestProgressBarEvent.class).bind(evt -> testResults.add(evt.message)); ProgressBar progressBar = new AbstractProgressBar() { @Override protected void stepImpl(String message) { events.publish(new TestProgressBarEvent(message)); } }; for (Object[] testArg : testContents) { step(progressBar, testArg); } progressBar.finish(); List<String> expectedResults = testContents.stream().map(ProgressBarTest::convert).collect(Collectors.toList()); assertThat(testResults.size()).isEqualTo(testContents.size()); assertThat(testResults.size()).isEqualTo(expectedResults.size()); for (int i = 0; i < testContents.size(); i++) assertThat(testResults.get(i)).isEqualTo(expectedResults.get(i)); }</code><technical_language>This uglier calling methods directly</technical_language>

Target:
public void testProgressBar() { List<String> testResults = new LinkedList<>(); finishedCounter = 0; ProgressBar progressBar = new AbstractProgressBar() { @Override protected void stepImpl(String message) { testResults.add(message); } @Override protected void finishImpl() { finishedCounter++; } }; progressBar.step("Progress bar testing generic String message"); progressBar.step("Progress bar testing class message", ProgressBarTest.class); progressBar.step(ProgressBarTest.class, "Progress bar testing class message"); progressBar.step(ProgressBarTest.class); progressBar.step("Progress bar testing mod message", TestMod.class); progressBar.step(TestMod.class, "Progress bar testing mod message"); progressBar.step(TestMod.class); progressBar.step("Progress bar testing null message", null); progressBar.step(null, "Progress bar testing null message"); progressBar.step((String)null); progressBar.step((Class)null); progressBar.step(ProgressBarTest.class, null); progressBar.step(null, ProgressBarTest.class); progressBar.finish(); progressBar.finish(); assertThat(testResults).containsExactly(new String[] { "Progress bar testing generic String message", "Progress bar testing class message: ProgressBarTest", "ProgressBarTest: Progress bar testing class message", "ProgressBarTest", "Progress bar testing mod message: Test Mod", "Test Mod: Progress bar testing mod message", "Test Mod", "Progress bar testing null message: null", "null: Progress bar testing null message", null, null, "ProgressBarTest", "ProgressBarTest" }); assertThat(progressBar.isFinished()).isTrue(); assertThat(finishedCounter).isEqualTo(1); }