Source:
public void testCheckThatAllOnlyQueuedBuildIsResolvedAsQueued() throws Exception { FreeStyleProject project1 = jenkins.createFreeStyleProject("project1"); jenkins.createFreeStyleProject("project2"); project1.getPublishersList().add(new BuildPipelineTrigger("project2", null)); jenkins.getInstance().rebuildDependencyGraph(); Pipeline pipeline = Pipeline.extractPipeline("name", project1); jenkins.buildAndAssertSuccess(project1); jenkins.buildAndAssertSuccess(project1); jenkins.waitUntilNoActivity(); List<Pipeline> pipelines = pipeline.createPipelineLatest(2, jenkins.getInstance(), false); assertEquals(2, pipelines.size()); assertEquals(StatusType.IDLE, pipelines.get(0).getStages().get(1).getTasks().get(0).getStatus().getType()); assertEquals(StatusType.IDLE, pipelines.get(1).getStages().get(1).getTasks().get(0).getStatus().getType()); BuildPipelineView view = new BuildPipelineView("", "", new DownstreamProjectGridBuilder("project1"), "0", false, ""); project1.setQuietPeriod(3); view.triggerManualBuild(1, "project2", "project1"); pipelines = pipeline.createPipelineLatest(2, jenkins.getInstance(), false); assertEquals(2, pipelines.size()); assertEquals(StatusType.IDLE, pipelines.get(0).getStages().get(1).getTasks().get(0).getStatus().getType()); assertEquals(StatusType.QUEUED, pipelines.get(1).getStages().get(1).getTasks().get(0).getStatus().getType()); jenkins.waitUntilNoActivity(); pipelines = pipeline.createPipelineLatest(2, jenkins.getInstance(), false); assertEquals(2, pipelines.size()); assertEquals(StatusType.IDLE, pipelines.get(0).getStages().get(1).getTasks().get(0).getStatus().getType()); assertEquals(StatusType.SUCCESS, pipelines.get(1).getStages().get(1).getTasks().get(0).getStatus().getType()); }

Target:
public void testCheckThatAllOnlyQueuedBuildIsResolvedAsQueued() throws Exception { FreeStyleProject project1 = jenkins.createFreeStyleProject("project1"); jenkins.createFreeStyleProject("project2"); project1.getPublishersList().add(new BuildPipelineTrigger("project2", null)); jenkins.getInstance().rebuildDependencyGraph(); Pipeline pipeline = Pipeline.extractPipeline("name", project1); jenkins.buildAndAssertSuccess(project1); jenkins.buildAndAssertSuccess(project1); jenkins.waitUntilNoActivity(); List<Pipeline> pipelines = pipeline.createPipelineLatest(2, jenkins.getInstance(), pagingEnabledFalse); assertEquals(2, pipelines.size()); assertEquals(StatusType.IDLE, pipelines.get(0).getStages().get(1).getTasks().get(0).getStatus().getType()); assertEquals(StatusType.IDLE, pipelines.get(1).getStages().get(1).getTasks().get(0).getStatus().getType()); BuildPipelineView view = new BuildPipelineView("", "", new DownstreamProjectGridBuilder("project1"), "0", false, ""); project1.setQuietPeriod(3); view.triggerManualBuild(1, "project2", "project1"); pipelines = pipeline.createPipelineLatest(2, jenkins.getInstance(), pagingEnabledFalse); assertEquals(2, pipelines.size()); assertEquals(StatusType.IDLE, pipelines.get(0).getStages().get(1).getTasks().get(0).getStatus().getType()); assertEquals(StatusType.QUEUED, pipelines.get(1).getStages().get(1).getTasks().get(0).getStatus().getType()); jenkins.waitUntilNoActivity(); pipelines = pipeline.createPipelineLatest(2, jenkins.getInstance(), pagingEnabledFalse); assertEquals(2, pipelines.size()); assertEquals(StatusType.IDLE, pipelines.get(0).getStages().get(1).getTasks().get(0).getStatus().getType()); assertEquals(StatusType.SUCCESS, pipelines.get(1).getStages().get(1).getTasks().get(0).getStatus().getType()); }