mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
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
This commit is contained in:
@@ -27,6 +27,8 @@
|
|||||||
package org.alfresco.rest.core.v0;
|
package org.alfresco.rest.core.v0;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.format.DateTimeFormatterBuilder;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
@@ -44,6 +46,10 @@ public class APIUtils
|
|||||||
{
|
{
|
||||||
/** Logger for this class. */
|
/** Logger for this class. */
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(APIUtils.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 constructor for helper class. */
|
||||||
private APIUtils()
|
private APIUtils()
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
package org.alfresco.rest.v0;
|
package org.alfresco.rest.v0;
|
||||||
|
|
||||||
import static org.alfresco.dataprep.AlfrescoHttpClient.MIME_TYPE_JSON;
|
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.apache.http.HttpStatus.SC_OK;
|
||||||
import static org.testng.AssertJUnit.assertEquals;
|
import static org.testng.AssertJUnit.assertEquals;
|
||||||
import static org.testng.AssertJUnit.assertNotNull;
|
import static org.testng.AssertJUnit.assertNotNull;
|
||||||
@@ -37,7 +38,6 @@ import java.io.IOException;
|
|||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -341,7 +341,7 @@ public class RMRolesAndActionsAPI extends BaseAPI
|
|||||||
requestParams.put("nodeRef", recNodeRef);
|
requestParams.put("nodeRef", recNodeRef);
|
||||||
if (date != null)
|
if (date != null)
|
||||||
{
|
{
|
||||||
String thisMoment = date.format(DateTimeFormatter.ISO_INSTANT);
|
String thisMoment = date.format(ISO_INSTANT_FORMATTER);
|
||||||
requestParams.put("params", new JSONObject()
|
requestParams.put("params", new JSONObject()
|
||||||
.put("asOfDate", new JSONObject()
|
.put("asOfDate", new JSONObject()
|
||||||
.put("iso8601", thisMoment)
|
.put("iso8601", thisMoment)
|
||||||
@@ -368,7 +368,7 @@ public class RMRolesAndActionsAPI extends BaseAPI
|
|||||||
requestParams.put("name", RM_ACTIONS.COMPLETE_EVENT.getAction());
|
requestParams.put("name", RM_ACTIONS.COMPLETE_EVENT.getAction());
|
||||||
requestParams.put("nodeRef", recNodeRef);
|
requestParams.put("nodeRef", recNodeRef);
|
||||||
date = (date != null) ? date : Instant.now();
|
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()
|
requestParams.put("params", new JSONObject()
|
||||||
.put("eventName", event.getEventName())
|
.put("eventName", event.getEventName())
|
||||||
.put("eventCompletedBy", user)
|
.put("eventCompletedBy", user)
|
||||||
|
Reference in New Issue
Block a user