From e753c72e36438f6529416ad531dbae9870ea8bd8 Mon Sep 17 00:00:00 2001 From: Lars Johansson <lars.johansson@ess.eu> Date: Mon, 21 Mar 2022 09:39:18 +0100 Subject: [PATCH] Refactor docker integration tests Purpose to improve clarity and prepare for easier testing of REST API. --- .../org/openepics/names/docker/ITUtil.java | 2 +- .../names/docker/ITUtilNameElement.java | 240 +++++- .../names/docker/ITUtilStructureElement.java | 223 ++++- .../org/openepics/names/docker/NamesIT.java | 307 ++----- .../names/docker/StructuresDeviceGroupIT.java | 764 ++++------------- .../names/docker/StructuresDeviceTypeIT.java | 778 ++++------------- .../names/docker/StructuresDisciplineIT.java | 714 +++------------- .../names/docker/StructuresSubsystemIT.java | 792 ++++-------------- .../names/docker/StructuresSystemGroupIT.java | 716 +++------------- .../names/docker/StructuresSystemIT.java | 781 ++++------------- 10 files changed, 1365 insertions(+), 3952 deletions(-) diff --git a/src/test/java/org/openepics/names/docker/ITUtil.java b/src/test/java/org/openepics/names/docker/ITUtil.java index 8ac83c23..48368e9a 100644 --- a/src/test/java/org/openepics/names/docker/ITUtil.java +++ b/src/test/java/org/openepics/names/docker/ITUtil.java @@ -278,7 +278,7 @@ public class ITUtil { * @param expected expected response * @param expectedMessageEmpty expected message behavior */ - static void assertEqualsResponseBoolean(ResponseBoolean actual, Boolean expected, Boolean expectedMessageEmpty) { + public static void assertEqualsResponseBoolean(ResponseBoolean actual, Boolean expected, Boolean expectedMessageEmpty) { assertNotNull(actual); assertEquals(expected, actual.getValue()); assertEquals(expectedMessageEmpty, StringUtils.isEmpty(actual.getMessage())); diff --git a/src/test/java/org/openepics/names/docker/ITUtilNameElement.java b/src/test/java/org/openepics/names/docker/ITUtilNameElement.java index b09cba4b..20034d2f 100644 --- a/src/test/java/org/openepics/names/docker/ITUtilNameElement.java +++ b/src/test/java/org/openepics/names/docker/ITUtilNameElement.java @@ -33,9 +33,11 @@ import org.openepics.names.docker.ITUtil.EndpointChoice; import org.openepics.names.rest.beans.NameElement; import org.openepics.names.rest.beans.Status; import org.openepics.names.util.EnumUtil.NameChoice; +import org.openepics.names.util.response.ResponseBoolean; import org.openepics.names.util.response.ResponseBooleanList; import org.openepics.names.util.response.ResponsePageNameElements; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; /** @@ -168,6 +170,156 @@ public class ITUtilNameElement { // ---------------------------------------------------------------------------------------------------- + /** + * Utility method to read name elements and assert number of items in list. + * + * @param queryString query string + * @param expectedLessThanOrEqual (if non-negative number) less than or equal to this number of items + * @param expectedGreaterThanOrEqual (if non-negative number) greater than or equal to this number of items + * @return number of items in list + */ + public static Integer assertRead(String queryString, int expectedLessThanOrEqual, int expectedGreaterThanOrEqual) { + try { + ObjectMapper mapper = new ObjectMapper(); + String[] response = null; + ResponsePageNameElements responsePageNameElements = null; + + response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + queryString); + ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); + responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); + if (expectedLessThanOrEqual >= 0) { + assertTrue(responsePageNameElements.getListSize() <= expectedLessThanOrEqual); + } + if (expectedGreaterThanOrEqual >= 0) { + assertTrue(responsePageNameElements.getListSize() >= expectedGreaterThanOrEqual); + } + + return responsePageNameElements.getListSize(); + } catch (IOException e) { + fail(); + } catch (Exception e) { + fail(); + } + return null; + } + + /** + * Utility method to get name equivalence of a mnemonic or name. + * + * @param name name + * @param expected expected response + */ + public static void assertEquivalence(String name, String expected) { + try { + String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/equivalence/" + name); + ITUtil.assertResponseLength2CodeOKContent(response, expected); + } catch (IOException e) { + fail(); + } catch (Exception e) { + fail(); + } + } + + /** + * Utility method to check if name exists. + * + * @param name name + * @param expected expected response + * @param expectedMessageEmpty expected message empty + */ + public static void assertExists(String name, Boolean expected, Boolean expectedMessageEmpty) { + try { + ObjectMapper mapper = new ObjectMapper(); + String[] response = null; + + response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/exists/" + name); + ITUtil.assertResponseLength2CodeOK(response); + ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), expected, expectedMessageEmpty); + } catch (IOException e) { + fail(); + } catch (Exception e) { + fail(); + } + } + + /** + * Utility method to check if name is legacy name. + * + * @param name name + * @param expected expected response + */ + public static void assertIsLegacy(String name, Boolean expected) { + try { + ObjectMapper mapper = new ObjectMapper(); + String[] response = null; + + response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/islegacy/" + name); + ITUtil.assertResponseLength2CodeOK(response); + ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), expected); + } catch (IOException e) { + fail(); + } catch (Exception e) { + fail(); + } + } + + /** + * Utility method to check if name is valid to create. + * + * @param name name + * @param expected expected response + */ + public static void assertIsValidToCreate(String name, Boolean expected) { + try { + ObjectMapper mapper = new ObjectMapper(); + String[] response = null; + + response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/isvalidtocreate/" + name); + ITUtil.assertResponseLength2CodeOK(response); + ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), expected); + } catch (IOException e) { + fail(); + } catch (Exception e) { + fail(); + } + } + + // ---------------------------------------------------------------------------------------------------- + + /** + * Utility method to (try to) validate a name element from given json and assert expected response. + * Method expected to NOT succeed to validate + * but instead assert response code (possibly also a non-empty message). + * + * @param json json + * @param nameChoice name choice + * @param responseCode response code + */ + public static void assertValidate(String json, NameChoice nameChoice, int responseCode) { + assertValidate(json, nameChoice, responseCode, Boolean.FALSE, Boolean.FALSE); + } + + public static void assertValidate(String json, NameChoice nameChoice, int responseCode, Boolean expected, Boolean expectedMessageEmpty) { + String validatePath = getValidatePath(nameChoice); + + try { + ObjectMapper mapper = new ObjectMapper(); + String[] response = null; + + response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, validatePath, json)); + ITUtil.assertResponseLength2Code(response, responseCode); + if (response[1] != null) { + ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), expected, expectedMessageEmpty); + } + } catch (IOException e) { + fail(); + } catch (InterruptedException e) { + fail(); + } catch (Exception e) { + fail(); + } + } + /** * Utility method to set name element attributes name and index and then validate create and assert expected response. * @@ -178,8 +330,8 @@ public class ITUtilNameElement { * @param expected expected response */ public static void assertValidate(NameElement nameElement, NameChoice nameChoice, String name, String index, Boolean expected) { - nameElement.setNameAndIndex(name, index); - assertValidate(nameElement, nameChoice, expected); + nameElement.setNameAndIndex(name, index); + assertValidate(nameElement, nameChoice, expected); } /** @@ -190,29 +342,15 @@ public class ITUtilNameElement { * @param expected expected response */ public static void assertValidate(NameElement nameElement, NameChoice nameChoice, Boolean expected) { - String validatePath = ""; - switch (nameChoice) { - case CREATE: - validatePath = "/validatecreate"; - break; - case UPDATE: - validatePath = "/validateupdate"; - break; - case DELETE: - validatePath = "/validatedelete"; - break; - default: - fail(); - break; - } - - try { + String validatePath = getValidatePath(nameChoice); + + try { ObjectMapper mapper = new ObjectMapper(); String[] response = null; response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, validatePath, "[" + mapper.writeValueAsString(nameElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), expected); + ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); + ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), expected); } catch (IOException e) { fail(); } catch (InterruptedException e) { @@ -222,8 +360,68 @@ public class ITUtilNameElement { } } + /** + * Utility method to return validate path for name choice. + * + * @param nameChoice name choice + * @return validate path + */ + private static String getValidatePath(NameChoice nameChoice) { + String validatePath = ""; + switch (nameChoice) { + case CREATE: + validatePath = "/validatecreate"; + break; + case UPDATE: + validatePath = "/validateupdate"; + break; + case DELETE: + validatePath = "/validatedelete"; + break; + default: + break; + } + return validatePath; + } + // ---------------------------------------------------------------------------------------------------- + /** + * Utility method to (try to) create a name element and assert result response code. + * Method expected to NOT succeed to create a name element + * but instead assert response code (possibly also a non-empty message). + * + * @param nameElement name element + * @param responseCode response code + * @throws JsonProcessingException + */ + public static void assertCreate(NameElement nameElement, int responseCode) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + assertCreate("[" + mapper.writeValueAsString(nameElement) + "]", responseCode); + } + + /** + * Utility method to (try to) create a name element from given json and assert result response code. + * Method expected to NOT succeed to create a name element + * but instead assert response code (possibly also a non-empty message). + * + * @param json json + * @param responseCode response code + */ + public static void assertCreate(String json, int responseCode) { + try { + String[] response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", json)); + ITUtil.assertResponseLength2Code(response, responseCode); + // ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + } catch (IOException e) { + fail(); + } catch (InterruptedException e) { + fail(); + } catch (Exception e) { + fail(); + } + } + /** * Utility method to create a name element and assert result. * diff --git a/src/test/java/org/openepics/names/docker/ITUtilStructureElement.java b/src/test/java/org/openepics/names/docker/ITUtilStructureElement.java index 464b45af..86d0967d 100644 --- a/src/test/java/org/openepics/names/docker/ITUtilStructureElement.java +++ b/src/test/java/org/openepics/names/docker/ITUtilStructureElement.java @@ -34,9 +34,11 @@ import org.openepics.names.rest.beans.Status; import org.openepics.names.rest.beans.StructureElement; import org.openepics.names.rest.beans.Type; import org.openepics.names.util.EnumUtil.StructureChoice; +import org.openepics.names.util.response.ResponseBoolean; import org.openepics.names.util.response.ResponseBooleanList; import org.openepics.names.util.response.ResponsePageStructureElements; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; /** @@ -164,6 +166,124 @@ public class ITUtilStructureElement { // ---------------------------------------------------------------------------------------------------- + /** + * Utility method to read structure elements and assert number of items in list. + * + * @param queryString query string + * @param expectedLessThanOrEqual (if non-negative number) less than or equal to this number of items + * @param expectedGreaterThanOrEqual (if non-negative number) greater than or equal to this number of items + * @return number of items in list + */ + public static Integer assertRead(String queryString, int expectedLessThanOrEqual, int expectedGreaterThanOrEqual) { + try { + ObjectMapper mapper = new ObjectMapper(); + String[] response = null; + ResponsePageStructureElements responsePageStructureElements = null; + + response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + queryString); + ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); + responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); + if (expectedLessThanOrEqual >= 0) { + assertTrue(responsePageStructureElements.getListSize() <= expectedLessThanOrEqual); + } + if (expectedGreaterThanOrEqual >= 0) { + assertTrue(responsePageStructureElements.getListSize() >= expectedGreaterThanOrEqual); + } + + return responsePageStructureElements.getListSize(); + } catch (IOException e) { + fail(); + } catch (Exception e) { + fail(); + } + return null; + } + + /** + * Utility method to get name equivalence of a mnemonic or name. + * + * @param name name + * @param expected expected response + */ + public static void assertEquivalence(String name, String expected) { + try { + String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/equivalence/" + name); + ITUtil.assertResponseLength2CodeOKContent(response, expected); + } catch (IOException e) { + fail(); + } catch (Exception e) { + fail(); + } + } + + /** + * Utility method to check if structure exists. + * + * @param mnemonic mnemonic + * @param type type + * @param expected expected response + * @param expectedMessageEmpty expected message empty + */ + public static void assertExists(String mnemonic, Type type, Boolean expected, Boolean expectedMessageEmpty) { + try { + ObjectMapper mapper = new ObjectMapper(); + String[] response = null; + + response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/exists/" + type.toString() + "/" + mnemonic); + ITUtil.assertResponseLength2CodeOK(response); + ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), expected, expectedMessageEmpty); + } catch (IOException e) { + fail(); + } catch (Exception e) { + fail(); + } + } + + /** + * Utility method to check if structure is valid to create. + * Method will not produce a message. + * + * @param mnemonicpath mnemonic path + * @param type type + * @param expected expected response + */ + public static void assertIsValidToCreate(String mnemonicpath, Type type, Boolean expected) { + try { + String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/" + type.toString() + "/" + mnemonicpath); + ITUtil.assertResponseLength2CodeOK(response); + } catch (IOException e) { + fail(); + } catch (Exception e) { + fail(); + } + } + + // ---------------------------------------------------------------------------------------------------- + + /** + * Utility method to (try to) validate a structure element from given json and assert expected response. + * Method expected to NOT succeed to validate + * but instead assert response code (possibly also a non-empty message). + * + * @param json json + * @param structureChoice structure choice + * @param responseCode response code + */ + public static void assertValidate(String json, StructureChoice structureChoice, int responseCode) { + String validatePath = getValidatePath(structureChoice); + + try { + String[] response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, validatePath, json)); + ITUtil.assertResponseLength2Code(response, responseCode); + } catch (IOException e) { + fail(); + } catch (InterruptedException e) { + fail(); + } catch (Exception e) { + fail(); + } + } + /** * Utility method to validate and assert expected response. * @@ -172,38 +292,15 @@ public class ITUtilStructureElement { * @param expected expected response */ public static void assertValidate(StructureElement structureElement, StructureChoice structureChoice, Boolean expected) { - String validatePath = ""; - switch (structureChoice) { - case CREATE: - validatePath = "/validatecreate"; - break; - case UPDATE: - validatePath = "/validateupdate"; - break; - case DELETE: - validatePath = "/validatedelete"; - break; - case APPROVE: - validatePath = "/validateapprove"; - break; - case CANCEL: - validatePath = "/validatecancel"; - break; - case REJECT: - validatePath = "/validatereject"; - break; - default: - fail(); - break; - } - - try { + String validatePath = getValidatePath(structureChoice); + + try { ObjectMapper mapper = new ObjectMapper(); String[] response = null; - response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, validatePath, "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), expected); + response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, validatePath, "[" + mapper.writeValueAsString(structureElement) + "]")); + ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); + ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), expected); } catch (IOException e) { fail(); } catch (InterruptedException e) { @@ -213,9 +310,77 @@ public class ITUtilStructureElement { } } + /** + * Utility method to return validate path for structure choice. + * + * @param structureChoice structure choice + * @return validate path + */ + private static String getValidatePath(StructureChoice structureChoice) { + String validatePath = ""; + switch (structureChoice) { + case CREATE: + validatePath = "/validatecreate"; + break; + case UPDATE: + validatePath = "/validateupdate"; + break; + case DELETE: + validatePath = "/validatedelete"; + break; + case APPROVE: + validatePath = "/validateapprove"; + break; + case CANCEL: + validatePath = "/validatecancel"; + break; + case REJECT: + validatePath = "/validatereject"; + break; + default: + break; + } + return validatePath; + } // ---------------------------------------------------------------------------------------------------- + /** + * Utility method to (try to) create a structure element and assert result response code. + * Method expected to NOT succeed to create a structure element + * but instead assert response code (possibly also a non-empty message). + * + * @param structureElement structure element + * @param responseCode response code + * @throws JsonProcessingException + */ + public static void assertCreate(StructureElement structureElement, int responseCode) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + assertCreate("[" + mapper.writeValueAsString(structureElement) + "]", responseCode); + } + + /** + * Utility method to (try to) create a structure element from given json and assert result response code. + * Method expected to NOT succeed to create a structure element + * but instead assert response code (possibly also a non-empty message). + * + * @param json json + * @param responseCode response code + */ + public static void assertCreate(String json, int responseCode) { + try { + String[] response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", json)); + ITUtil.assertResponseLength2Code(response, responseCode); + // ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + } catch (IOException e) { + fail(); + } catch (InterruptedException e) { + fail(); + } catch (Exception e) { + fail(); + } + } + /** * Utility method to create a structure element and assert result. * diff --git a/src/test/java/org/openepics/names/docker/NamesIT.java b/src/test/java/org/openepics/names/docker/NamesIT.java index c4c4739f..c15cf614 100644 --- a/src/test/java/org/openepics/names/docker/NamesIT.java +++ b/src/test/java/org/openepics/names/docker/NamesIT.java @@ -18,9 +18,6 @@ package org.openepics.names.docker; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.io.File; @@ -30,17 +27,11 @@ import java.util.UUID; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.openepics.names.docker.ITUtil.AuthorizationChoice; -import org.openepics.names.docker.ITUtil.EndpointChoice; import org.openepics.names.rest.beans.NameElement; import org.openepics.names.rest.beans.Status; import org.openepics.names.rest.beans.StructureElement; import org.openepics.names.rest.beans.Type; import org.openepics.names.util.EnumUtil.NameChoice; -import org.openepics.names.util.response.Response; -import org.openepics.names.util.response.ResponseBoolean; -import org.openepics.names.util.response.ResponseBooleanList; -import org.openepics.names.util.response.ResponsePageNameElements; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; @@ -179,49 +170,27 @@ public class NamesIT { // read validate create try { - ObjectMapper mapper = new ObjectMapper(); NameElement nameElement = new NameElement(); - String[] response = null; - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/exists/RFQ-010PRL:EMR-RFA-051"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE, Boolean.TRUE); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/islegacy/RFQ-010PRL:EMR-RFA-051"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/isvalidtocreate/RFQ-010PRL:EMR-RFA-051"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.TRUE); + ITUtilNameElement.assertExists("RFQ-010PRL:EMR-RFA-051", Boolean.FALSE, Boolean.TRUE); + ITUtilNameElement.assertIsLegacy("RFQ-010PRL:EMR-RFA-051", Boolean.FALSE); + ITUtilNameElement.assertIsValidToCreate("RFQ-010PRL:EMR-RFA-051", Boolean.TRUE); // validate create - response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "/validatecreate", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilNameElement.assertValidate("[{asdf]", NameChoice.CREATE, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilNameElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", "[" + mapper.writeValueAsString(nameElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); nameElement.setDescription("description"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", "[" + mapper.writeValueAsString(nameElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); nameElement.setComment("comment"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", "[" + mapper.writeValueAsString(nameElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); nameElement.setSubsystem(subsystem010PRL); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.TRUE); @@ -233,17 +202,11 @@ public class NamesIT { nameElement.setName("RFQ-010PRL:EMR-RFA-051"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", "[" + mapper.writeValueAsString(nameElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); nameElement.setIndex("051"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", "[" + mapper.writeValueAsString(nameElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); nameElement.setDevicetype(deviceTypeRFA); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.TRUE); @@ -267,17 +230,11 @@ public class NamesIT { nameElement.setName("RFQ:EMR-RFA-051"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", "[" + mapper.writeValueAsString(nameElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); nameElement.setIndex("051"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", "[" + mapper.writeValueAsString(nameElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); nameElement.setDevicetype(deviceTypeRFA); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.TRUE); @@ -301,17 +258,11 @@ public class NamesIT { nameElement.setName("Acc:EMR-RFA-051"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", "[" + mapper.writeValueAsString(nameElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); nameElement.setIndex("051"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "", "[" + mapper.writeValueAsString(nameElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); nameElement.setDevicetype(deviceTypeTT); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); @@ -320,8 +271,6 @@ public class NamesIT { ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.TRUE); } catch (IOException e) { fail(); - } catch (InterruptedException e) { - fail(); } catch (Exception e) { fail(); } @@ -344,7 +293,6 @@ public class NamesIT { try { ObjectMapper mapper = new ObjectMapper(); - String[] response = null; NameElement nameElement = null; NameElement nameElement2 = null; @@ -366,21 +314,13 @@ public class NamesIT { "description", Status.APPROVED, Boolean.TRUE, Boolean.FALSE, null, "test who", "comment"); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/exists/RFQ-010PRL:EMR-RFA-052"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE, Boolean.TRUE); + ITUtilNameElement.assertExists("RFQ-010PRL:EMR-RFA-052", Boolean.FALSE, Boolean.TRUE); + ITUtilNameElement.assertIsLegacy("RFQ-010PRL:EMR-RFA-052", Boolean.FALSE); + ITUtilNameElement.assertIsValidToCreate("RFQ-010PRL:EMR-RFA-052", Boolean.TRUE); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/islegacy/RFQ-010PRL:EMR-RFA-052"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/isvalidtocreate/RFQ-010PRL:EMR-RFA-052"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.TRUE); - - response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "/validatecreate", "[" + mapper.writeValueAsString(nameElement) + ","+mapper.writeValueAsString(nameElement2) +"]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), Boolean.FALSE); + ITUtilNameElement.assertValidate( + "[" + mapper.writeValueAsString(nameElement) + ","+mapper.writeValueAsString(nameElement2) +"]", + NameChoice.CREATE, HttpURLConnection.HTTP_OK, Boolean.FALSE, Boolean.FALSE); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.TRUE); @@ -388,25 +328,13 @@ public class NamesIT { createdNameElement = ITUtilNameElement.assertCreate(nameElement); nameElement = createdNameElement; - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/exists/RFQ-010PRL:EMR-RFA-052"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.TRUE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/islegacy/RFQ-010PRL:EMR-RFA-052"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/isvalidtocreate/RFQ-010PRL:EMR-RFA-052"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); + ITUtilNameElement.assertExists("RFQ-010PRL:EMR-RFA-052", Boolean.TRUE, Boolean.TRUE); + ITUtilNameElement.assertIsLegacy("RFQ-010PRL:EMR-RFA-052", Boolean.FALSE); + ITUtilNameElement.assertIsValidToCreate("RFQ-010PRL:EMR-RFA-052", Boolean.FALSE); - response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.NAMES, "/validatecreate", "[" + mapper.writeValueAsString(nameElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBooleanList.class), Boolean.FALSE); + ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); } catch (IOException e) { fail(); - } catch (InterruptedException e) { - fail(); } catch (Exception e) { fail(); } @@ -802,116 +730,36 @@ public class NamesIT { responseNameElement = ITUtilNameElement.assertDelete(nameElement8); try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; + // read - ResponsePageNameElements responsePageNameElements = null; + ITUtilNameElement.assertRead("", -1, 8); - // read + ITUtilNameElement.assertRead("?queryFields=UUID&queryValues=" + uuid.toString(), 1, 1); + ITUtilNameElement.assertRead("?queryFields=NAMEEQUIVALENCE&queryValues=RFQ-10%25", -1, 8); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - assertTrue(responsePageNameElements.getListSize() >= 8); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "?queryFields=UUID&queryValues=" + uuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - ITUtilNameElement.assertContentLength(responsePageNameElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "?queryFields=NAMEEQUIVALENCE&queryValues=RFQ-10%25"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - assertTrue(responsePageNameElements.getListSize() >= 8); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "?deleted=false"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - assertTrue(responsePageNameElements.getListSize() >= 6); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "?deleted=true"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - assertTrue(responsePageNameElements.getListSize() >= 2); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/RFQ-010:EMR-FS-005"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - ITUtilNameElement.assertContentLength(responsePageNameElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/RFQ-010:EMR-FS-0"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - ITUtilNameElement.assertContentLength(responsePageNameElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/RFQ-010:EMR-FS-0__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - assertTrue(responsePageNameElements.getListSize() >= 6); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/RFQ-010:EMR-FS-0%25"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - assertTrue(responsePageNameElements.getListSize() >= 6); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/systemstructure/RFQ-010"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - assertTrue(responsePageNameElements.getListSize() >= 6); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/systemstructure/RFQ-0"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - ITUtilNameElement.assertContentLength(responsePageNameElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/systemstructure/RFQ-0__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - assertTrue(responsePageNameElements.getListSize() >= 6); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/systemstructure/RFQ-N1U1"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - ITUtilNameElement.assertContentLength(responsePageNameElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/devicestructure/EMR-FS"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - assertTrue(responsePageNameElements.getListSize() >= 6); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/devicestructure/EMR-F"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - ITUtilNameElement.assertContentLength(responsePageNameElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/devicestructure/EMR-F_"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - assertTrue(responsePageNameElements.getListSize() >= 6); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/devicestructure/EMR-TT"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - ITUtilNameElement.assertContentLength(responsePageNameElements, 0); + ITUtilNameElement.assertRead("?deleted=false", -1, 6); + ITUtilNameElement.assertRead("?deleted=true", -1, 2); - // history + ITUtilNameElement.assertRead("/RFQ-010:EMR-FS-005", 1, 1); + ITUtilNameElement.assertRead("/RFQ-010:EMR-FS-0", 0, 0); + ITUtilNameElement.assertRead("/RFQ-010:EMR-FS-0__", -1, 6); + ITUtilNameElement.assertRead("/RFQ-010:EMR-FS-0%25", -1, 6); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/history/" + systemRFQ.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - ITUtilNameElement.assertContentLength(responsePageNameElements, 0); + ITUtilNameElement.assertRead("/systemstructure/RFQ-010", -1, 6); + ITUtilNameElement.assertRead("/systemstructure/RFQ-0", 0, 0); + ITUtilNameElement.assertRead("/systemstructure/RFQ-0__", -1, 6); + ITUtilNameElement.assertRead("/systemstructure/RFQ-N1U1", 0, 0); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/history/" + uuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - ITUtilNameElement.assertContentLength(responsePageNameElements, 3); + ITUtilNameElement.assertRead("/devicestructure/EMR-FS", -1, 6); + ITUtilNameElement.assertRead("/devicestructure/EMR-F", 0, 0); + ITUtilNameElement.assertRead("/devicestructure/EMR-F_", -1, 6); + ITUtilNameElement.assertRead("/devicestructure/EMR-TT", 0, 0); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/history/" + uuid2.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageNameElements = mapper.readValue(response[1], ResponsePageNameElements.class); - ITUtilNameElement.assertContentLength(responsePageNameElements, 1); - } catch (IOException e) { - fail(); + // history + + ITUtilNameElement.assertRead("/history/" + systemRFQ.toString(), 0, 0); + ITUtilNameElement.assertRead("/history/" + uuid.toString(), 3, 3); + ITUtilNameElement.assertRead("/history/" + uuid2.toString(), 1, 1); } catch (Exception e) { fail(); } @@ -919,57 +767,46 @@ public class NamesIT { @Test public void equivalenceName() { - try { - String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/equivalence/A2T-010PRL:RFS-PRLTap-054"); - ITUtil.assertResponseLength2CodeOKContent(response, "A2T-10PR1:RFS-PR1TAP-54"); - } catch (IOException e) { - fail(); - } + // purpose + // test name equivalence + // + // what + // read equivalence name + + ITUtilNameElement.assertEquivalence("A2T-010PRL:RFS-PRLTap-071", "A2T-10PR1:RFS-PR1TAP-71"); } @Test public void existsName() { - ObjectMapper mapper = new ObjectMapper(); + // purpose + // test if name exists + // + // what + // read exists name - try { - String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/exists/A2T-010PRL:RFS-PRLTap-054"); - ITUtil.assertResponseLength2CodeOK(response); - ResponseBoolean responseEntity = mapper.readValue(response[1], ResponseBoolean.class); - assertNotNull(responseEntity); - assertFalse(responseEntity.getValue()); - } catch (IOException e) { - fail(); - } + ITUtilNameElement.assertExists("RFQ-010PRL:EMR-RFA-071", Boolean.FALSE, Boolean.TRUE); } @Test public void isLegacyName() { - ObjectMapper mapper = new ObjectMapper(); + // purpose + // test if name is legacy name + // + // what + // read is legacy name - try { - String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/islegacy/A2T-010PRL:RFS-PRLTap-054"); - ITUtil.assertResponseLength2CodeOK(response); - ResponseBoolean responseEntity = mapper.readValue(response[1], ResponseBoolean.class); - assertNotNull(responseEntity); - assertFalse(responseEntity.getValue()); - } catch (IOException e) { - fail(); - } + ITUtilNameElement.assertIsLegacy("RFQ-010PRL:EMR-RFA-071", Boolean.FALSE); } @Test public void isValidToCreateName() { - ObjectMapper mapper = new ObjectMapper(); + // purpose + // test if name is valid to create + // + // what + // read is valid to create name - try { - String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_NAMES + "/isvalidtocreate/A2T-010PRL:RFS-PRLTap-054"); - ITUtil.assertResponseLength2CodeOK(response); - ResponseBoolean responseEntity = mapper.readValue(response[1], ResponseBoolean.class); - assertNotNull(responseEntity); - assertFalse(responseEntity.getValue()); - } catch (IOException e) { - fail(); - } + ITUtilNameElement.assertIsValidToCreate("RFQ-010PRL:EMR-RFA-071", Boolean.TRUE); } } diff --git a/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java b/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java index ad2b1244..e5033d32 100644 --- a/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java @@ -20,7 +20,6 @@ package org.openepics.names.docker; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.io.File; @@ -30,22 +29,15 @@ import java.util.UUID; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.openepics.names.docker.ITUtil.AuthorizationChoice; -import org.openepics.names.docker.ITUtil.EndpointChoice; import org.openepics.names.rest.beans.Status; import org.openepics.names.rest.beans.StructureElement; import org.openepics.names.rest.beans.Type; import org.openepics.names.util.EnumUtil.StructureChoice; -import org.openepics.names.util.response.Response; -import org.openepics.names.util.response.ResponseBoolean; -import org.openepics.names.util.response.ResponsePageStructureElements; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import com.fasterxml.jackson.databind.ObjectMapper; - /** * Integration tests for Naming and PostgreSQL that make use of existing dockerization * with docker-compose.yml / Dockerfile. @@ -119,57 +111,32 @@ public class StructuresDeviceGroupIT { // read validate create try { - ObjectMapper mapper = new ObjectMapper(); StructureElement structureElement = new StructureElement(); - String[] response = null; - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/exists/DEVICEGROUP/Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE, Boolean.TRUE); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/DEVICEGROUP/Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); + ITUtilStructureElement.assertExists("Cc", Type.DEVICEGROUP, Boolean.FALSE, Boolean.TRUE); + ITUtilStructureElement.assertIsValidToCreate("Cc", Type.DEVICEGROUP, Boolean.FALSE); - response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "/validatecreate", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertValidate("[{asdf]", StructureChoice.CREATE, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setType(Type.DEVICEGROUP); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setParent(disciplineUuid); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setName("name"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setDescription("description"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setComment("comment"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); @@ -182,8 +149,6 @@ public class StructuresDeviceGroupIT { ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); } catch (IOException e) { fail(); - } catch (InterruptedException e) { - fail(); } catch (Exception e) { fail(); } @@ -296,10 +261,10 @@ public class StructuresDeviceGroupIT { structureElement.setMnemonic("123456789"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - } catch (Exception e) { - fail(); - } - } + } catch (Exception e) { + fail(); + } + } @Test public void createApprove() { @@ -950,11 +915,6 @@ public class StructuresDeviceGroupIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement approvedStructureElement = null; @@ -971,155 +931,47 @@ public class StructuresDeviceGroupIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Di"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/DEVICEGROUP", -1, 1); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Di", -1, 1); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?queryFields=UUID&queryValues=" + approvedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Di"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + approvedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/DEVICEGROUP", -1, 1)); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED", -1, 1); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?queryFields=UUID&queryValues=" + approvedStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Di", -1, 1); + + ITUtilStructureElement.assertRead("/history/" + approvedStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1137,11 +989,6 @@ public class StructuresDeviceGroupIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement cancelledStructureElement = null; @@ -1158,155 +1005,47 @@ public class StructuresDeviceGroupIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Di"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/DEVICEGROUP", -1, 1); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Di", -1, 1); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?queryFields=UUID&queryValues=" + cancelledStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Di"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + cancelledStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/DEVICEGROUP", -1, 1)); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED", -1, 1); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?queryFields=UUID&queryValues=" + cancelledStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Di", -1, 1); + + ITUtilStructureElement.assertRead("/history/" + cancelledStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1324,11 +1063,6 @@ public class StructuresDeviceGroupIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement rejectedStructureElement = null; @@ -1345,155 +1079,47 @@ public class StructuresDeviceGroupIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLengthOne(responsePageStructureElements); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Di"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/DEVICEGROUP", -1, 1); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Di", -1, 1); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?queryFields=UUID&queryValues=" + rejectedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Di"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + rejectedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/DEVICEGROUP", -1, 1)); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED", -1, 1); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?queryFields=UUID&queryValues=" + rejectedStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Di", -1, 1); + + ITUtilStructureElement.assertRead("/history/" + rejectedStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1858,126 +1484,33 @@ public class StructuresDeviceGroupIT { // 60 device group entries try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - // from first structure element assertNotNull(uuid); - // 30, not 45 or 60 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 30); - - // 5, not 10 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - // 20, not 35 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 20); - - // 0, not 5 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - // 5, not 10 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - // 25, not 30 or 45 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?statuses=PENDING&statuses=APPROVED&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 25); - - // 15, not 30 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?deleted=false&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - // 0, not 5 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?deleted=false&statuses=PENDING&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?deleted=false&statuses=APPROVED&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - // 0, not 5 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?deleted=false&statuses=CANCELLED&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - // 0, not 5 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?deleted=false&statuses=REJECTED&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - // 15, not 20 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?deleted=false&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?deleted=true&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?deleted=true&statuses=PENDING&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?deleted=true&statuses=APPROVED&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?deleted=true&statuses=CANCELLED&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?deleted=true&statuses=REJECTED&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICEGROUP?deleted=true&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONICPATH&queryValues=Di2"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/children/DEVICEGROUP/" + uuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/children/DISCIPLINE/" + disciplineUuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + ITUtilStructureElement.assertRead("/DEVICEGROUP?queryFields=MNEMONICPATH&queryValues=Di2", 30, 30); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING&queryFields=MNEMONICPATH&queryValues=Di2", 5, 5); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=APPROVED&queryFields=MNEMONICPATH&queryValues=Di2", 20, 20); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=CANCELLED&queryFields=MNEMONICPATH&queryValues=Di2", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=REJECTED&queryFields=MNEMONICPATH&queryValues=Di2", 5, 5); + ITUtilStructureElement.assertRead("/DEVICEGROUP?statuses=PENDING&statuses=APPROVED&queryFields=MNEMONICPATH&queryValues=Di2", 25, 25); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?deleted=false&queryFields=MNEMONICPATH&queryValues=Di2", 15, 15); + ITUtilStructureElement.assertRead("/DEVICEGROUP?deleted=false&statuses=PENDING&queryFields=MNEMONICPATH&queryValues=Di2", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?deleted=false&statuses=APPROVED&queryFields=MNEMONICPATH&queryValues=Di2", 15, 15); + ITUtilStructureElement.assertRead("/DEVICEGROUP?deleted=false&statuses=CANCELLED&queryFields=MNEMONICPATH&queryValues=Di2", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?deleted=false&statuses=REJECTED&queryFields=MNEMONICPATH&queryValues=Di2", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?deleted=false&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONICPATH&queryValues=Di2", 15, 15); + + ITUtilStructureElement.assertRead("/DEVICEGROUP?deleted=true&queryFields=MNEMONICPATH&queryValues=Di2", 15, 15); + ITUtilStructureElement.assertRead("/DEVICEGROUP?deleted=true&statuses=PENDING&queryFields=MNEMONICPATH&queryValues=Di2", 5, 5); + ITUtilStructureElement.assertRead("/DEVICEGROUP?deleted=true&statuses=APPROVED&queryFields=MNEMONICPATH&queryValues=Di2", 5, 5); + ITUtilStructureElement.assertRead("/DEVICEGROUP?deleted=true&statuses=CANCELLED&queryFields=MNEMONICPATH&queryValues=Di2", 0, 0); + ITUtilStructureElement.assertRead("/DEVICEGROUP?deleted=true&statuses=REJECTED&queryFields=MNEMONICPATH&queryValues=Di2", 5, 5); + ITUtilStructureElement.assertRead("/DEVICEGROUP?deleted=true&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONICPATH&queryValues=Di2", 10, 10); + + ITUtilStructureElement.assertRead("/children/DEVICEGROUP/" + uuid.toString(), 0, 0); + ITUtilStructureElement.assertRead("/children/DISCIPLINE/" + disciplineUuid.toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1991,12 +1524,7 @@ public class StructuresDeviceGroupIT { // what // read equivalence mnemonic - try { - String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/equivalence/Dg"); - ITUtil.assertResponseLength2CodeOKContent(response, "DG"); - } catch (IOException e) { - fail(); - } + ITUtilStructureElement.assertEquivalence("Dg", "DG"); } } diff --git a/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java b/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java index a77d8082..b9db0bcf 100644 --- a/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java @@ -20,7 +20,6 @@ package org.openepics.names.docker; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.io.File; @@ -30,22 +29,15 @@ import java.util.UUID; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.openepics.names.docker.ITUtil.AuthorizationChoice; -import org.openepics.names.docker.ITUtil.EndpointChoice; import org.openepics.names.rest.beans.Status; import org.openepics.names.rest.beans.StructureElement; import org.openepics.names.rest.beans.Type; import org.openepics.names.util.EnumUtil.StructureChoice; -import org.openepics.names.util.response.Response; -import org.openepics.names.util.response.ResponseBoolean; -import org.openepics.names.util.response.ResponsePageStructureElements; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import com.fasterxml.jackson.databind.ObjectMapper; - /** * Integration tests for Naming and PostgreSQL that make use of existing dockerization * with docker-compose.yml / Dockerfile. @@ -119,72 +111,39 @@ public class StructuresDeviceTypeIT { // read validate create try { - ObjectMapper mapper = new ObjectMapper(); StructureElement structureElement = new StructureElement(); - String[] response = null; - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/exists/DEVICETYPE/Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE, Boolean.TRUE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/DEVICETYPE/Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/DEVICETYPE/Db-Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/DEVICETYPE/Di-Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.TRUE); + ITUtilStructureElement.assertExists("Cc", Type.DEVICETYPE, Boolean.FALSE, Boolean.TRUE); + ITUtilStructureElement.assertIsValidToCreate("Cc", Type.DEVICETYPE, Boolean.FALSE); + ITUtilStructureElement.assertIsValidToCreate("Db-Cc", Type.DEVICETYPE, Boolean.FALSE); + ITUtilStructureElement.assertIsValidToCreate("Di-Cc", Type.DEVICETYPE, Boolean.TRUE); + ITUtilStructureElement.assertIsValidToCreate("Di-Di", Type.DEVICETYPE, Boolean.FALSE); - response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "/validatecreate", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertValidate("[{asdf]", StructureChoice.CREATE, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setType(Type.DEVICETYPE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setParent(deviceGroupUuid); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setName("name"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setMnemonic("Cc"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setDescription("description"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setComment("comment"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); @@ -193,8 +152,6 @@ public class StructuresDeviceTypeIT { ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); } catch (IOException e) { fail(); - } catch (InterruptedException e) { - fail(); } catch (Exception e) { fail(); } @@ -307,10 +264,10 @@ public class StructuresDeviceTypeIT { structureElement.setMnemonic("123456789"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - } catch (Exception e) { - fail(); - } - } + } catch (Exception e) { + fail(); + } + } @Test public void createApprove() { @@ -961,11 +918,6 @@ public class StructuresDeviceTypeIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement approvedStructureElement = null; @@ -982,155 +934,47 @@ public class StructuresDeviceTypeIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Di-Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/DEVICETYPE", -1, 1); + + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha", 1, 1); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/DEVICETYPE?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Di-Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?queryFields=UUID&queryValues=" + approvedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Di-Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + approvedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/DEVICETYPE", -1, 1)); + + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED", -1, 1); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha", 1, 1); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/DEVICETYPE?queryFields=UUID&queryValues=" + approvedStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rsha", 1, 1); + ITUtilStructureElement.assertRead("/mnemonicpath/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Di-Rsha", 1, 1); + + ITUtilStructureElement.assertRead("/history/" + approvedStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1148,11 +992,6 @@ public class StructuresDeviceTypeIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement cancelledStructureElement = null; @@ -1169,155 +1008,47 @@ public class StructuresDeviceTypeIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Di-Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/DEVICETYPE", -1, 1); + + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING", 1, 1); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc", 1, 1); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/DEVICETYPE?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Di-Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?queryFields=UUID&queryValues=" + cancelledStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Di-Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + cancelledStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/DEVICETYPE", -1, 1)); + + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED", -1, 1); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc", 1, 1); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/DEVICETYPE?queryFields=UUID&queryValues=" + cancelledStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Di-Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + cancelledStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1335,11 +1066,6 @@ public class StructuresDeviceTypeIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement rejectedStructureElement = null; @@ -1356,155 +1082,47 @@ public class StructuresDeviceTypeIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLengthOne(responsePageStructureElements); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Di-Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/DEVICETYPE", -1, 1); + + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr", 1, 1); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/DEVICETYPE?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Di-Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?queryFields=UUID&queryValues=" + rejectedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Di-Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + rejectedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/DEVICETYPE", -1, 1)); + + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED", -1, 1); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr", 1, 1); + + ITUtilStructureElement.assertRead("/DEVICETYPE?queryFields=UUID&queryValues=" + rejectedStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Di-Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + rejectedStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1869,123 +1487,34 @@ public class StructuresDeviceTypeIT { // 60 device type entries try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - // from first structure element assertNotNull(uuid); - // 45, not 60 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 45); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - // 20, not 35 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 20); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - // 30, not 45 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 30); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?deleted=false&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 30); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?deleted=false&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?deleted=false&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?deleted=false&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?deleted=false&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?deleted=false&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 20); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?deleted=true&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?deleted=true&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?deleted=true&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?deleted=true&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?deleted=true&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DEVICETYPE?deleted=true&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/children/DEVICETYPE/" + uuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/children/DEVICEGROUP/" + deviceGroupUuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/children/DISCIPLINE/" + disciplineUuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + ITUtilStructureElement.assertRead("/DEVICETYPE?queryFields=MNEMONIC&queryValues=A__", 45, 45); + + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 10, 10); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 20, 20); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 10, 10); + ITUtilStructureElement.assertRead("/DEVICETYPE?statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 30, 30); + + ITUtilStructureElement.assertRead("/DEVICETYPE?deleted=false&queryFields=MNEMONIC&queryValues=A__", 30, 30); + ITUtilStructureElement.assertRead("/DEVICETYPE?deleted=false&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DEVICETYPE?deleted=false&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 15, 15); + ITUtilStructureElement.assertRead("/DEVICETYPE?deleted=false&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DEVICETYPE?deleted=false&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DEVICETYPE?deleted=false&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 20, 20); + + ITUtilStructureElement.assertRead("/DEVICETYPE?deleted=true&queryFields=MNEMONIC&queryValues=A__", 15, 15); + ITUtilStructureElement.assertRead("/DEVICETYPE?deleted=true&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DEVICETYPE?deleted=true&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DEVICETYPE?deleted=true&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 0, 0); + ITUtilStructureElement.assertRead("/DEVICETYPE?deleted=true&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DEVICETYPE?deleted=true&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 10, 10); + + ITUtilStructureElement.assertRead("/children/DEVICETYPE/" + uuid.toString(), 0, 0); + ITUtilStructureElement.assertRead("/children/DEVICEGROUP/" + deviceGroupUuid.toString(), -1, 1); + ITUtilStructureElement.assertRead("/children/DISCIPLINE/" + disciplineUuid.toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1999,12 +1528,7 @@ public class StructuresDeviceTypeIT { // what // read equivalence mnemonic - try { - String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/equivalence/Dt"); - ITUtil.assertResponseLength2CodeOKContent(response, "DT"); - } catch (IOException e) { - fail(); - } + ITUtilStructureElement.assertEquivalence("Dt", "DT"); } } diff --git a/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java b/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java index cee8f416..5349c447 100644 --- a/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java @@ -20,7 +20,6 @@ package org.openepics.names.docker; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.io.File; @@ -29,22 +28,15 @@ import java.net.HttpURLConnection; import java.util.UUID; import org.junit.jupiter.api.Test; -import org.openepics.names.docker.ITUtil.AuthorizationChoice; -import org.openepics.names.docker.ITUtil.EndpointChoice; import org.openepics.names.rest.beans.Status; import org.openepics.names.rest.beans.StructureElement; import org.openepics.names.rest.beans.Type; import org.openepics.names.util.EnumUtil.StructureChoice; -import org.openepics.names.util.response.Response; -import org.openepics.names.util.response.ResponseBoolean; -import org.openepics.names.util.response.ResponsePageStructureElements; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import com.fasterxml.jackson.databind.ObjectMapper; - /** * Integration tests for Naming and PostgreSQL that make use of existing dockerization * with docker-compose.yml / Dockerfile. @@ -91,57 +83,32 @@ public class StructuresDisciplineIT { // read validate create try { - ObjectMapper mapper = new ObjectMapper(); StructureElement structureElement = new StructureElement(); - String[] response = null; - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/exists/DISCIPLINE/Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE, Boolean.TRUE); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/DISCIPLINE/Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.TRUE); + ITUtilStructureElement.assertExists("Cc", Type.DISCIPLINE, Boolean.FALSE, Boolean.TRUE); + ITUtilStructureElement.assertIsValidToCreate("Cc", Type.DISCIPLINE, Boolean.TRUE); - response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "/validatecreate", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertValidate("[{asdf]", StructureChoice.CREATE, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setType(Type.DISCIPLINE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setName("name"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setMnemonic("Cc"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setDescription("description"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setComment("comment"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); @@ -150,8 +117,6 @@ public class StructuresDisciplineIT { ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); } catch (IOException e) { fail(); - } catch (InterruptedException e) { - fail(); } catch (Exception e) { fail(); } @@ -263,10 +228,10 @@ public class StructuresDisciplineIT { structureElement.setMnemonic("123456789"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - } catch (Exception e) { - fail(); - } - } + } catch (Exception e) { + fail(); + } + } @Test public void createApprove() { @@ -905,11 +870,6 @@ public class StructuresDisciplineIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement approvedStructureElement = null; @@ -926,145 +886,45 @@ public class StructuresDisciplineIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/DISCIPLINE", -1, 1); + + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha", 1, 1); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/DISCIPLINE?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?queryFields=UUID&queryValues=" + approvedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + approvedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/DISCIPLINE", -1, 1)); + + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED", -1, 1); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha", 1, 1); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/DISCIPLINE?queryFields=UUID&queryValues=" + approvedStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rsha", 1, 1); + ITUtilStructureElement.assertRead("/mnemonicpath/Rsha", 1, 1); + + ITUtilStructureElement.assertRead("/history/" + approvedStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1082,11 +942,6 @@ public class StructuresDisciplineIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement cancelledStructureElement = null; @@ -1103,145 +958,45 @@ public class StructuresDisciplineIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/DISCIPLINE", -1, 1); + + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc", 1, 1); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/DISCIPLINE?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?queryFields=UUID&queryValues=" + cancelledStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + cancelledStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/DISCIPLINE", -1, 1)); + + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED", -1, 1); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc", 1, 1); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/DISCIPLINE?queryFields=UUID&queryValues=" + cancelledStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + cancelledStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1259,11 +1014,6 @@ public class StructuresDisciplineIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement rejectedStructureElement = null; @@ -1280,145 +1030,45 @@ public class StructuresDisciplineIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLengthOne(responsePageStructureElements); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/DISCIPLINE", -1, 1); + + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr", 1, 1); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/DISCIPLINE?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?queryFields=UUID&queryValues=" + rejectedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + rejectedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/DISCIPLINE", -1, 1)); + + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED", -1, 1); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr", 1, 1); + + ITUtilStructureElement.assertRead("/DISCIPLINE?queryFields=UUID&queryValues=" + rejectedStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + rejectedStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1783,113 +1433,32 @@ public class StructuresDisciplineIT { // 60 discipline entries try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - // from first structure element assertNotNull(uuid); - // 45, not 60 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 45); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - // 20, not 35 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 20); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - // 30, not 45 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 30); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?deleted=false&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 30); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?deleted=false&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?deleted=false&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?deleted=false&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?deleted=false&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?deleted=false&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 20); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?deleted=true&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?deleted=true&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?deleted=true&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?deleted=true&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?deleted=true&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/DISCIPLINE?deleted=true&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/children/DISCIPLINE/" + uuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - } catch (IOException e) { - fail(); + ITUtilStructureElement.assertRead("/DISCIPLINE?queryFields=MNEMONIC&queryValues=A__", 45, 45); + + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 10, 10); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 20, 20); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 10, 10); + ITUtilStructureElement.assertRead("/DISCIPLINE?statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 30, 30); + + ITUtilStructureElement.assertRead("/DISCIPLINE?deleted=false&queryFields=MNEMONIC&queryValues=A__", 30, 30); + ITUtilStructureElement.assertRead("/DISCIPLINE?deleted=false&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DISCIPLINE?deleted=false&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 15, 15); + ITUtilStructureElement.assertRead("/DISCIPLINE?deleted=false&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DISCIPLINE?deleted=false&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DISCIPLINE?deleted=false&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 20, 20); + + ITUtilStructureElement.assertRead("/DISCIPLINE?deleted=true&queryFields=MNEMONIC&queryValues=A__", 15, 15); + ITUtilStructureElement.assertRead("/DISCIPLINE?deleted=true&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DISCIPLINE?deleted=true&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DISCIPLINE?deleted=true&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 0, 0); + ITUtilStructureElement.assertRead("/DISCIPLINE?deleted=true&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/DISCIPLINE?deleted=true&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 10, 10); + + ITUtilStructureElement.assertRead("/children/DISCIPLINE/" + uuid.toString(), 0, 0); } catch (Exception e) { fail(); } @@ -1903,12 +1472,7 @@ public class StructuresDisciplineIT { // what // read equivalence mnemonic - try { - String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/equivalence/Di"); - ITUtil.assertResponseLength2CodeOKContent(response, "D1"); - } catch (IOException e) { - fail(); - } + ITUtilStructureElement.assertEquivalence("Di", "D1"); } } diff --git a/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java b/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java index 0c7a15ed..65f18b81 100644 --- a/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java @@ -20,7 +20,6 @@ package org.openepics.names.docker; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.io.File; @@ -30,22 +29,15 @@ import java.util.UUID; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.openepics.names.docker.ITUtil.AuthorizationChoice; -import org.openepics.names.docker.ITUtil.EndpointChoice; import org.openepics.names.rest.beans.Status; import org.openepics.names.rest.beans.StructureElement; import org.openepics.names.rest.beans.Type; import org.openepics.names.util.EnumUtil.StructureChoice; -import org.openepics.names.util.response.Response; -import org.openepics.names.util.response.ResponseBoolean; -import org.openepics.names.util.response.ResponsePageStructureElements; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import com.fasterxml.jackson.databind.ObjectMapper; - /** * Integration tests for Naming and PostgreSQL that make use of existing dockerization * with docker-compose.yml / Dockerfile. @@ -123,84 +115,41 @@ public class StructuresSubsystemIT { // type, name, mnemonic, description, comment try { - ObjectMapper mapper = new ObjectMapper(); StructureElement structureElement = new StructureElement(); - String[] response = null; - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/exists/SUBSYSTEM/Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE, Boolean.TRUE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/SUBSYSTEM/Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/SUBSYSTEM/Sys-Sys"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/SUBSYSTEM/Sys-Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.TRUE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/SUBSYSTEM/Sg-Sys-Sg"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/SUBSYSTEM/Sg-Sys-Sys"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/SUBSYSTEM/Sg-Sys-Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.TRUE); - response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "/validatecreate", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertExists("Cc", Type.SUBSYSTEM, Boolean.FALSE, Boolean.TRUE); + ITUtilStructureElement.assertIsValidToCreate("Cc", Type.SUBSYSTEM, Boolean.FALSE); + ITUtilStructureElement.assertIsValidToCreate("Sys-Sys", Type.SUBSYSTEM, Boolean.FALSE); + ITUtilStructureElement.assertIsValidToCreate("Sys-Cc", Type.SUBSYSTEM, Boolean.TRUE); + ITUtilStructureElement.assertIsValidToCreate("Sg-Sys-Sg", Type.SUBSYSTEM, Boolean.FALSE); + ITUtilStructureElement.assertIsValidToCreate("Sg-Sys-Sys", Type.SUBSYSTEM, Boolean.FALSE); + ITUtilStructureElement.assertIsValidToCreate("Sg-Sys-Cc", Type.SUBSYSTEM, Boolean.FALSE); - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertValidate("[{asdf]", StructureChoice.CREATE, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setType(Type.SUBSYSTEM); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setParent(systemUuid); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setName("name"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setMnemonic("Cc"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setDescription("description"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setComment("comment"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); @@ -209,8 +158,6 @@ public class StructuresSubsystemIT { ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); } catch (IOException e) { fail(); - } catch (InterruptedException e) { - fail(); } catch (Exception e) { fail(); } @@ -323,10 +270,10 @@ public class StructuresSubsystemIT { structureElement.setMnemonic("123456789"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - } catch (Exception e) { - fail(); - } - } + } catch (Exception e) { + fail(); + } + } @Test public void createApprove() { @@ -977,11 +924,6 @@ public class StructuresSubsystemIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement approvedStructureElement = null; @@ -998,155 +940,47 @@ public class StructuresSubsystemIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Sg-Sys-Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/SUBSYSTEM", -1, 1); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha", 1, 1); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Sg-Sys-Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?queryFields=UUID&queryValues=" + approvedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Sg-Sys-Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + approvedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/SUBSYSTEM", -1, 1)); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED", -1, 1); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha", 1, 1); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?queryFields=UUID&queryValues=" + approvedStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rsha", 1, 1); + ITUtilStructureElement.assertRead("/mnemonicpath/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Sg-Sys-Rsha", 1, 1); + + ITUtilStructureElement.assertRead("/history/" + approvedStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1164,11 +998,6 @@ public class StructuresSubsystemIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement cancelledStructureElement = null; @@ -1185,155 +1014,47 @@ public class StructuresSubsystemIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Sg-Sys-Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/SUBSYSTEM", -1, 1); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc", 1, 1); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Sg-Sys-Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?queryFields=UUID&queryValues=" + cancelledStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Sg-Sys-Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + cancelledStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/SUBSYSTEM", -1, 1)); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED", -1, 1); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc", 1, 1); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?queryFields=UUID&queryValues=" + cancelledStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Sg-Sys-Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + cancelledStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1351,11 +1072,6 @@ public class StructuresSubsystemIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement rejectedStructureElement = null; @@ -1372,155 +1088,47 @@ public class StructuresSubsystemIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLengthOne(responsePageStructureElements); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Sg-Sys-Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/SUBSYSTEM", -1, 1); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr", 1, 1); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Sg-Sys-Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?queryFields=UUID&queryValues=" + rejectedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Sg-Sys-Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + rejectedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/SUBSYSTEM", -1, 1)); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED", -1, 1); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr", 1, 1); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?queryFields=UUID&queryValues=" + rejectedStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Sg-Sys-Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + rejectedStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1885,123 +1493,34 @@ public class StructuresSubsystemIT { // 60 subsystem entries try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - // from first structure element assertNotNull(uuid); - // 45, not 60 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 45); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - // 20, not 35 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 20); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - // 30, not 45 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 30); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?deleted=false&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 30); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?deleted=false&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?deleted=false&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?deleted=false&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?deleted=false&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?deleted=false&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 20); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?deleted=true&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?deleted=true&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?deleted=true&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?deleted=true&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?deleted=true&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SUBSYSTEM?deleted=true&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/children/SUBSYSTEM/" + uuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/children/SYSTEM/" + systemUuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/children/SYSTEMGROUP/" + systemGroupUuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + ITUtilStructureElement.assertRead("/SUBSYSTEM?queryFields=MNEMONIC&queryValues=A__", 45, 45); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 10, 10); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 20, 20); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 10, 10); + ITUtilStructureElement.assertRead("/SUBSYSTEM?statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 30, 30); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?deleted=false&queryFields=MNEMONIC&queryValues=A__", 30, 30); + ITUtilStructureElement.assertRead("/SUBSYSTEM?deleted=false&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SUBSYSTEM?deleted=false&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 15, 15); + ITUtilStructureElement.assertRead("/SUBSYSTEM?deleted=false&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SUBSYSTEM?deleted=false&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SUBSYSTEM?deleted=false&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 20, 20); + + ITUtilStructureElement.assertRead("/SUBSYSTEM?deleted=true&queryFields=MNEMONIC&queryValues=A__", 15, 15); + ITUtilStructureElement.assertRead("/SUBSYSTEM?deleted=true&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SUBSYSTEM?deleted=true&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SUBSYSTEM?deleted=true&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 0, 0); + ITUtilStructureElement.assertRead("/SUBSYSTEM?deleted=true&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SUBSYSTEM?deleted=true&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 10, 10); + + ITUtilStructureElement.assertRead("/children/SUBSYSTEM/" + uuid.toString(), 0, 0); + ITUtilStructureElement.assertRead("/children/SYSTEM/" + systemUuid.toString(), -1, 1); + ITUtilStructureElement.assertRead("/children/SYSTEMGROUP/" + systemGroupUuid.toString(), -1, 1); } catch (Exception e) { fail(); } @@ -2015,12 +1534,7 @@ public class StructuresSubsystemIT { // what // read equivalence mnemonic - try { - String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/equivalence/Sub"); - ITUtil.assertResponseLength2CodeOKContent(response, "SUB"); - } catch (IOException e) { - fail(); - } + ITUtilStructureElement.assertEquivalence("Sub", "SUB"); } } diff --git a/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java b/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java index b38a0731..b181d59f 100644 --- a/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java @@ -21,7 +21,6 @@ package org.openepics.names.docker; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.io.File; @@ -30,22 +29,15 @@ import java.net.HttpURLConnection; import java.util.UUID; import org.junit.jupiter.api.Test; -import org.openepics.names.docker.ITUtil.AuthorizationChoice; -import org.openepics.names.docker.ITUtil.EndpointChoice; import org.openepics.names.rest.beans.Status; import org.openepics.names.rest.beans.StructureElement; import org.openepics.names.rest.beans.Type; import org.openepics.names.util.EnumUtil.StructureChoice; -import org.openepics.names.util.response.Response; -import org.openepics.names.util.response.ResponseBoolean; -import org.openepics.names.util.response.ResponsePageStructureElements; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import com.fasterxml.jackson.databind.ObjectMapper; - /** * Integration tests for Naming and PostgreSQL that make use of existing dockerization * with docker-compose.yml / Dockerfile. @@ -95,59 +87,34 @@ public class StructuresSystemGroupIT { // with and without mnemonic try { - ObjectMapper mapper = new ObjectMapper(); StructureElement structureElement = new StructureElement(); - String[] response = null; - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/exists/SYSTEMGROUP/Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE, Boolean.TRUE); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/SYSTEMGROUP/Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.TRUE); + ITUtilStructureElement.assertExists("Cc", Type.SYSTEMGROUP, Boolean.FALSE, Boolean.TRUE); + ITUtilStructureElement.assertIsValidToCreate("Cc", Type.SYSTEMGROUP, Boolean.TRUE); // validate create - response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "/validatecreate", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertValidate("[{asdf]", StructureChoice.CREATE, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setType(Type.SYSTEMGROUP); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setName("name"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setMnemonic("Cc"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setDescription("description"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setComment("comment"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); @@ -162,8 +129,6 @@ public class StructuresSystemGroupIT { ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); } catch (IOException e) { fail(); - } catch (InterruptedException e) { - fail(); } catch (Exception e) { fail(); } @@ -281,10 +246,10 @@ public class StructuresSystemGroupIT { structureElement.setMnemonic("Acc"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); - } catch (Exception e) { - fail(); - } - } + } catch (Exception e) { + fail(); + } + } @Test public void createApprove() { @@ -951,11 +916,6 @@ public class StructuresSystemGroupIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement approvedStructureElement = null; @@ -972,145 +932,45 @@ public class StructuresSystemGroupIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/SYSTEMGROUP", -1, 1); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha", 1, 1); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?queryFields=UUID&queryValues=" + approvedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + approvedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/SYSTEMGROUP", -1, 1)); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha", 1, 1); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?queryFields=UUID&queryValues=" + approvedStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rsha", 1, 1); + ITUtilStructureElement.assertRead("/mnemonicpath/Rsha", 1, 1); + + ITUtilStructureElement.assertRead("/history/" + approvedStructureElement.getUuid().toString(), 1, 1); } catch (Exception e) { fail(); } @@ -1128,11 +988,6 @@ public class StructuresSystemGroupIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement cancelledStructureElement = null; @@ -1149,145 +1004,45 @@ public class StructuresSystemGroupIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/SYSTEMGROUP", -1, 1); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc", 1, 1); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?queryFields=UUID&queryValues=" + cancelledStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + cancelledStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/SYSTEMGROUP", -1, 1)); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc", 1, 1); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?queryFields=UUID&queryValues=" + cancelledStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + cancelledStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1305,11 +1060,6 @@ public class StructuresSystemGroupIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement rejectedStructureElement = null; @@ -1326,145 +1076,45 @@ public class StructuresSystemGroupIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLengthOne(responsePageStructureElements); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/SYSTEMGROUP", -1, 1); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr", 1, 1); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?queryFields=UUID&queryValues=" + rejectedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + rejectedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/SYSTEMGROUP", -1, 1)); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr", 1, 1); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?queryFields=UUID&queryValues=" + rejectedStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + rejectedStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1829,113 +1479,32 @@ public class StructuresSystemGroupIT { // 60 system group entries try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - // from first structure element assertNotNull(uuid); - // 45, not 60 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 45); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - // 20, not 35 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 20); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - // 30, not 45 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 30); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?deleted=false&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 30); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?deleted=false&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?deleted=false&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?deleted=false&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?deleted=false&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?deleted=false&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 20); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?deleted=true&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?deleted=true&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?deleted=true&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?deleted=true&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?deleted=true&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEMGROUP?deleted=true&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/children/SYSTEMGROUP/" + uuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - } catch (IOException e) { - fail(); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?queryFields=MNEMONIC&queryValues=A__", 45, 45); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 10, 10); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 20, 20); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 10, 10); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 30, 30); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?deleted=false&queryFields=MNEMONIC&queryValues=A__", 30, 30); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?deleted=false&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?deleted=false&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 15, 15); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?deleted=false&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?deleted=false&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?deleted=false&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 20, 20); + + ITUtilStructureElement.assertRead("/SYSTEMGROUP?deleted=true&queryFields=MNEMONIC&queryValues=A__", 15, 15); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?deleted=true&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?deleted=true&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?deleted=true&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?deleted=true&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEMGROUP?deleted=true&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 10, 10); + + ITUtilStructureElement.assertRead("/children/SYSTEMGROUP/" + uuid.toString(), 0, 0); } catch (Exception e) { fail(); } @@ -1949,14 +1518,7 @@ public class StructuresSystemGroupIT { // what // read equivalence mnemonic - try { - String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/equivalence/Sg"); - ITUtil.assertResponseLength2CodeOKContent(response, "SG"); - } catch (IOException e) { - fail(); - } catch (Exception e) { - fail(); - } + ITUtilStructureElement.assertEquivalence("Sg", "SG"); } } diff --git a/src/test/java/org/openepics/names/docker/StructuresSystemIT.java b/src/test/java/org/openepics/names/docker/StructuresSystemIT.java index cf24c536..7d431e23 100644 --- a/src/test/java/org/openepics/names/docker/StructuresSystemIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresSystemIT.java @@ -20,7 +20,6 @@ package org.openepics.names.docker; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.io.File; @@ -30,22 +29,15 @@ import java.util.UUID; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.openepics.names.docker.ITUtil.AuthorizationChoice; -import org.openepics.names.docker.ITUtil.EndpointChoice; import org.openepics.names.rest.beans.Status; import org.openepics.names.rest.beans.StructureElement; import org.openepics.names.rest.beans.Type; import org.openepics.names.util.EnumUtil.StructureChoice; -import org.openepics.names.util.response.Response; -import org.openepics.names.util.response.ResponseBoolean; -import org.openepics.names.util.response.ResponsePageStructureElements; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import com.fasterxml.jackson.databind.ObjectMapper; - /** * Integration tests for Naming and PostgreSQL that make use of existing dockerization * with docker-compose.yml / Dockerfile. @@ -113,80 +105,40 @@ public class StructuresSystemIT { // type, name, mnemonic, description, comment try { - ObjectMapper mapper = new ObjectMapper(); StructureElement structureElement = new StructureElement(); - String[] response = null; - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/exists/SYSTEM/Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE, Boolean.TRUE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/SYSTEM/Sg-Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.TRUE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/SYSTEM/SG-Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.TRUE); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/SYSTEM/Sg-Sg"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); + ITUtilStructureElement.assertExists("Cc", Type.SYSTEM, Boolean.FALSE, Boolean.TRUE); + ITUtilStructureElement.assertIsValidToCreate("Sg-Cc", Type.SYSTEM, Boolean.TRUE); + ITUtilStructureElement.assertIsValidToCreate("SG-Cc", Type.SYSTEM, Boolean.TRUE); + ITUtilStructureElement.assertIsValidToCreate("Sg-Sg", Type.SYSTEM, Boolean.FALSE); + ITUtilStructureElement.assertIsValidToCreate("Sg-SG", Type.SYSTEM, Boolean.FALSE); + ITUtilStructureElement.assertIsValidToCreate("Cc", Type.SYSTEM, Boolean.TRUE); - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/SYSTEM/Sg-SG"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.FALSE); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/isvalidtocreate/SYSTEM/Cc"); - ITUtil.assertResponseLength2CodeOK(response); - ITUtil.assertEqualsResponseBoolean(mapper.readValue(response[1], ResponseBoolean.class), Boolean.TRUE); - - response = ITUtil.runShellCommand(ITUtil.curlGetPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "/validatecreate", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[{asdf]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertValidate("[{asdf]", StructureChoice.CREATE, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setType(Type.SYSTEM); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setParent(systemGroupUuid); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setName("name"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setMnemonic("Cc"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setDescription("description"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - - response = ITUtil.runShellCommand(ITUtil.curlPostPathJson(AuthorizationChoice.NONE, EndpointChoice.STRUCTURES, "", "[" + mapper.writeValueAsString(structureElement) + "]")); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_BAD_REQUEST); - ITUtil.assertMessageNotEmpty(mapper.readValue(response[1], Response.class)); + ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); structureElement.setComment("comment"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); @@ -195,8 +147,6 @@ public class StructuresSystemIT { ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); } catch (IOException e) { fail(); - } catch (InterruptedException e) { - fail(); } catch (Exception e) { fail(); } @@ -308,10 +258,10 @@ public class StructuresSystemIT { structureElement.setMnemonic("123456789"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - } catch (Exception e) { - fail(); - } - } + } catch (Exception e) { + fail(); + } + } @Test public void createApprove() { @@ -962,11 +912,6 @@ public class StructuresSystemIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement approvedStructureElement = null; @@ -983,155 +928,47 @@ public class StructuresSystemIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Sg-Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/SYSTEM", -1, 1); + + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha", 1, 1); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/SYSTEM?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Sg-Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // approve approvedStructureElement = ITUtilStructureElement.assertApprove(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?queryFields=UUID&queryValues=" + approvedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Sg-Rsha"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + approvedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/SYSTEM", -1, 1)); + + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rsha", 1, 1); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rsha", 0, 0); + + ITUtilStructureElement.assertRead("/SYSTEM?queryFields=UUID&queryValues=" + approvedStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rsha", 1, 1); + ITUtilStructureElement.assertRead("/mnemonicpath/Rsha", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Sg-Rsha", 1, 1); + + ITUtilStructureElement.assertRead("/history/" + approvedStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1149,11 +986,6 @@ public class StructuresSystemIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement cancelledStructureElement = null; @@ -1170,155 +1002,47 @@ public class StructuresSystemIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Sg-Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/SYSTEM", -1, 1); + + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/SYSTEM?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Sg-Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // cancel cancelledStructureElement = ITUtilStructureElement.assertCancel(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?queryFields=UUID&queryValues=" + cancelledStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Sg-Rshc"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + cancelledStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/SYSTEM", -1, 1)); + + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshc", 1, 1); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/SYSTEM?queryFields=UUID&queryValues=" + cancelledStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshc", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Sg-Rshc", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + cancelledStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1336,11 +1060,6 @@ public class StructuresSystemIT { // create (and more) to read (with content) try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - StructureElement structureElement = null; StructureElement createdStructureElement = null; StructureElement rejectedStructureElement = null; @@ -1357,155 +1076,47 @@ public class StructuresSystemIT { structureElement = createdStructureElement; // read (1) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - length = responsePageStructureElements.getListSize(); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLengthOne(responsePageStructureElements); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Sg-Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + createdStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); + length = ITUtilStructureElement.assertRead("/SYSTEM", -1, 1); + + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr", 1, 1); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/SYSTEM?queryFields=UUID&queryValues=" + createdStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Sg-Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + createdStructureElement.getUuid().toString(), -1, 1); // reject rejectedStructureElement = ITUtilStructureElement.assertReject(structureElement); // read (2) - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertNotNull(responsePageStructureElements); - assertTrue(responsePageStructureElements.getListSize() >= 1); - assertEquals(length, responsePageStructureElements.getListSize()); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?queryFields=UUID&queryValues=" + rejectedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 1); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonic/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/mnemonicpath/Sg-Rshr"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/history/" + rejectedStructureElement.getUuid().toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + assertEquals(length, ITUtilStructureElement.assertRead("/SYSTEM", -1, 1)); + + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED", -1, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED", -1, 1); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=Rshr", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=Rshr", 1, 1); + + ITUtilStructureElement.assertRead("/SYSTEM?queryFields=UUID&queryValues=" + rejectedStructureElement.getUuid().toString(), 1, 1); + + ITUtilStructureElement.assertRead("/mnemonic/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Rshr", 0, 0); + ITUtilStructureElement.assertRead("/mnemonicpath/Sg-Rshr", 0, 0); + + ITUtilStructureElement.assertRead("/history/" + rejectedStructureElement.getUuid().toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1870,118 +1481,33 @@ public class StructuresSystemIT { // 60 system entries try { - ObjectMapper mapper = new ObjectMapper(); - String[] response = null; - - ResponsePageStructureElements responsePageStructureElements = null; - // from first structure element assertNotNull(uuid); - // 45, not 60 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 45); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - // 20, not 35 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 20); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - // 30, not 45 - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 30); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?deleted=false&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 30); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?deleted=false&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?deleted=false&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?deleted=false&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?deleted=false&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?deleted=false&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 20); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?deleted=true&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 15); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?deleted=true&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?deleted=true&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?deleted=true&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?deleted=true&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 5); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/SYSTEM?deleted=true&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__"); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 10); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/children/SYSTEM/" + uuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - ITUtilStructureElement.assertContentLength(responsePageStructureElements, 0); - - response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/children/SYSTEMGROUP/" + systemGroupUuid.toString()); - ITUtil.assertResponseLength2Code(response, HttpURLConnection.HTTP_OK); - responsePageStructureElements = mapper.readValue(response[1], ResponsePageStructureElements.class); - assertTrue(responsePageStructureElements.getListSize() >= 1); - } catch (IOException e) { - fail(); + ITUtilStructureElement.assertRead("/SYSTEM?queryFields=MNEMONIC&queryValues=A__", 45, 45); + + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 10, 10); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 20, 20); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 10, 10); + ITUtilStructureElement.assertRead("/SYSTEM?statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 30, 30); + + ITUtilStructureElement.assertRead("/SYSTEM?deleted=false&queryFields=MNEMONIC&queryValues=A__", 30, 30); + ITUtilStructureElement.assertRead("/SYSTEM?deleted=false&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEM?deleted=false&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 15, 15); + ITUtilStructureElement.assertRead("/SYSTEM?deleted=false&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEM?deleted=false&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEM?deleted=false&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 20, 20); + + ITUtilStructureElement.assertRead("/SYSTEM?deleted=true&queryFields=MNEMONIC&queryValues=A__", 15, 15); + ITUtilStructureElement.assertRead("/SYSTEM?deleted=true&statuses=PENDING&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEM?deleted=true&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEM?deleted=true&statuses=CANCELLED&queryFields=MNEMONIC&queryValues=A__", 0, 0); + ITUtilStructureElement.assertRead("/SYSTEM?deleted=true&statuses=REJECTED&queryFields=MNEMONIC&queryValues=A__", 5, 5); + ITUtilStructureElement.assertRead("/SYSTEM?deleted=true&statuses=PENDING&statuses=APPROVED&queryFields=MNEMONIC&queryValues=A__", 10, 10); + + ITUtilStructureElement.assertRead("/children/SYSTEM/" + uuid.toString(), 0, 0); + ITUtilStructureElement.assertRead("/children/SYSTEMGROUP/" + systemGroupUuid.toString(), -1, 1); } catch (Exception e) { fail(); } @@ -1995,12 +1521,7 @@ public class StructuresSystemIT { // what // read equivalence mnemonic - try { - String[] response = ITUtil.doGetJson(ITUtil.HTTP_IP_PORT_NAMING_API_V1_STRUCTURES + "/equivalence/Sys"); - ITUtil.assertResponseLength2CodeOKContent(response, "SYS"); - } catch (IOException e) { - fail(); - } + ITUtilStructureElement.assertEquivalence("Sys", "SYS"); } } -- GitLab