diff --git a/pom.xml b/pom.xml index d3ce2f5e9fb99390d6dbefcf0311794dce5078c9..26c9d3977b146292deed3c899f542c1b1e392380 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- OSDU Versions--> - <os-core-common.version>3.3.1</os-core-common.version> + <os-core-common.version>3.4.1</os-core-common.version> <!-- Spring Versions--> <spring-boot.version>3.3.7</spring-boot.version> diff --git a/storage-acceptance-test/src/test/java/org/opengroup/osdu/storage/query/PostFetchRecordsIntegrationTests.java b/storage-acceptance-test/src/test/java/org/opengroup/osdu/storage/query/PostFetchRecordsIntegrationTests.java index 56c47c1b054f5b31d43a415bfa2d4522cd0125dd..95df9e7e5eba4c89ef19552dab5ba23e4d42bb32 100644 --- a/storage-acceptance-test/src/test/java/org/opengroup/osdu/storage/query/PostFetchRecordsIntegrationTests.java +++ b/storage-acceptance-test/src/test/java/org/opengroup/osdu/storage/query/PostFetchRecordsIntegrationTests.java @@ -41,6 +41,7 @@ import org.opengroup.osdu.storage.util.TokenTestUtils; public final class PostFetchRecordsIntegrationTests extends TestBase { + private static final long NOW = System.currentTimeMillis(); private static final String RECORD_ID_PREFIX = TenantUtils.getFirstTenantName() + ":query:"; @@ -54,9 +55,12 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { private static final String DATETIME_PERSISTABLE_REFERENCE = "{\"type\":\"DAT\",\"format\":\"YYYY-MM-DD\"}"; private static final String UNIT_PERSISTABLE_REFERENCE = "{\"abcd\":{\"a\":0.0,\"b\":0.3048,\"c\":1.0,\"d\":0.0},\"symbol\":\"ft\",\"baseMeasurement\":{\"ancestry\":\"L\",\"type\":\"UM\"},\"type\":\"UAD\"}"; private static final String UNIT_OF_MEASURE_ID = String.format("%s:reference-data--UnitOfMeasure:ft:", TenantUtils.getTenantName()); + private static final String FRAME_OF_REFERENCE_NAME = "frame-of-reference"; + private static final String FRAME_OF_REFERENCE_VAL = "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"; private static final TokenTestUtils TOKEN_TEST_UTILS = new TokenTestUtils(); + @BeforeAll public static void classSetup() throws Exception { PostFetchRecordsIntegrationTests.classSetup(TOKEN_TEST_UTILS.getToken()); @@ -101,7 +105,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "none"); + headers.put(FRAME_OF_REFERENCE_NAME, "none"); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(), ""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -137,7 +141,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "none"); + headers.put(FRAME_OF_REFERENCE_NAME, "none"); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(), ""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -172,14 +176,13 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "none"); + headers.put(FRAME_OF_REFERENCE_NAME, "none"); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(), ""); assertEquals(HttpStatus.SC_BAD_REQUEST, response.getCode()); } @Test - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test public void should_returnConvertedRecords_whenConversionRequiredAndNoError() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); String jsonInput = RecordUtil.createJsonRecordWithReference(2, recordId, KIND, LEGAL_TAG, PERSISTABLE_REFERENCE, "CRS"); @@ -194,7 +197,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(), ""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -215,7 +218,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnConvertedRecords_whenConversionRequiredAndNoErrorWithMultiplePairOfCoordinates() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -231,7 +233,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(), ""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -251,7 +253,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnOriginalRecordsAndConversionStatusAsNoMeta_whenConversionRequiredAndNoMetaBlockInRecord() throws Exception{ String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -268,7 +269,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(), ""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -304,7 +305,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(), ""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -327,7 +328,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { } @Test - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test public void should_returnRecordsAndConversionStatus_whenConversionRequiredAndNestedPropertyProvidedInMetaBlock() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); String jsonInput = RecordUtil.createJsonRecordWithNestedProperty(1, recordId, KIND, LEGAL_TAG, PERSISTABLE_REFERENCE, "CRS"); @@ -341,7 +341,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(), ""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -357,7 +357,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { CloseableHttpResponse deleteResponse = TestUtils.send("records/" + recordId + 0, "DELETE", HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()), "", ""); assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse.getCode()); } - //@Ignore // Ignoring the test for now, once we have CRS converter we should enable this test + @Test public void should_returnRecordsAndConversionStatus_whenConversionRequiredAndNestedPropertyProvidedInMetaBlock1() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -372,7 +372,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(), ""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -402,7 +402,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -418,7 +418,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnRecordsAndConversionStatus_whenNestedArrayOfPropertiesProvidedWithoutError() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -434,7 +433,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -456,7 +455,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnRecordsAndConversionStatus_whenNestedArrayOfPropertiesProvidedWithInvalidValues() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -471,7 +469,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -491,7 +489,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnRecordsAndConversionStatus_whenInhomogeneousNestedArrayOfPropertiesProvidedWithoutError() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -506,7 +503,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -525,7 +522,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnRecordsAndConversionStatus_whenInhomogeneousNestedArrayOfPropertiesProvidedWithInvalidValues() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -540,7 +536,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -560,7 +556,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnRecordsAndConversionStatus_whenInhomogeneousNestedArrayOfPropertiesProvidedWithIndexOutOfBoundary() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -575,7 +570,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -595,7 +590,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnRecordsAfterCrsConversion__whenProvidedRecordWithAsIngestedCoordinatesBlockTypePoint() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -610,7 +604,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -628,7 +622,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse1.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnRecordsAfterCrsConversion__whenProvidedRecordWithAsIngestedCoordinatesBlockTypeMultiPoint() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -643,7 +636,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -661,7 +654,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse1.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnRecordsAfterCrsConversion__whenProvidedRecordWithAsIngestedCoordinatesBlockTypePolygon() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -676,7 +668,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -694,7 +686,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse1.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnRecordsAfterCrsConversion__whenProvidedRecordWithAsIngestedCoordinatesBlockTypeMultiPolygon() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -709,7 +700,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -727,7 +718,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse1.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnRecordsAfterCrsConversion__whenProvidedRecordWithAsIngestedCoordinatesBlockTypeLineString() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -742,7 +732,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -760,7 +750,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse1.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnRecordsAfterCrsConversion__whenProvidedRecordWithAsIngestedCoordinatesBlockTypeMultiLineString() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -775,7 +764,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -793,7 +782,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse1.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnRecordsAfterCrsConversion__whenProvidedRecordWithAsIngestedCoordinatesBlockTypeGeometryCollection() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -808,7 +796,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -826,7 +814,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse1.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnConvertedRecords_whenConversionRequiredWithAsIngestedCoordinatesBlockWithError() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -841,7 +828,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -859,7 +846,6 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse1.getCode()); } - // @Ignore // Ignoring the test for now, once we have CRS converter we should enable this test @Test public void should_returnConvertedRecords_whenConversionNotRequiredWithAsIngestedCoordinatesAndWgs84CoordinatesBlocks() throws Exception { String recordId = RECORD_ID_PREFIX + UUID.randomUUID().toString(); @@ -874,7 +860,7 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { body.add("records", records); Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); - headers.put("frame-of-reference", "units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;"); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); assertEquals(HttpStatus.SC_OK, response.getCode()); @@ -891,4 +877,37 @@ public final class PostFetchRecordsIntegrationTests extends TestBase { CloseableHttpResponse deleteResponse1 = TestUtils.send("records/" + recordId + 0, "DELETE", HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()), "", ""); assertEquals(HttpStatus.SC_NO_CONTENT, deleteResponse1.getCode()); } + + @Test + public void should_returnConvertedRecord_withPrimitiveArrayAndConfiguredUnitOfMeasure() throws Exception { + String recordId = RECORD_ID_PREFIX + UUID.randomUUID(); + String jsonInput = RecordUtil.createJsonRecordForUnitConversionWithPrimitiveArray( + recordId, + KIND, + LEGAL_TAG, + UNIT_OF_MEASURE_ID, + "records/primitive-array-unit-conversion.json" + ); + CloseableHttpResponse createResponse = TestUtils.send( + "records", + "PUT", + HeaderUtils.getHeaders(TenantUtils.getTenantName(), + testUtils.getToken()), + jsonInput, + "" + ); + assertEquals(HttpStatus.SC_CREATED, createResponse.getCode()); + JsonArray records = new JsonArray(); + records.add(recordId); + JsonObject body = new JsonObject(); + body.add("records", records); + Map<String, String> headers = HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()); + headers.put(FRAME_OF_REFERENCE_NAME, FRAME_OF_REFERENCE_VAL); + CloseableHttpResponse response = TestUtils.send("query/records:batch", "POST", headers, body.toString(),""); + assertEquals(HttpStatus.SC_OK, response.getCode()); + + DummyRecordsHelper.ConvertedRecordsMock responseObject = RECORDS_HELPER.getConvertedRecordsMockFromResponse(response); + assertEquals(1, responseObject.conversionStatuses.size()); + assertEquals("SUCCESS", responseObject.conversionStatuses.get(0).status); + } } diff --git a/storage-acceptance-test/src/test/java/org/opengroup/osdu/storage/util/FileReadUtil.java b/storage-acceptance-test/src/test/java/org/opengroup/osdu/storage/util/FileReadUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..8a0fc3e80a3ee8145251f00f115299ec850fe66c --- /dev/null +++ b/storage-acceptance-test/src/test/java/org/opengroup/osdu/storage/util/FileReadUtil.java @@ -0,0 +1,35 @@ +/* + * Copyright 2020-2025 Google LLC + * Copyright 2020-2025 EPAM Systems, Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.storage.util; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +public class FileReadUtil { + + private static Gson gson = new Gson(); + + public static JsonObject readRecordFromFile(String filename) { + InputStream file = FileReadUtil.class.getClassLoader().getResourceAsStream(filename); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(file)); + return gson.fromJson(bufferedReader, JsonObject.class); + } +} diff --git a/storage-acceptance-test/src/test/java/org/opengroup/osdu/storage/util/RecordUtil.java b/storage-acceptance-test/src/test/java/org/opengroup/osdu/storage/util/RecordUtil.java index bcf1875d1f246105c648d5244a49a742b2a0391f..a4484cdf0de274f26f3a628f2a648550c461f00a 100644 --- a/storage-acceptance-test/src/test/java/org/opengroup/osdu/storage/util/RecordUtil.java +++ b/storage-acceptance-test/src/test/java/org/opengroup/osdu/storage/util/RecordUtil.java @@ -72,6 +72,17 @@ public class RecordUtil { return records.toString(); } + public static String createJsonRecordForUnitConversionWithPrimitiveArray(String id, String kind, String legalTag, String unitOfMeasureId, String fileName){ + JsonObject defaultRecord = getDefaultRecord(id, kind, legalTag); + JsonObject recordObject = FileReadUtil.readRecordFromFile(fileName); + recordObject.get("meta").getAsJsonArray().get(0).getAsJsonObject().addProperty(UNIT_OF_MEASURE_ID, unitOfMeasureId); + defaultRecord.add("data", recordObject.get("data")); + defaultRecord.add("meta", recordObject.get("meta")); + JsonArray records = new JsonArray(); + records.add(defaultRecord); + return records.toString(); + } + public static String createJsonRecordWithEntV2OnlyAcl(String id, String kind, String legalTag, String data) { JsonObject dataJson = new JsonObject(); dataJson.addProperty("custom", data); diff --git a/storage-acceptance-test/src/test/resources/records/primitive-array-unit-conversion.json b/storage-acceptance-test/src/test/resources/records/primitive-array-unit-conversion.json new file mode 100644 index 0000000000000000000000000000000000000000..7ab602c6b7f143eda0aac7331b1d72c09153e735 --- /dev/null +++ b/storage-acceptance-test/src/test/resources/records/primitive-array-unit-conversion.json @@ -0,0 +1,19 @@ +{ + "meta": [ + { + "kind": "Unit", + "name": "ft", + "persistableReference": "{\"abcd\":{\"a\":0.0,\"b\":0.001,\"c\":1.0,\"d\":0.0},\"symbol\":\"ft\",\"baseMeasurement\":{\"ancestry\":\"L\",\"type\":\"UM\"},\"type\":\"UAD\"}", + "propertyNames": [ + "GrainSizes[]" + ] + } + ], + "data": { + "GrainSizes": [ + 1, + 2, + 3 + ] + } +}