Source:
<code>public void testGerritEventManualEvent() { AbstractProject project = PowerMockito.mock(AbstractProject.class); when(project.getFullName()).thenReturn("MockedProject"); when(project.isBuildable()).thenReturn(true); mockConfig(project); PowerMockito.mockStatic(ToGerritRunListener.class); ToGerritRunListener listener = PowerMockito.mock(ToGerritRunListener.class); PowerMockito.when(ToGerritRunListener.getInstance()).thenReturn(listener); GerritProject gP = mock(GerritProject.class); doReturn(true).when(gP).isInteresting(any(String.class), any(String.class), any(String.class)); when(gP.getFilePaths()).thenReturn(null); GerritTrigger trigger = Setup.createDefaultTrigger(project, new Setup.ScheduleProxy() { @Override public boolean schedule(Job theJob, int quitePeriod, GerritCause cause, BadgeAction badgeAction, ParametersAction parameters) { Assert.assertEquals(0, quitePeriod); Assert.assertTrue(cause instanceof GerritUserCause); Assert.assertTrue(badgeAction instanceof BadgeAction); Assert.assertTrue(parameters instanceof ParametersAction); return false; } }); Setup.setTrigger(trigger, project); trigger.setGerritProjects(Collections.nCopies(1, gP)); trigger.setEscapeQuotes(false); trigger.setSilentMode(false); Whitebox.setInternalState(trigger, "job", project); ManualPatchsetCreated event = Setup.createManualPatchsetCreated(); <START> <END> trigger.createListener().gerritEvent(event); verify(listener).onTriggered(same(project), same(event)); }</code><technical_language>longer verifying schedule2 method is called, proxy fail if scheduled bad parameters, pass test if scheduled all</technical_language>

Target:
public void testGerritEventManualEvent() { AbstractProject project = PowerMockito.mock(AbstractProject.class); when(project.getFullName()).thenReturn("MockedProject"); when(project.isBuildable()).thenReturn(true); mockConfig(project); PowerMockito.mockStatic(ToGerritRunListener.class); ToGerritRunListener listener = PowerMockito.mock(ToGerritRunListener.class); PowerMockito.when(ToGerritRunListener.getInstance()).thenReturn(listener); GerritProject gP = mock(GerritProject.class); doReturn(true).when(gP).isInteresting(any(String.class), any(String.class), any(String.class)); when(gP.getFilePaths()).thenReturn(null); Setup.ScheduleProxy scheduleTestProxy = new Setup.ScheduleProxy() { @Override public boolean schedule(Job theJob, int quitePeriod, GerritCause cause, BadgeAction badgeAction, ParametersAction parameters) { Assert.assertEquals(0, quitePeriod); Assert.assertTrue(cause instanceof GerritUserCause); Assert.assertTrue(badgeAction instanceof BadgeAction); Assert.assertTrue(parameters instanceof ParametersAction); return false; } }; GerritTrigger trigger = Setup.createDefaultTrigger(project, scheduleTestProxy); Setup.setTrigger(trigger, project); trigger.setGerritProjects(Collections.nCopies(1, gP)); trigger.setEscapeQuotes(false); trigger.setSilentMode(false); Whitebox.setInternalState(trigger, "job", project); ManualPatchsetCreated event = Setup.createManualPatchsetCreated(); trigger.createListener().gerritEvent(event); verify(listener).onTriggered(same(project), same(event)); assertTrue(scheduleTestProxy.wasScheduled()); }