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
This commit is contained in:
Nick Burch
2010-08-27 13:17:31 +00:00
parent 753c0d9ac1
commit aecf8c464b
2 changed files with 15 additions and 13 deletions

View File

@@ -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<Map<String,Object>> {
/** 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);

View File

@@ -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");