diff --git a/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-http/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/http/AasDiscoveryServiceHTTPSuite.java b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-http/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/http/AasDiscoveryServiceHTTPSuite.java index f97298c99..e52e7c048 100644 --- a/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-http/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/http/AasDiscoveryServiceHTTPSuite.java +++ b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-http/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/http/AasDiscoveryServiceHTTPSuite.java @@ -62,7 +62,7 @@ public void getAllAssetAdministrationShellIdsByAssetLink() throws ParseException String actualShellIds = requestAllShellIds(); - BaSyxHttpTestUtils.assertSameJSONContent(expectedShellIds, actualShellIds); + BaSyxHttpTestUtils.assertSameJSONContent(expectedShellIds, getJSONWithoutCursorInfo(actualShellIds)); } @Test @@ -142,6 +142,10 @@ protected String requestAllShellIds() throws IOException, ParseException { protected CloseableHttpResponse requestAllAssetLinks(String shellIdentifier) throws IOException, ParseException { return BaSyxHttpTestUtils.executeGetOnURL(getURL() + "/" + Base64UrlEncodedIdentifier.encodeIdentifier(shellIdentifier)); } + + private String getJSONWithoutCursorInfo(String response) throws JsonMappingException, JsonProcessingException { + return BaSyxHttpTestUtils.removeCursorFromJSON(response); + } private String getNewAssetLinksJSON() throws IOException { return BaSyxHttpTestUtils.readJSONStringFromClasspath("NewAssetLinks.json"); diff --git a/basyx.aasrepository/basyx.aasrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/http/AasRepositoryHTTPSuite.java b/basyx.aasrepository/basyx.aasrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/http/AasRepositoryHTTPSuite.java index cdab824fe..23e5ce995 100644 --- a/basyx.aasrepository/basyx.aasrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/http/AasRepositoryHTTPSuite.java +++ b/basyx.aasrepository/basyx.aasrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/http/AasRepositoryHTTPSuite.java @@ -121,7 +121,7 @@ public void getAllPaginatedAas() throws IOException, ParseException { String actualJsonFromServer = BaSyxHttpTestUtils.getResponseAsString(retrievalResponse); - BaSyxHttpTestUtils.assertSameJSONContent(getPaginatedAasJSONString(), actualJsonFromServer); + BaSyxHttpTestUtils.assertSameJSONContent(getPaginatedAasJSONString(), getJSONWithoutCursorInfo(actualJsonFromServer)); } @Test @@ -183,7 +183,9 @@ public void removeSubmodelReference() throws FileNotFoundException, IOException, CloseableHttpResponse getResponse = BaSyxHttpTestUtils.executeGetOnURL(getSpecificAasSubmodelRefAccessURL(dummyAasId)); assertEquals(200, deleteResponse.getCode()); - BaSyxHttpTestUtils.assertSameJSONContent(getSMReferenceRemovalJson(), BaSyxHttpTestUtils.getResponseAsString(getResponse)); + + String response = BaSyxHttpTestUtils.getResponseAsString(getResponse); + BaSyxHttpTestUtils.assertSameJSONContent(getSMReferenceRemovalJson(), getJSONWithoutCursorInfo(response)); } @@ -278,12 +280,16 @@ public void paginationResult() throws FileNotFoundException, IOException, ParseE CloseableHttpResponse httpResponse = BaSyxHttpTestUtils.executeGetOnURL(getURL() + "?limit=1&cursor=" + ENCODED_CURSOR); String response = BaSyxHttpTestUtils.getResponseAsString(httpResponse); - BaSyxHttpTestUtils.assertSameJSONContent(getPaginatedAas1JSONString(), response); + BaSyxHttpTestUtils.assertSameJSONContent(getPaginatedAas1JSONString(), getJSONWithoutCursorInfo(response)); } private String getPaginatedAas1JSONString() throws FileNotFoundException, IOException { return BaSyxHttpTestUtils.readJSONStringFromClasspath("PaginatedAasSimple_1.json"); } + + private String getJSONWithoutCursorInfo(String response) throws JsonMappingException, JsonProcessingException { + return BaSyxHttpTestUtils.removeCursorFromJSON(response); + } private CloseableHttpResponse updateSpecificAas(String dummyaasid, String aasJsonContent) throws IOException { return BaSyxHttpTestUtils.executePutOnURL(getSpecificAasAccessURL(dummyaasid), aasJsonContent); diff --git a/basyx.aasrepository/basyx.aasrepository-http/src/test/resources/PaginatedAasSimple_1.json b/basyx.aasrepository/basyx.aasrepository-http/src/test/resources/PaginatedAasSimple_1.json index efa29b99c..f43f94410 100644 --- a/basyx.aasrepository/basyx.aasrepository-http/src/test/resources/PaginatedAasSimple_1.json +++ b/basyx.aasrepository/basyx.aasrepository-http/src/test/resources/PaginatedAasSimple_1.json @@ -1,7 +1,5 @@ { - "paging_metadata": { - "cursor": "Y3VzdG9tSWRlbnRpZmllcg" - }, + "paging_metadata": {}, "result": [ { "modelType": "AssetAdministrationShell", diff --git a/basyx.common/basyx.http/src/test/java/org/eclipse/digitaltwin/basyx/http/serialization/BaSyxHttpTestUtils.java b/basyx.common/basyx.http/src/test/java/org/eclipse/digitaltwin/basyx/http/serialization/BaSyxHttpTestUtils.java index 7d494dd7e..bd54c3db6 100644 --- a/basyx.common/basyx.http/src/test/java/org/eclipse/digitaltwin/basyx/http/serialization/BaSyxHttpTestUtils.java +++ b/basyx.common/basyx.http/src/test/java/org/eclipse/digitaltwin/basyx/http/serialization/BaSyxHttpTestUtils.java @@ -48,7 +48,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; /** * Supports the tests working with the HTTP/REST API of AAS, Submodels, etc. @@ -58,6 +60,9 @@ */ public class BaSyxHttpTestUtils { + private static final String CURSOR = "cursor"; + private static final String PAGING_METADATA_KEY = "paging_metadata"; + /** * Reads the JSON String from a JSON file in the classpath * @@ -168,6 +173,30 @@ public static CloseableHttpResponse executePatchOnURL(String url, String content return client.execute(patchRequest); } + + /** + * Removes cursor node from the paging_metadata provided in the JSON + * + * @param inputJSON + * @return + * + * @throws JsonMappingException + * @throws JsonProcessingException + */ + public static String removeCursorFromJSON(String inputJSON) throws JsonMappingException, JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + + JsonNode rootNode = mapper.readTree(inputJSON); + + if (rootNode.has(PAGING_METADATA_KEY)) { + ObjectNode pagingMetadata = (ObjectNode) rootNode.get(PAGING_METADATA_KEY); + + if (pagingMetadata.has(CURSOR)) + pagingMetadata.remove(CURSOR); + } + + return mapper.writeValueAsString(rootNode); + } private static HttpPatch createPatchRequestWithHeader(String url, String content) { HttpPatch patchRequest = new HttpPatch(url); diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/http/ConceptDescriptionRepositoryHTTPSuite.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/http/ConceptDescriptionRepositoryHTTPSuite.java index 43b46ebb5..97036ac22 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/http/ConceptDescriptionRepositoryHTTPSuite.java +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/http/ConceptDescriptionRepositoryHTTPSuite.java @@ -66,28 +66,28 @@ public abstract class ConceptDescriptionRepositoryHTTPSuite { public void getAllConceptDescriptionsPreconfigured() throws IOException, ParseException { String conceptDescriptionsJSON = requestAllConceptDescriptions(); String expectedConceptDescriptionsJSON = getAllConceptDescriptionJSON(); - BaSyxHttpTestUtils.assertSameJSONContent(expectedConceptDescriptionsJSON, conceptDescriptionsJSON); + BaSyxHttpTestUtils.assertSameJSONContent(expectedConceptDescriptionsJSON, getJSONWithoutCursorInfo(conceptDescriptionsJSON)); } @Test public void getAllConceptDescriptionsByIdShortPreconfigured() throws IOException, ParseException { String conceptDescriptionsJSON = getAllConceptDescriptionsByIdShortJSON("ConceptDescription"); String expectedConceptDescriptionsJSON = getConceptDescriptionsWithIdShort(); - BaSyxHttpTestUtils.assertSameJSONContent(expectedConceptDescriptionsJSON, conceptDescriptionsJSON); + BaSyxHttpTestUtils.assertSameJSONContent(expectedConceptDescriptionsJSON, getJSONWithoutCursorInfo(conceptDescriptionsJSON)); } @Test public void getAllConceptDescriptionsByIsCaseOfPreconfigured() throws IOException, ParseException { String conceptDescriptionsJSON = getAllConceptDescriptionsByIsCaseOfJSON(getReferenceJSON()); String expectedConceptDescriptionsJSON = getConceptDescriptionsWithIsCaseOf(); - BaSyxHttpTestUtils.assertSameJSONContent(expectedConceptDescriptionsJSON, conceptDescriptionsJSON); + BaSyxHttpTestUtils.assertSameJSONContent(expectedConceptDescriptionsJSON, getJSONWithoutCursorInfo(conceptDescriptionsJSON)); } @Test public void getAllConceptDescriptionsByDataSpecRefPreconfigured() throws IOException, ParseException { String conceptDescriptionsJSON = getAllConceptDescriptionsByDataSpecRefJSON(getDataSpecReferenceJSON()); String expectedConceptDescriptionsJSON = getAllConceptDescriptionsWithDataSpecRef(); - BaSyxHttpTestUtils.assertSameJSONContent(expectedConceptDescriptionsJSON, conceptDescriptionsJSON); + BaSyxHttpTestUtils.assertSameJSONContent(expectedConceptDescriptionsJSON, getJSONWithoutCursorInfo(conceptDescriptionsJSON)); } @Test @@ -190,7 +190,7 @@ public void paginatedResult() throws ParseException, IOException { String expectedDescriptionJSON = getConceptDescriptionsWithDataSpecRefWithPagination(); - BaSyxHttpTestUtils.assertSameJSONContent(expectedDescriptionJSON, actualConceptDescriptionsJSON); + BaSyxHttpTestUtils.assertSameJSONContent(expectedDescriptionJSON, getJSONWithoutCursorInfo(actualConceptDescriptionsJSON)); } @Test @@ -199,6 +199,10 @@ public void deleteNonExistingConceptDescription() throws IOException { assertEquals(HttpStatus.NOT_FOUND.value(), deletionResponse.getCode()); } + + private String getJSONWithoutCursorInfo(String response) throws JsonMappingException, JsonProcessingException { + return BaSyxHttpTestUtils.removeCursorFromJSON(response); + } private void assertConceptDescriptionCreationReponse(String conceptDescriptionJSON, CloseableHttpResponse creationResponse) throws IOException, ParseException, JsonProcessingException, JsonMappingException { assertEquals(HttpStatus.CREATED.value(), creationResponse.getCode()); diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/resources/ConceptDescriptionWithDataSpecWithPagination.json b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/resources/ConceptDescriptionWithDataSpecWithPagination.json index 23b19ee16..dfbcee15f 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/resources/ConceptDescriptionWithDataSpecWithPagination.json +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/resources/ConceptDescriptionWithDataSpecWithPagination.json @@ -1,6 +1,5 @@ { "paging_metadata": { - "cursor": "N0E3MTA0SUhUUkVGTjQzMjI" }, "result": [ { diff --git a/basyx.submodelrepository/basyx.submodelrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/SubmodelRepositorySubmodelHTTPTestSuite.java b/basyx.submodelrepository/basyx.submodelrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/SubmodelRepositorySubmodelHTTPTestSuite.java index fc7952862..c7cd4e3bd 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/SubmodelRepositorySubmodelHTTPTestSuite.java +++ b/basyx.submodelrepository/basyx.submodelrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/SubmodelRepositorySubmodelHTTPTestSuite.java @@ -83,7 +83,8 @@ public abstract class SubmodelRepositorySubmodelHTTPTestSuite { public void getAllSubmodelsPreconfigured() throws IOException, ParseException { String submodelsJSON = BaSyxSubmodelHttpTestUtils.requestAllSubmodels(getURL()); String expectedSubmodelsJSON = getAllSubmodelJSON(); - BaSyxHttpTestUtils.assertSameJSONContent(expectedSubmodelsJSON, submodelsJSON); + + BaSyxHttpTestUtils.assertSameJSONContent(expectedSubmodelsJSON,getJSONWithoutCursorInfo(submodelsJSON)); } @Test @@ -187,7 +188,7 @@ public void getPaginatedSubmodel() throws ParseException, IOException { .requestAllSubmodels(getURL() + "?limit=1&cursor=" + ENCODED_CURSOR); String expected = getSubmodelsPaginatedJson(); - BaSyxHttpTestUtils.assertSameJSONContent(expected, submodelsJSON); + BaSyxHttpTestUtils.assertSameJSONContent(expected, getJSONWithoutCursorInfo(submodelsJSON)); } @Test @@ -269,6 +270,10 @@ public void getFileFromNotExistElement() throws FileNotFoundException, Unsupport assertEquals(HttpStatus.NOT_FOUND.value(), response.getCode()); } + + private String getJSONWithoutCursorInfo(String response) throws JsonMappingException, JsonProcessingException { + return BaSyxHttpTestUtils.removeCursorFromJSON(response); + } private String createSMEFileDeleteURL(String submodelId, String submodelElementIdShort) { return BaSyxSubmodelHttpTestUtils.getSpecificSubmodelAccessPath(getURL(), submodelId) + "/submodel-elements/" + submodelElementIdShort + "/attachment"; diff --git a/basyx.submodelrepository/basyx.submodelrepository-http/src/test/resources/SubmodelsPaginated.json b/basyx.submodelrepository/basyx.submodelrepository-http/src/test/resources/SubmodelsPaginated.json index 6fea7de5e..8802a50b3 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-http/src/test/resources/SubmodelsPaginated.json +++ b/basyx.submodelrepository/basyx.submodelrepository-http/src/test/resources/SubmodelsPaginated.json @@ -1,6 +1,5 @@ { "paging_metadata": { - "cursor": "OEE2MzQ0QkRBQjU3RTE4NA" }, "result": [{ "id": "8A6344BDAB57E184", diff --git a/basyx.submodelservice/basyx.submodelservice-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/http/SubmodelServiceSubmodelElementsTestSuiteHTTP.java b/basyx.submodelservice/basyx.submodelservice-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/http/SubmodelServiceSubmodelElementsTestSuiteHTTP.java index 8d0bdfff9..a05f013d6 100644 --- a/basyx.submodelservice/basyx.submodelservice-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/http/SubmodelServiceSubmodelElementsTestSuiteHTTP.java +++ b/basyx.submodelservice/basyx.submodelservice-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/http/SubmodelServiceSubmodelElementsTestSuiteHTTP.java @@ -66,7 +66,7 @@ public void getSubmodelElements() throws FileNotFoundException, IOException, Par String requestedSubmodelElements = requestSubmodelElementsJSON(); String submodelElementJSON = getSubmodelElementsJSON(); - BaSyxHttpTestUtils.assertSameJSONContent(submodelElementJSON, requestedSubmodelElements); + BaSyxHttpTestUtils.assertSameJSONContent(submodelElementJSON, getJSONWithoutCursorInfo(requestedSubmodelElements)); } @Test @@ -74,7 +74,7 @@ public void getPaginatedSubmodelElements() throws FileNotFoundException, IOExcep String actualPaginatedSubmodelElements = requestPaginatedSubmodelElementsJSON(); String expectedPaginatedSubmodelElementJSON = getPaginatedSubmodelElementsJSON(); - BaSyxHttpTestUtils.assertSameJSONContent(expectedPaginatedSubmodelElementJSON, actualPaginatedSubmodelElements); + BaSyxHttpTestUtils.assertSameJSONContent(expectedPaginatedSubmodelElementJSON, getJSONWithoutCursorInfo(actualPaginatedSubmodelElements)); } @Test @@ -453,6 +453,10 @@ public void invokeOperation() throws FileNotFoundException, IOException, ParseEx BaSyxHttpTestUtils.assertSameJSONContent(expectedValue, BaSyxHttpTestUtils.getResponseAsString(response)); } + + private String getJSONWithoutCursorInfo(String response) throws JsonMappingException, JsonProcessingException { + return BaSyxHttpTestUtils.removeCursorFromJSON(response); + } private CloseableHttpResponse requestOperationInvocation(String operationId, String parameters) throws IOException { return BaSyxHttpTestUtils.executePostOnURL(createSpecificSubmodelElementURL(operationId) + "/invoke", parameters); diff --git a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/SubmodelElementsPaginated.json b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/SubmodelElementsPaginated.json index 2b58e8e58..88c35a6ee 100644 --- a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/SubmodelElementsPaginated.json +++ b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/SubmodelElementsPaginated.json @@ -1,6 +1,5 @@ { "paging_metadata": { - "cursor": "U2ltcGxlTGlzdA" }, "result": [ {