project.getBuildersList().add(new SleepBuilder(2000));
server.waitForCommand(GERRIT_STREAM_EVENTS, 2000);
ManualPatchsetCreated firstEvent = Setup.createManualPatchsetCreated();
AtomicReference<AbstractBuild> firstBuildRef = TestUtils.getFutureBuildToStart(firstEvent);
gerritServer.triggerEvent(firstEvent);
AbstractBuild firstBuild = TestUtils.waitForBuildToStart(firstBuildRef);
PatchsetCreated secondEvent = Setup.createPatchsetCreated();
if (null != secondEvent.getPatchSet()) {
secondEvent.getPatchSet().setNumber("2");
}
gerritServer.triggerEvent(secondEvent);
TestUtils.waitForBuilds(project, 2);
assertEquals(2, project.getLastCompletedBuild().getNumber());
assertSame(Result.ABORTED, firstBuild.getResult());
assertSame(Result.ABORTED, project.getFirstBuild().getResult());
assertSame(Result.SUCCESS, project.getLastBuild().getResult());
}