From e00e10aa9dac0011e0b5c17db38349c3b0b641d0 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 26 Mar 2019 15:35:05 +0200 Subject: [PATCH 1/3] call super.checkServerHealth --- .../java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java index aa65f8c967..ed5d917d55 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java @@ -161,6 +161,7 @@ public class BaseRMRestTest extends RestTest @BeforeClass (alwaysRun = true) public void checkServerHealth() throws Exception { + super.checkServerHealth(); // Create RM Site if not exist createRMSiteIfNotExists(); } From 8c88ef28834676d5996f56d248e991cccd916f27 Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 26 Mar 2019 16:19:15 +0200 Subject: [PATCH 2/3] Revert "call super.checkServerHealth" This reverts commit e00e10aa --- .../java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java index ed5d917d55..aa65f8c967 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java @@ -161,7 +161,6 @@ public class BaseRMRestTest extends RestTest @BeforeClass (alwaysRun = true) public void checkServerHealth() throws Exception { - super.checkServerHealth(); // Create RM Site if not exist createRMSiteIfNotExists(); } From aa84113c6d8aaad417dc80b1215996fdc4326147 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 27 Mar 2019 13:19:09 +0200 Subject: [PATCH 3/3] changed formatter used in tests because DateTimeFormatter.ISO_INSTANT outputs 9 nanoseconds and POST request to http://localhost:8080/alfresco/service/api/rma/actions/ExecutionQueue returns 500 --- .../src/main/java/org/alfresco/rest/core/v0/APIUtils.java | 6 ++++++ .../java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/APIUtils.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/APIUtils.java index fb6e3d9802..3d3f362a41 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/APIUtils.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/APIUtils.java @@ -27,6 +27,8 @@ package org.alfresco.rest.core.v0; import java.io.IOException; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; import org.apache.commons.io.IOUtils; import org.apache.http.HttpResponse; @@ -44,6 +46,10 @@ public class APIUtils { /** Logger for this class. */ private static final Logger LOGGER = LoggerFactory.getLogger(APIUtils.class); + /** The ISO instant formatter that formats or parses an instant in UTC, such as '2011-12-03T10:15:305Z' + * similar with {@link DateTimeFormatter#ISO_INSTANT}, but with only 3 nanoseconds*/ + public static final DateTimeFormatter ISO_INSTANT_FORMATTER = + new DateTimeFormatterBuilder().appendInstant(3).toFormatter(); /** Private constructor for helper class. */ private APIUtils() diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java index 6f07fcf3ab..96025d88b3 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java @@ -27,6 +27,7 @@ package org.alfresco.rest.v0; import static org.alfresco.dataprep.AlfrescoHttpClient.MIME_TYPE_JSON; +import static org.alfresco.rest.core.v0.APIUtils.ISO_INSTANT_FORMATTER; import static org.apache.http.HttpStatus.SC_OK; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; @@ -37,7 +38,6 @@ import java.io.IOException; import java.text.MessageFormat; import java.time.Instant; import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.Map; import java.util.Set; @@ -341,7 +341,7 @@ public class RMRolesAndActionsAPI extends BaseAPI requestParams.put("nodeRef", recNodeRef); if (date != null) { - String thisMoment = date.format(DateTimeFormatter.ISO_INSTANT); + String thisMoment = date.format(ISO_INSTANT_FORMATTER); requestParams.put("params", new JSONObject() .put("asOfDate", new JSONObject() .put("iso8601", thisMoment) @@ -368,7 +368,7 @@ public class RMRolesAndActionsAPI extends BaseAPI requestParams.put("name", RM_ACTIONS.COMPLETE_EVENT.getAction()); requestParams.put("nodeRef", recNodeRef); date = (date != null) ? date : Instant.now(); - String formattedDate = DateTimeFormatter.ISO_INSTANT.format(date); + String formattedDate = ISO_INSTANT_FORMATTER.format(date); requestParams.put("params", new JSONObject() .put("eventName", event.getEventName()) .put("eventCompletedBy", user)