From aecf8c464b147627c71e2d5bbf2a5b5aefba3e37 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 27 Aug 2010 13:17:31 +0000 Subject: [PATCH] ALF-4505 - Change how replication definition "sort by last run" orders jobs that haven't ever been run git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22044 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../replication/ReplicationModelBuilder.java | 6 +++-- .../replication/ReplicationRestApiTest.java | 22 +++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/source/java/org/alfresco/repo/web/scripts/replication/ReplicationModelBuilder.java b/source/java/org/alfresco/repo/web/scripts/replication/ReplicationModelBuilder.java index 3c33f0b8b0..25d392db4e 100644 --- a/source/java/org/alfresco/repo/web/scripts/replication/ReplicationModelBuilder.java +++ b/source/java/org/alfresco/repo/web/scripts/replication/ReplicationModelBuilder.java @@ -112,6 +112,8 @@ public class ReplicationModelBuilder } /** * Sorts simple definitions by their last run time. + * Things that have never been run go to the bottom of the list, + * so we see most recently run, least recently run, never run. */ public static class SimpleSorterByLastRun implements Comparator> { /** Works on ISO8601 formatted date strings */ @@ -122,10 +124,10 @@ public class ReplicationModelBuilder return 0; } if(dateA != null && dateB == null) { - return 1; + return -1; } if(dateA == null && dateB != null) { - return -1; + return 1; } // We want more recent dates first return 0-dateA.compareTo(dateB); diff --git a/source/java/org/alfresco/repo/web/scripts/replication/ReplicationRestApiTest.java b/source/java/org/alfresco/repo/web/scripts/replication/ReplicationRestApiTest.java index 109d42d90e..3f254f72ef 100644 --- a/source/java/org/alfresco/repo/web/scripts/replication/ReplicationRestApiTest.java +++ b/source/java/org/alfresco/repo/web/scripts/replication/ReplicationRestApiTest.java @@ -311,17 +311,8 @@ public class ReplicationRestApiTest extends BaseWebScriptTest assertNotNull(results); assertEquals(3, results.length()); - // Never run first - jsonRD = (JSONObject)results.get(0); - assertNotNull(jsonRD); - assertEquals("AnotherTest", jsonRD.get("name")); - assertEquals("New", jsonRD.get("status")); - assertEquals(true, jsonRD.get("enabled")); - assertEquals(JSONObject.NULL, jsonRD.get("startedAt")); - assertEquals("/api/replication-definition/AnotherTest", jsonRD.get("details")); - // Ran most recently - jsonRD = (JSONObject)results.get(1); + jsonRD = (JSONObject)results.get(0); assertNotNull(jsonRD); assertEquals("Test2", jsonRD.get("name")); assertEquals("Completed", jsonRD.get("status")); @@ -330,7 +321,7 @@ public class ReplicationRestApiTest extends BaseWebScriptTest assertEquals("/api/replication-definition/Test2", jsonRD.get("details")); // Ran least recently - jsonRD = (JSONObject)results.get(2); + jsonRD = (JSONObject)results.get(1); assertNotNull(jsonRD); assertEquals("Test1", jsonRD.get("name")); assertEquals("Running", jsonRD.get("status")); @@ -338,6 +329,15 @@ public class ReplicationRestApiTest extends BaseWebScriptTest assertEquals(startedAt, jsonRD.getJSONObject("startedAt").get("iso8601")); assertEquals("/api/replication-definition/Test1", jsonRD.get("details")); + // Never run last + jsonRD = (JSONObject)results.get(2); + assertNotNull(jsonRD); + assertEquals("AnotherTest", jsonRD.get("name")); + assertEquals("New", jsonRD.get("status")); + assertEquals(true, jsonRD.get("enabled")); + assertEquals(JSONObject.NULL, jsonRD.get("startedAt")); + assertEquals("/api/replication-definition/AnotherTest", jsonRD.get("details")); + // Cancel one of these rd = replicationService.loadReplicationDefinition("AnotherTest");