mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
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:
@@ -112,6 +112,8 @@ public class ReplicationModelBuilder
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sorts simple definitions by their last run time.
|
* 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>> {
|
public static class SimpleSorterByLastRun implements Comparator<Map<String,Object>> {
|
||||||
/** Works on ISO8601 formatted date strings */
|
/** Works on ISO8601 formatted date strings */
|
||||||
@@ -122,10 +124,10 @@ public class ReplicationModelBuilder
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(dateA != null && dateB == null) {
|
if(dateA != null && dateB == null) {
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(dateA == null && dateB != null) {
|
if(dateA == null && dateB != null) {
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
// We want more recent dates first
|
// We want more recent dates first
|
||||||
return 0-dateA.compareTo(dateB);
|
return 0-dateA.compareTo(dateB);
|
||||||
|
@@ -311,17 +311,8 @@ public class ReplicationRestApiTest extends BaseWebScriptTest
|
|||||||
assertNotNull(results);
|
assertNotNull(results);
|
||||||
assertEquals(3, results.length());
|
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
|
// Ran most recently
|
||||||
jsonRD = (JSONObject)results.get(1);
|
jsonRD = (JSONObject)results.get(0);
|
||||||
assertNotNull(jsonRD);
|
assertNotNull(jsonRD);
|
||||||
assertEquals("Test2", jsonRD.get("name"));
|
assertEquals("Test2", jsonRD.get("name"));
|
||||||
assertEquals("Completed", jsonRD.get("status"));
|
assertEquals("Completed", jsonRD.get("status"));
|
||||||
@@ -330,7 +321,7 @@ public class ReplicationRestApiTest extends BaseWebScriptTest
|
|||||||
assertEquals("/api/replication-definition/Test2", jsonRD.get("details"));
|
assertEquals("/api/replication-definition/Test2", jsonRD.get("details"));
|
||||||
|
|
||||||
// Ran least recently
|
// Ran least recently
|
||||||
jsonRD = (JSONObject)results.get(2);
|
jsonRD = (JSONObject)results.get(1);
|
||||||
assertNotNull(jsonRD);
|
assertNotNull(jsonRD);
|
||||||
assertEquals("Test1", jsonRD.get("name"));
|
assertEquals("Test1", jsonRD.get("name"));
|
||||||
assertEquals("Running", jsonRD.get("status"));
|
assertEquals("Running", jsonRD.get("status"));
|
||||||
@@ -338,6 +329,15 @@ public class ReplicationRestApiTest extends BaseWebScriptTest
|
|||||||
assertEquals(startedAt, jsonRD.getJSONObject("startedAt").get("iso8601"));
|
assertEquals(startedAt, jsonRD.getJSONObject("startedAt").get("iso8601"));
|
||||||
assertEquals("/api/replication-definition/Test1", jsonRD.get("details"));
|
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
|
// Cancel one of these
|
||||||
rd = replicationService.loadReplicationDefinition("AnotherTest");
|
rd = replicationService.loadReplicationDefinition("AnotherTest");
|
||||||
|
Reference in New Issue
Block a user