Skip to content

Commit

Permalink
[JENKINS-27770] Makse sorter adhere to Java 7 compare contract.
Browse files Browse the repository at this point in the history
  • Loading branch information
emsa23 committed Apr 14, 2015
1 parent 107e02f commit 52b8024
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Expand Up @@ -88,7 +88,15 @@ public int compare(BuildableItem o1, BuildableItem o2) {
if (o1weight < o2weight) {
return -1;
}
return (int) (o1.getInQueueSince() - o2.getInQueueSince());
// Same weights sort on time in queue
if(o1.getInQueueSince() > o2.getInQueueSince()) {
return 1;
}
if(o1.getInQueueSince() < o2.getInQueueSince()) {
return -1;
}
// Having same time-stamp is not likely - but maybe it can happen ...
return o1.getDisplayName().compareTo(o2.getDisplayName());
}
});
//
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/jenkins/advancedqueue/test/BasicTest.java
Expand Up @@ -25,6 +25,14 @@ public void simple_with_no_configuration() throws Exception {
TestRunListener.assertStartedItems();
}

@Test
public void simple_two_jobs_with_no_configuration() throws Exception {
TestRunListener.init(new ExpectedItem("Job 0", 3), new ExpectedItem("Job 1", 3));
jobHelper.scheduleProjects(new UserIdCause(), new UserIdCause());
j.waitUntilNoActivity();
TestRunListener.assertStartedItems();
}

@Test
@LocalData
public void simple_two_jobs_with_basic_configuration() throws Exception {
Expand Down

0 comments on commit 52b8024

Please sign in to comment.