@Test public void testGetQueueItems() throws IOException, Exception{ ListView view1 = listView("view1"); view1.filterQueue = true; ListView view2 = listView("view2"); view2.filterQueue = true; FreeStyleProject inView1 = j.createFreeStyleProject("in-view1"); inView1.setAssignedLabel(j.jenkins.getLabelAtom("without-any-slave")); view1.add(inView1); MatrixProject inView2 = j.createMatrixProject("in-view2"); inView2.setAssignedLabel(j.jenkins.getLabelAtom("without-any-slave")); view2.add(inView2); FreeStyleProject notInView = j.createFreeStyleProject("not-in-view"); notInView.setAssignedLabel(j.jenkins.getLabelAtom("without-any-slave")); FreeStyleProject inBothViews = j.createFreeStyleProject("in-both-views"); inBothViews.setAssignedLabel(j.jenkins.getLabelAtom("without-any-slave")); view1.add(inBothViews); view2.add(inBothViews); Queue.getInstance().schedule(notInView, 0); Queue.getInstance().schedule(inView1, 0); Queue.getInstance().schedule(inView2, 0); Queue.getInstance().schedule(inBothViews, 0); Thread.sleep(1000); assertContainsItems(view1, inView1, inBothViews); assertNotContainsItems(view1, notInView, inView2); assertContainsItems(view2, inView2, inBothViews); assertNotContainsItems(view2, notInView, inView1); }
private void assertNotContainsItems(View view, Task... items) { for (Task job: items) { assertFalse( "Queued items for " + view.getDisplayName() + " should not contain " + job.getDisplayName(), view.getQueueItems().contains(Queue.getInstance().getItem(job)) ); } }