diff --git a/here-naksha-app-service/src/test/java/com/here/naksha/app/service/NakshaAppTest.java b/here-naksha-app-service/src/test/java/com/here/naksha/app/service/NakshaAppTest.java index 52cb19861..d0d07b956 100644 --- a/here-naksha-app-service/src/test/java/com/here/naksha/app/service/NakshaAppTest.java +++ b/here-naksha-app-service/src/test/java/com/here/naksha/app/service/NakshaAppTest.java @@ -849,10 +849,10 @@ void tc0501_testUpdateFeatureById() throws Exception { HttpResponse response; // Read request body - final String bodyJson = loadFileOrFail("TC0501_updateOneFeatureById/update_request.json"); + final String bodyJson = loadFileOrFail("TC0501_updateOneFeatureById/update_request_and_response.json"); // TODO: include geometry after Cursor-related changes -> final Space space = parseJsonFileOrFail("TC0300_createFeaturesWithNewIds/create_space.json", Space.class); - final String expectedBodyPart = loadFileOrFail("TC0501_updateOneFeatureById/response.json"); + final String expectedBodyPart = bodyJson; streamId = UUID.randomUUID().toString(); // When: Create Features request is submitted to NakshaHub Space Storage instance @@ -873,6 +873,39 @@ void tc0501_testUpdateFeatureById() throws Exception { assertEquals(streamId, getHeader(response, HDR_STREAM_ID), "StreamId mismatch"); } + @Test + @Order(11) + void tc0502_testUpdateFeatureByWrongUriId() throws Exception { + // Test API : PUT /hub/spaces/{spaceId}/features/{featureId} + String streamId; + HttpRequest request; + HttpResponse response; + + // Read request body + final String bodyJson = loadFileOrFail("TC0502_updateFeatureWithWrongUriId/request.json"); + // TODO: include geometry after Cursor-related changes -> + final Space space = parseJsonFileOrFail("TC0300_createFeaturesWithNewIds/create_space.json", Space.class); + final String expectedBodyPart = loadFileOrFail("TC0502_updateFeatureWithWrongUriId/response.json"); + streamId = UUID.randomUUID().toString(); + + // When: Create Features request is submitted to NakshaHub Space Storage instance + request = HttpRequest.newBuilder(stdHttpRequest, (k, v) -> true) + .uri(new URI(NAKSHA_HTTP_URI + "hub/spaces/" + space.getId() + "/features/wrong-id")) + .PUT(HttpRequest.BodyPublishers.ofString(bodyJson)) + .header(HDR_STREAM_ID, streamId) + .build(); + response = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); + + // Then: Perform assertions + assertEquals(409, response.statusCode(), "ResCode mismatch"); + JSONAssert.assertEquals( + "Update Feature error response doesn't match", + expectedBodyPart, + response.body(), + JSONCompareMode.LENIENT); + assertEquals(streamId, getHeader(response, HDR_STREAM_ID), "StreamId mismatch"); + } + @AfterAll static void close() throws InterruptedException { if (app != null) { diff --git a/here-naksha-app-service/src/test/resources/unit_test_data/TC0501_updateOneFeatureById/response.json b/here-naksha-app-service/src/test/resources/unit_test_data/TC0501_updateOneFeatureById/update_request_and_response.json similarity index 100% rename from here-naksha-app-service/src/test/resources/unit_test_data/TC0501_updateOneFeatureById/response.json rename to here-naksha-app-service/src/test/resources/unit_test_data/TC0501_updateOneFeatureById/update_request_and_response.json diff --git a/here-naksha-app-service/src/test/resources/unit_test_data/TC0501_updateOneFeatureById/update_request.json b/here-naksha-app-service/src/test/resources/unit_test_data/TC0502_updateFeatureWithWrongUriId/request.json similarity index 69% rename from here-naksha-app-service/src/test/resources/unit_test_data/TC0501_updateOneFeatureById/update_request.json rename to here-naksha-app-service/src/test/resources/unit_test_data/TC0502_updateFeatureWithWrongUriId/request.json index d63312d9b..2b543f72e 100644 --- a/here-naksha-app-service/src/test/resources/unit_test_data/TC0501_updateOneFeatureById/update_request.json +++ b/here-naksha-app-service/src/test/resources/unit_test_data/TC0502_updateFeatureWithWrongUriId/request.json @@ -1,5 +1,5 @@ { - "id": "my-custom-id-301-1", + "id": "wrong-id", "type": "Feature", "properties": { "speedLimit": "30" diff --git a/here-naksha-app-service/src/test/resources/unit_test_data/TC0502_updateFeatureWithWrongUriId/response.json b/here-naksha-app-service/src/test/resources/unit_test_data/TC0502_updateFeatureWithWrongUriId/response.json new file mode 100644 index 000000000..a4eb75c5c --- /dev/null +++ b/here-naksha-app-service/src/test/resources/unit_test_data/TC0502_updateFeatureWithWrongUriId/response.json @@ -0,0 +1,5 @@ +{ + "type": "ErrorResponse", + "error": "Conflict", + "errorMessage": "No feature found for id wrong-id" +}