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:
cagache
2019-03-27 13:19:09 +02:00
parent 8c88ef2883
commit aa84113c6d
2 changed files with 9 additions and 3 deletions

View File

@@ -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()

View File

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