diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6e8b968d92..ac6878f459 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -145,7 +145,7 @@ jobs: if: ${{ !inputs.skipPublish }} env: QUARKUS_APPLICATION_NAME: 'Astra DB JSON API' - QUARKUS_SMALLRYE_OPENAPI_INFO_DESCRIPTION: 'The Astra DB JSON API modifies and queries data stored as unstructured JSON documents in collections. See the [documentation site](https://docs.datastax.com/en/astra-serverless/docs/develop/dev-with-doc.html) for additional information.' + QUARKUS_SMALLRYE_OPENAPI_INFO_DESCRIPTION: 'The Astra DB JSON API modifies and queries data stored as unstructured JSON documents in collections. See the [documentation site](https://documents.datastax.com/en/astra-serverless/documents/develop/dev-with-doc.html) for additional information.' QUARKUS_SMALLRYE_OPENAPI_INFO_TERMS_OF_SERVICE: 'https://www.datastax.com/legal' QUARKUS_SMALLRYE_OPENAPI_INFO_CONTACT_NAME: 'DataStax' QUARKUS_SMALLRYE_OPENAPI_INFO_CONTACT_URL: 'https://www.datastax.com/contact-us' diff --git a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/CommandResult.java b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/CommandResult.java index 161a7f0a3c..5b9558de6a 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/CommandResult.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/CommandResult.java @@ -1,6 +1,7 @@ package io.stargate.sgv2.jsonapi.api.model.command; import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.JsonNode; import java.util.Collections; @@ -26,7 +27,8 @@ public record CommandResult( @Schema( description = "A response data holding documents that were returned as the result of a command.", - nullable = true) + nullable = true, + oneOf = {CommandResult.MultiResponseData.class, CommandResult.SingleResponseData.class}) ResponseData data, @Schema( description = @@ -45,18 +47,18 @@ public record CommandResult( @Schema(nullable = true) List errors) { /** - * Constructor for only specifying the {@link ResponseData}. + * Constructor for only specifying the {@link MultiResponseData}. * - * @param responseData {@link ResponseData} + * @param responseData {@link MultiResponseData} */ public CommandResult(ResponseData responseData) { this(responseData, null, null); } /** - * Constructor for specifying the {@link ResponseData} and statuses. + * Constructor for specifying the {@link MultiResponseData} and statuses. * - * @param responseData {@link ResponseData} + * @param responseData {@link MultiResponseData} * @param status Map of status information. */ public CommandResult(ResponseData responseData, Map status) { @@ -81,30 +83,62 @@ public CommandResult(List errors) { this(null, null, errors); } + public interface ResponseData { + + @JsonIgnore + List documents(); + } + + /** + * Response data object that's included in the {@link CommandResult}, for a single document + * responses. + * + * @param document Document. + */ + @Schema(description = "Response data for a single document commands.") + public record SingleResponseData( + @NotNull + @Schema( + description = "Document that resulted from a command.", + type = SchemaType.OBJECT, + implementation = Object.class) + JsonNode document) + implements ResponseData { + + @JsonIgnore + @Override + public List documents() { + return List.of(document); + } + } + /** - * Response data object that's included in the {@link CommandResult}. + * Response data object that's included in the {@link CommandResult}, for multi document + * responses. * - * @param docs Documents. + * @param documents Documents. * @param nextPageState Optional next paging state. */ - public record ResponseData( + @Schema(description = "Response data for multiple documents commands.") + public record MultiResponseData( @NotNull @Schema( description = "Documents that resulted from a command.", type = SchemaType.ARRAY, implementation = Object.class, minItems = 0) - List docs, + List documents, @Schema(description = "Next page state for pagination.", nullable = true) - String nextPageState) { + String nextPageState) + implements ResponseData { /** * Constructor that sets documents without next paging state. * - * @param docs Documents, must not be null. + * @param documents Documents, must not be null. */ - public ResponseData(List docs) { - this(docs, null); + public MultiResponseData(List documents) { + this(documents, null); } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/IncOperation.java b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/IncOperation.java index 53807a0d2c..68070f1ddb 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/IncOperation.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/IncOperation.java @@ -14,7 +14,7 @@ /** * Implementation of {@code $inc} update operation used to modify numeric field values in documents. - * See {@href https://www.mongodb.com/docs/manual/reference/operator/update/inc/} for full + * See {@href https://www.mongodb.com/documents/manual/reference/operator/update/inc/} for full * explanation. */ public class IncOperation extends UpdateOperation { diff --git a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/MinMaxOperation.java b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/MinMaxOperation.java index 96d62aa89e..3981c24623 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/MinMaxOperation.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/MinMaxOperation.java @@ -13,8 +13,8 @@ /** * Implementation of {@code $min} and {@code $max} update operation used to modify numeric field * values in documents. See {@href - * https://www.mongodb.com/docs/manual/reference/operator/update/min/} and {@href - * https://www.mongodb.com/docs/manual/reference/operator/update/max/} for full explanations. + * https://www.mongodb.com/documents/manual/reference/operator/update/min/} and {@href + * https://www.mongodb.com/documents/manual/reference/operator/update/max/} for full explanations. */ public class MinMaxOperation extends UpdateOperation { private final boolean isMaxAction; diff --git a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/MulOperation.java b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/MulOperation.java index a387bd6e2e..ab26c4c5f1 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/MulOperation.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/MulOperation.java @@ -15,7 +15,7 @@ /** * Implementation of {@code $mul} update operation used to modify numeric field values in documents. - * See {@href https://www.mongodb.com/docs/manual/reference/operator/update/mul/} for full + * See {@href https://www.mongodb.com/documents/manual/reference/operator/update/mul/} for full * explanation. */ public class MulOperation extends UpdateOperation { diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/DeleteOperationPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/DeleteOperationPage.java index 44ef1b37c7..d1f636e332 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/DeleteOperationPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/DeleteOperationPage.java @@ -73,12 +73,12 @@ public CommandResult get() { if (moreData) return new CommandResult( - deletedDoc.isEmpty() ? null : new CommandResult.ResponseData(deletedDoc), + deletedDoc.isEmpty() ? null : new CommandResult.MultiResponseData(deletedDoc), Map.of(CommandStatus.DELETED_COUNT, deletedCount, CommandStatus.MORE_DATA, true), errors.isEmpty() ? null : errors); else return new CommandResult( - deletedDoc.isEmpty() ? null : new CommandResult.ResponseData(deletedDoc), + deletedDoc.isEmpty() ? null : new CommandResult.MultiResponseData(deletedDoc), Map.of(CommandStatus.DELETED_COUNT, deletedCount), errors.isEmpty() ? null : errors); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/ReadOperationPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/ReadOperationPage.java index 4f30880545..505ed140b5 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/ReadOperationPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/ReadOperationPage.java @@ -13,8 +13,8 @@ public record ReadOperationPage(List docs, String pagingState) public CommandResult get() { final List jsonNodes = new ArrayList<>(); docs.stream().forEach(doc -> jsonNodes.add(doc.document())); - final CommandResult.ResponseData responseData = - new CommandResult.ResponseData(jsonNodes, pagingState); + final CommandResult.MultiResponseData responseData = + new CommandResult.MultiResponseData(jsonNodes, pagingState); return new CommandResult(responseData); } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/UpdateOperationPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/UpdateOperationPage.java index 3112f74b2b..b0925a70f2 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/UpdateOperationPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/UpdateOperationPage.java @@ -64,7 +64,7 @@ public CommandResult get() { if (moreDataFlag) updateStatus.put(CommandStatus.MORE_DATA, moreDataFlag); if (returnDocs) { return new CommandResult( - new CommandResult.ResponseData(updatedDocs), + new CommandResult.MultiResponseData(updatedDocs), updateStatus, errors.isEmpty() ? null : errors); } else { diff --git a/src/main/java/io/stargate/sgv2/jsonapi/util/JsonUtil.java b/src/main/java/io/stargate/sgv2/jsonapi/util/JsonUtil.java index cc2f0999ff..ecba485f5b 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/util/JsonUtil.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/util/JsonUtil.java @@ -82,7 +82,7 @@ public static boolean looksLikeEJsonValue(JsonNode json) { /** * Helper method that will see if given {@link JsonNode} is an EJSON-encoded "Date" (aka * Timestamp) value and if so, constructs and returns matching {@link java.util.Date} value. See - * {@href https://docs.meteor.com/api/ejson.html} for details on encoded value. + * {@href https://documents.meteor.com/api/ejson.html} for details on encoded value. * * @param json JSON value to check * @return Date extracted, if given valid EJSON-encoded Date value; or {@code null} if not diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DeleteManyIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DeleteManyIntegrationTest.java index adb0d404da..19282a6459 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DeleteManyIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DeleteManyIntegrationTest.java @@ -101,7 +101,7 @@ public void byId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals("[]")) + .body("data.documents", jsonEquals("[]")) .body("status", is(nullValue())) .body("errors", is(nullValue())); @@ -123,7 +123,7 @@ public void byId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]._id", is("doc2")) + .body("data.documents[0]._id", is("doc2")) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -198,7 +198,7 @@ public void byColumn() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals("[]")) + .body("data.documents", jsonEquals("[]")) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -243,7 +243,7 @@ public void noFilter() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals("[]")) + .body("data.documents", jsonEquals("[]")) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -288,7 +288,7 @@ public void noFilterMoreDataFlag() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(5)) + .body("data.documents", hasSize(5)) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -299,7 +299,7 @@ class Concurrency { @RepeatedTest(10) public void concurrentDeletes() throws Exception { - // with 10 docs + // with 10 documents int totalDocuments = 10; String document = @@ -392,7 +392,7 @@ public void concurrentDeletes() throws Exception { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())); + .body("data.documents", is(empty())); } } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DeleteOneIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DeleteOneIntegrationTest.java index 099057cdf4..844ee5a7d0 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DeleteOneIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DeleteOneIntegrationTest.java @@ -90,7 +90,7 @@ public void byId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals("[]")) + .body("data.documents", jsonEquals("[]")) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -183,7 +183,7 @@ public void byColumn() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals("[]")) + .body("data.documents", jsonEquals("[]")) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -251,7 +251,7 @@ public void noFilter() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals("[]")) + .body("data.documents", jsonEquals("[]")) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -319,7 +319,7 @@ public void noMatch() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]._id", is("doc5")) + .body("data.documents[0]._id", is("doc5")) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -383,7 +383,7 @@ public void withSort() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(0)); + .body("data.documents", hasSize(0)); // cleanUp deleteAllDocuments(); @@ -482,7 +482,7 @@ public void concurrentDeletes() throws Exception { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())); + .body("data.documents", is(empty())); } } } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindIntegrationTest.java index 70074d8c31..bbe873f1a8 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindIntegrationTest.java @@ -150,7 +150,7 @@ public void noFilter() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs", hasSize(6)); + .body("data.documents", hasSize(6)); } @Test @@ -199,8 +199,8 @@ public void byId() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)) - .body("data.docs", hasSize(1)); + .body("data.documents[0]", jsonEquals(expected)) + .body("data.documents", hasSize(1)); } @Test @@ -229,8 +229,8 @@ public void byDateId() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)) - .body("data.docs", hasSize(1)); + .body("data.documents[0]", jsonEquals(expected)) + .body("data.documents", hasSize(1)); } @Test @@ -257,10 +257,10 @@ public void inCondition() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(2)) + .body("data.documents", hasSize(2)) .body("status", is(nullValue())) .body("errors", is(nullValue())) - .body("data.docs", containsInAnyOrder(jsonEquals(expected1), jsonEquals(expected2))); + .body("data.documents", containsInAnyOrder(jsonEquals(expected1), jsonEquals(expected2))); } @Test @@ -283,10 +283,10 @@ public void inConditionWithOtherCondition() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body("status", is(nullValue())) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected1)); + .body("data.documents[0]", jsonEquals(expected1)); } @Test @@ -307,7 +307,7 @@ public void inConditionEmptyArray() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(0)) + .body("data.documents", hasSize(0)) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -330,7 +330,7 @@ public void inOperatorEmptyArrayWithAdditionalFilters() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(0)) + .body("data.documents", hasSize(0)) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -404,7 +404,7 @@ public void byIdWithProjection() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals("{\"username\":\"user1\"}")); + .body("data.documents[0]", jsonEquals("{\"username\":\"user1\"}")); } @Test @@ -429,7 +429,7 @@ public void byColumn() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -454,7 +454,7 @@ public void withEqComparisonOperator() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -479,7 +479,7 @@ public void withEqSubDoc() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -510,7 +510,7 @@ public void withEqSubDocWithIndex() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -542,7 +542,7 @@ public void withEqArrayElement() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -591,7 +591,7 @@ public void withExistOperator() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -618,7 +618,7 @@ public void withAllOperator() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -645,7 +645,7 @@ public void withAllOperatorLongerString() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -672,7 +672,7 @@ public void withAllOperatorMixedAFormatArray() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -725,7 +725,7 @@ public void withEqSubdocumentShortcut() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -756,7 +756,7 @@ public void withEqSubdocument() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -829,7 +829,7 @@ public void withSizeOperator() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -882,7 +882,7 @@ public void withEqOperatorArray() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -909,7 +909,7 @@ public void withEqOperatorNestedArray() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -1000,7 +1000,7 @@ public void byBooleanColumn() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -1025,7 +1025,7 @@ public void byDateColumn() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } } } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndDeleteIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndDeleteIntegrationTest.java index 2dd0c9e099..9c3cbd9f16 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndDeleteIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndDeleteIntegrationTest.java @@ -49,7 +49,7 @@ public void byId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(document)) + .body("data.documents[0]", jsonEquals(document)) .body("status.deletedCount", is(1)) .body("errors", is(nullValue())); @@ -70,7 +70,7 @@ public void byId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(0)); + .body("data.documents", hasSize(0)); } @Test @@ -144,7 +144,7 @@ public void withSortDesc() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(document)) + .body("data.documents[0]", jsonEquals(document)) .body("status.deletedCount", is(1)) .body("errors", is(nullValue())); @@ -165,7 +165,7 @@ public void withSortDesc() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(0)); + .body("data.documents", hasSize(0)); } @Test @@ -207,7 +207,7 @@ public void withSort() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(document1)) + .body("data.documents[0]", jsonEquals(document1)) .body("status.deletedCount", is(1)) .body("errors", is(nullValue())); @@ -228,7 +228,7 @@ public void withSort() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(0)); + .body("data.documents", hasSize(0)); } @Test @@ -278,7 +278,7 @@ public void withSortProjection() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)) + .body("data.documents[0]", jsonEquals(expected)) .body("status.deletedCount", is(1)) .body("errors", is(nullValue())); @@ -299,7 +299,7 @@ public void withSortProjection() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(0)); + .body("data.documents", hasSize(0)); } } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndReplaceIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndReplaceIntegrationTest.java index eb677175b3..80b8c65c9a 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndReplaceIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndReplaceIntegrationTest.java @@ -59,7 +59,7 @@ public void byId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(document)) + .body("data.documents[0]", jsonEquals(document)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -81,7 +81,7 @@ public void byId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -122,7 +122,7 @@ public void byIdWithId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(document)) + .body("data.documents[0]", jsonEquals(document)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -144,7 +144,7 @@ public void byIdWithId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -176,8 +176,8 @@ public void byIdWithIdNoChange() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) - .body("data.docs[0]", jsonEquals(document)) + .body("data.documents", hasSize(1)) + .body("data.documents[0]", jsonEquals(document)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(0)) .body("errors", is(nullValue())); @@ -199,7 +199,7 @@ public void byIdWithIdNoChange() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(document)); + .body("data.documents[0]", jsonEquals(document)); } @Test @@ -251,7 +251,7 @@ public void withSort() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)) + .body("data.documents[0]", jsonEquals(expected)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -273,7 +273,7 @@ public void withSort() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -305,7 +305,7 @@ public void withUpsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)) + .body("data.documents[0]", jsonEquals(expected)) .body("status.matchedCount", is(0)) .body("status.modifiedCount", is(0)) .body("status.upsertedId", is("doc2")) @@ -328,7 +328,7 @@ public void withUpsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -404,7 +404,7 @@ public void byIdWithEmptyDocument() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(document)) + .body("data.documents[0]", jsonEquals(document)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -426,7 +426,7 @@ public void byIdWithEmptyDocument() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } } @@ -468,7 +468,7 @@ public void byIdProjectionAfter() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedAfterProjection)) + .body("data.documents[0]", jsonEquals(expectedAfterProjection)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -497,7 +497,7 @@ public void byIdProjectionAfter() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedAfterReplace)); + .body("data.documents[0]", jsonEquals(expectedAfterReplace)); } @Test @@ -536,7 +536,7 @@ public void byIdProjectionBefore() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedWithProjectionBefore)) + .body("data.documents[0]", jsonEquals(expectedWithProjectionBefore)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -565,7 +565,7 @@ public void byIdProjectionBefore() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedAfterReplace)); + .body("data.documents[0]", jsonEquals(expectedAfterReplace)); } } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndUpdateIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndUpdateIntegrationTest.java index 170e624b77..d01c16fe93 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndUpdateIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndUpdateIntegrationTest.java @@ -55,7 +55,7 @@ public void byIdAndSet() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(document)) + .body("data.documents[0]", jsonEquals(document)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -85,7 +85,7 @@ public void byIdAndSet() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -119,8 +119,8 @@ public void byIdAndSetNoChange() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) - .body("data.docs[0]", jsonEquals(document)) + .body("data.documents", hasSize(1)) + .body("data.documents[0]", jsonEquals(document)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(0)) .body("errors", is(nullValue())); @@ -145,7 +145,7 @@ public void byIdAndSetNotFound() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())) + .body("data.documents", is(empty())) .body("status.matchedCount", is(0)) .body("status.modifiedCount", is(0)) .body("errors", is(nullValue())); @@ -171,7 +171,7 @@ public void emptyOptionsAllowed() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())) + .body("data.documents", is(empty())) .body("status.matchedCount", is(0)) .body("status.modifiedCount", is(0)) .body("errors", is(nullValue())); @@ -212,7 +212,7 @@ public void byIdReturnDocumentAfter() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)) + .body("data.documents[0]", jsonEquals(expected)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -234,7 +234,7 @@ public void byIdReturnDocumentAfter() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -277,7 +277,7 @@ public void byIdReturnDocumentBefore() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(docBefore)) + .body("data.documents[0]", jsonEquals(docBefore)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -299,7 +299,7 @@ public void byIdReturnDocumentBefore() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(docAfter)); + .body("data.documents[0]", jsonEquals(docAfter)); } @Test @@ -323,7 +323,7 @@ public void byColumnUpsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", is(notNullValue())) + .body("data.documents[0]", is(notNullValue())) .body("status.upsertedId", is(notNullValue())) .body("status.matchedCount", is(0)) .body("status.modifiedCount", is(0)) @@ -346,7 +346,7 @@ public void byColumnUpsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", is(notNullValue())); + .body("data.documents[0]", is(notNullValue())); } @Test @@ -377,7 +377,7 @@ public void byIdUpsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)) + .body("data.documents[0]", jsonEquals(expected)) .body("status.upsertedId", is("afterDoc4")) .body("status.matchedCount", is(0)) .body("status.modifiedCount", is(0)) @@ -400,7 +400,7 @@ public void byIdUpsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -431,7 +431,7 @@ public void byColumnAndSet() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(document)) + .body("data.documents[0]", jsonEquals(document)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -461,7 +461,7 @@ public void byColumnAndSet() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -493,7 +493,7 @@ public void byIdAndUnset() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(document)) + .body("data.documents[0]", jsonEquals(document)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -521,7 +521,7 @@ public void byIdAndUnset() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -577,7 +577,7 @@ public void withSortReturnDocumentAfter() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)) + .body("data.documents[0]", jsonEquals(expected)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -599,7 +599,7 @@ public void withSortReturnDocumentAfter() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -655,7 +655,7 @@ public void withSortDescendingReturnDocumentAfter() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)) + .body("data.documents[0]", jsonEquals(expected)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())); @@ -677,7 +677,7 @@ public void withSortDescendingReturnDocumentAfter() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } } @@ -734,7 +734,7 @@ public void byIdTryUnsetId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(inputDoc)); + .body("data.documents[0]", jsonEquals(inputDoc)); } @Test @@ -787,7 +787,7 @@ public void byIdTrySetId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(inputDoc)); + .body("data.documents[0]", jsonEquals(inputDoc)); } @Test @@ -844,7 +844,7 @@ public void byIdTrySetPropertyOnArray() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(inputDoc)); + .body("data.documents[0]", jsonEquals(inputDoc)); } @Test @@ -902,7 +902,7 @@ public void byIdTryPopNonArray() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(inputDoc)); + .body("data.documents[0]", jsonEquals(inputDoc)); } @Test @@ -959,7 +959,7 @@ public void byIdTryIncNonNumber() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(inputDoc)); + .body("data.documents[0]", jsonEquals(inputDoc)); } } @@ -1052,7 +1052,7 @@ public void byIdAndUnsetNested() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -1136,7 +1136,7 @@ public void byIdAndSetNested() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } } @@ -1176,7 +1176,7 @@ public void byIdUpsertAndAddOnInsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)) + .body("data.documents[0]", jsonEquals(expected)) .body("status.upsertedId", is("setOnInsertDoc1")) .body("status.matchedCount", is(0)) .body("status.modifiedCount", is(0)) @@ -1198,7 +1198,7 @@ public void byIdUpsertAndAddOnInsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); // However: with update for upsert, $setOnInsert not to be applied json = @@ -1230,7 +1230,7 @@ public void byIdUpsertAndAddOnInsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)) + .body("data.documents[0]", jsonEquals(expected)) .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("status.upsertedId", nullValue()) @@ -1253,7 +1253,7 @@ public void byIdUpsertAndAddOnInsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } } @@ -1315,7 +1315,7 @@ public void projectionAfterUpdate() { .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expectedFiltered)); + .body("data.documents[0]", jsonEquals(expectedFiltered)); // But also that update itself worked ($unset "z" and "subdoc.a") String expectedUpdated = @@ -1346,7 +1346,7 @@ public void projectionAfterUpdate() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedUpdated)); + .body("data.documents[0]", jsonEquals(expectedUpdated)); } @Test @@ -1407,7 +1407,7 @@ public void projectionBeforeUpdate() { .body("status.matchedCount", is(1)) .body("status.modifiedCount", is(1)) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expectedFiltered)); + .body("data.documents[0]", jsonEquals(expectedFiltered)); // And with updates $unset of c and subdoc.x, but no Projection String expectedUpdated = @@ -1437,7 +1437,7 @@ public void projectionBeforeUpdate() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedUpdated)); + .body("data.documents[0]", jsonEquals(expectedUpdated)); } } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneIntegrationTest.java index 35873748d3..1400e31ac6 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneIntegrationTest.java @@ -102,7 +102,7 @@ public void noFilterNoDocuments() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())) + .body("data.documents", is(empty())) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -125,7 +125,7 @@ public void noFilter() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -149,7 +149,7 @@ public void emptyOptionsAllowed() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -173,10 +173,11 @@ public void noFilterSortAscending() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body("status", is(nullValue())) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(DOC4_JSON)); // missing value is the lowest precedence + .body( + "data.documents[0]", jsonEquals(DOC4_JSON)); // missing value is the lowest precedence } @Test @@ -198,10 +199,11 @@ public void noFilterSortDescending() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body("status", is(nullValue())) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(DOC5_JSON)); // missing value is the lowest precedence + .body( + "data.documents[0]", jsonEquals(DOC5_JSON)); // missing value is the lowest precedence } @Test @@ -223,8 +225,8 @@ public void byId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) - .body("data.docs[0]", jsonEquals(DOC1_JSON)) + .body("data.documents", hasSize(1)) + .body("data.documents[0]", jsonEquals(DOC1_JSON)) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -248,7 +250,7 @@ public void byIdNotFound() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())) + .body("data.documents", is(empty())) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -273,10 +275,10 @@ public void inCondition() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body("status", is(nullValue())) .body("errors", is(nullValue())) - .body("data.docs[0]", anyOf(jsonEquals(DOC5_JSON), jsonEquals(DOC4_JSON))); + .body("data.documents[0]", anyOf(jsonEquals(DOC5_JSON), jsonEquals(DOC4_JSON))); } @Test @@ -297,7 +299,7 @@ public void inConditionEmptyArray() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(0)) + .body("data.documents", hasSize(0)) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -369,8 +371,8 @@ public void byColumn() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) - .body("data.docs[0]", jsonEquals(DOC1_JSON)) + .body("data.documents", hasSize(1)) + .body("data.documents[0]", jsonEquals(DOC1_JSON)) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -394,7 +396,7 @@ public void byColumnMissing() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())) + .body("data.documents", is(empty())) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -418,7 +420,7 @@ public void byColumnNotMatching() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())) + .body("data.documents", is(empty())) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -443,8 +445,8 @@ public void withExistsOperatorSortAsc() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) - .body("data.docs[0]", jsonEquals(DOC1_JSON)) + .body("data.documents", hasSize(1)) + .body("data.documents[0]", jsonEquals(DOC1_JSON)) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -469,9 +471,9 @@ public void withExistsOperatorSortDesc() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) // post sorting by sort id , it uses document id by default. - .body("data.docs[0]", jsonEquals(DOC5_JSON)) + .body("data.documents[0]", jsonEquals(DOC5_JSON)) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -495,8 +497,8 @@ public void withExistsOperator() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) - .body("data.docs[0]", jsonEquals(DOC1_JSON)) + .body("data.documents", hasSize(1)) + .body("data.documents[0]", jsonEquals(DOC1_JSON)) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -546,7 +548,7 @@ public void withExistsNotMatching() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())) + .body("data.documents", is(empty())) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -570,7 +572,7 @@ public void withAllOperatorMissing() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())) + .body("data.documents", is(empty())) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -594,7 +596,7 @@ public void withAllOperatorNotMatching() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())) + .body("data.documents", is(empty())) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -644,8 +646,8 @@ public void withSizeOperator() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) - .body("data.docs[0]", jsonEquals(DOC3_JSON)) + .body("data.documents", hasSize(1)) + .body("data.documents[0]", jsonEquals(DOC3_JSON)) .body("status", is(nullValue())) .body("errors", is(nullValue())); } @@ -669,7 +671,7 @@ public void withSizeOperatorNotMatching() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())) + .body("data.documents", is(empty())) .body("status", is(nullValue())) .body("errors", is(nullValue())); } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneWithProjectionIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneWithProjectionIntegrationTest.java index 82c2a8b3d2..ec20637470 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneWithProjectionIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneWithProjectionIntegrationTest.java @@ -80,9 +80,9 @@ public void byIdNestedExclusion() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body( - "data.docs[0]", + "data.documents[0]", jsonEquals( """ { @@ -93,7 +93,7 @@ public void byIdNestedExclusion() { """)) .body("status", is(nullValue())) .body("errors", is(nullValue())) - .body("data.docs", hasSize(1)); + .body("data.documents", hasSize(1)); } @Test @@ -122,9 +122,9 @@ public void byIdIncludeDates() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body( - "data.docs[0]", + "data.documents[0]", jsonEquals( """ { @@ -169,9 +169,9 @@ public void byIdExcludeDates() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body( - "data.docs[0]", + "data.documents[0]", jsonEquals( """ { @@ -217,9 +217,9 @@ public void byIdRootSliceHead() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body( - "data.docs[0]", + "data.documents[0]", jsonEquals( """ { @@ -256,9 +256,9 @@ public void byIdRootSliceTail() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body( - "data.docs[0]", + "data.documents[0]", jsonEquals( """ { @@ -301,9 +301,9 @@ public void byIdRootSliceHeadOverrun() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body( - "data.docs[0]", + "data.documents[0]", jsonEquals( """ { @@ -344,9 +344,9 @@ public void byIdRootSliceTail() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body( - "data.docs[0]", + "data.documents[0]", jsonEquals( """ { @@ -388,9 +388,9 @@ public void byIdNestedArraySliceHead() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", hasSize(1)) + .body("data.documents", hasSize(1)) .body( - "data.docs[0]", + "data.documents[0]", jsonEquals( """ { diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOperationWithSortIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOperationWithSortIntegrationTest.java index 1ccf2dc3e9..51d05b6a45 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOperationWithSortIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOperationWithSortIntegrationTest.java @@ -74,7 +74,7 @@ public void sortByTextAndNullValue() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals(arrayNode.toString())); + .body("data.documents", jsonEquals(arrayNode.toString())); } @Test @@ -115,7 +115,7 @@ public void sortWithSkipLimit() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals(arrayNode.toString())); + .body("data.documents", jsonEquals(arrayNode.toString())); } @Test @@ -152,7 +152,7 @@ public void sortDescendingTextValue() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals(arrayNode.toString())); + .body("data.documents", jsonEquals(arrayNode.toString())); } @Test @@ -189,7 +189,7 @@ public void sortBooleanValueAndMissing() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals(arrayNode.toString())); + .body("data.documents", jsonEquals(arrayNode.toString())); } @Test @@ -226,7 +226,7 @@ public void sortBooleanValueAndMissingDescending() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals(arrayNode.toString())); + .body("data.documents", jsonEquals(arrayNode.toString())); } @Test @@ -263,7 +263,7 @@ public void sortNumericField() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals(arrayNode.toString())); + .body("data.documents", jsonEquals(arrayNode.toString())); } @Test @@ -300,7 +300,7 @@ public void sortNumericFieldDescending() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals(arrayNode.toString())); + .body("data.documents", jsonEquals(arrayNode.toString())); } @Test @@ -340,7 +340,7 @@ public void sortNumericFieldAndFilter() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals(arrayNode.toString())); + .body("data.documents", jsonEquals(arrayNode.toString())); } @Test @@ -377,7 +377,7 @@ public void sortMultiColumns() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals(arrayNode.toString())); + .body("data.documents", jsonEquals(arrayNode.toString())); } @Test @@ -416,7 +416,7 @@ public void sortMultiColumnsMixedOrder() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals(arrayNode.toString())); + .body("data.documents", jsonEquals(arrayNode.toString())); } @Test @@ -455,7 +455,7 @@ public void sortByDate() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals(arrayNode.toString())); + .body("data.documents", jsonEquals(arrayNode.toString())); } @Test @@ -494,7 +494,7 @@ public void sortByDateDescending() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", jsonEquals(arrayNode.toString())); + .body("data.documents", jsonEquals(arrayNode.toString())); } private void sortByUserNameUserId( diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/HTTPLimitsIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/HTTPLimitsIntegrationTest.java index 5dac5c96c6..ccda870048 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/HTTPLimitsIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/HTTPLimitsIntegrationTest.java @@ -27,7 +27,7 @@ public void tryToSendTooBigInsert() { RandomBytesInputStream inputStream = new RandomBytesInputStream(1024 * 1024 + 1024); // Fails before getting to business logic no need for real collection (or keyspace fwtw) - // While docs don't say it, Quarkus tests show 413 as expected fail message: + // While documents don't say it, Quarkus tests show 413 as expected fail message: given() // https://stackoverflow.com/questions/66299813/apache-httpclient-4-5-13-java-net-socketexception-broken-pipe-write-failed .config( diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java index dfdffb21d0..66acd24204 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java @@ -87,7 +87,7 @@ public void insertDocument() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)) + .body("data.documents[0]", jsonEquals(expected)) .body("errors", is(nullValue())); } @@ -144,7 +144,7 @@ public void insertDocumentWithDateValue() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)) + .body("data.documents[0]", jsonEquals(expected)) .body("errors", is(nullValue())); } @@ -202,7 +202,7 @@ public void insertDocumentWithDateDocId() { .then() .statusCode(200) .body("errors", is(nullValue())) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -255,7 +255,7 @@ public void insertDocumentWithNumberId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)) + .body("data.documents[0]", jsonEquals(expected)) .body("errors", is(nullValue())); } @@ -363,7 +363,7 @@ public void insertDuplicateDocument() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -799,7 +799,7 @@ public void withDifferentTypes() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); json = """ @@ -825,7 +825,7 @@ public void withDifferentTypes() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/LwtRetryIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/LwtRetryIntegrationTest.java index 98beb9438b..cd13e4b2b2 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/LwtRetryIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/LwtRetryIntegrationTest.java @@ -113,7 +113,7 @@ public void mixedOperations() throws Exception { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs", is(empty())); + .body("data.documents", is(empty())); } @AfterEach diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/UpdateManyIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/UpdateManyIntegrationTest.java index c93d2560b7..9ce40e446e 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/UpdateManyIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/UpdateManyIntegrationTest.java @@ -90,7 +90,7 @@ public void byId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); // then not changed document expected = @@ -117,7 +117,7 @@ public void byId() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -187,7 +187,7 @@ public void byColumn() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs.active_user", everyItem(is(false))); + .body("data.documents.active_user", everyItem(is(false))); } @Test @@ -231,7 +231,7 @@ public void limit() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs.active_user", everyItem(is(false))) + .body("data.documents.active_user", everyItem(is(false))) .body("errors", is(nullValue())); } @@ -276,7 +276,7 @@ public void limitMoreDataFlag() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs.active_user", everyItem(is(true))); + .body("data.documents.active_user", everyItem(is(true))); } @Test @@ -330,7 +330,7 @@ public void upsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -383,7 +383,7 @@ public void byIdNoChange() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -430,7 +430,7 @@ public void upsertManyByColumnUpsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", is(notNullValue())); + .body("data.documents[0]", is(notNullValue())); } @Test @@ -485,7 +485,7 @@ public void upsertAddFilterColumn() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } } @@ -494,7 +494,7 @@ class Concurrency { @RepeatedTest(10) public void concurrentUpdates() throws Exception { - // with 5 docs + // with 5 documents String document = """ { @@ -510,7 +510,7 @@ public void concurrentUpdates() throws Exception { int threads = 3; CountDownLatch latch = new CountDownLatch(threads); - // find all docs + // find all documents String updateJson = """ { @@ -579,7 +579,7 @@ public void concurrentUpdates() throws Exception { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs.count", everyItem(is(3))); + .body("data.documents.count", everyItem(is(3))); } } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/UpdateOneIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/UpdateOneIntegrationTest.java index 69dfd2283e..ec72d6f236 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/UpdateOneIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/UpdateOneIntegrationTest.java @@ -97,7 +97,7 @@ public void byIdAndSet() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -176,7 +176,7 @@ public void byIdUpsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -223,7 +223,7 @@ public void byColumnUpsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", is(notNullValue())); + .body("data.documents[0]", is(notNullValue())); } @Test @@ -278,7 +278,7 @@ public void byIdAndColumnUpsert() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -370,7 +370,7 @@ public void byColumnAndSet() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -466,7 +466,7 @@ public void byColumnWithSortAndSet() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -536,7 +536,7 @@ public void byColumnAndSetArray() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -608,7 +608,7 @@ public void byColumnAndSetSubDoc() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } } @@ -671,7 +671,7 @@ public void byIdAndUnset() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } } @@ -755,7 +755,7 @@ public void byColumnAndPop() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } } @@ -819,7 +819,7 @@ public void byColumnAndPush() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -884,7 +884,7 @@ public void byColumnAndPushWithEach() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } @Test @@ -950,7 +950,7 @@ public void byColumnAndPushWithEachAndPosition() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } } @@ -1027,7 +1027,7 @@ public void byColumnAndInc() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedDoc)); + .body("data.documents[0]", jsonEquals(expectedDoc)); } } @@ -1101,7 +1101,7 @@ public void byColumnAndMultiply() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedDoc)); + .body("data.documents[0]", jsonEquals(expectedDoc)); } } @@ -1165,7 +1165,7 @@ public void byColumnAndAddToSet() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } // Test for case where nothing is actually added @@ -1215,7 +1215,7 @@ public void byColumnAndAddToSetNoChange() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(originalDoc)); + .body("data.documents[0]", jsonEquals(originalDoc)); } @Test @@ -1280,7 +1280,7 @@ public void byColumnAndAddToSetWithEach() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expected)); + .body("data.documents[0]", jsonEquals(expected)); } } @@ -1357,7 +1357,7 @@ public void byColumnAndMin() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedDoc)); + .body("data.documents[0]", jsonEquals(expectedDoc)); } @Test @@ -1421,7 +1421,7 @@ public void byColumnMinNonNumeric() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedDoc)); + .body("data.documents[0]", jsonEquals(expectedDoc)); } @Test @@ -1486,7 +1486,7 @@ public void byColumnMinMixedTypes() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedDoc)); + .body("data.documents[0]", jsonEquals(expectedDoc)); } } @@ -1563,7 +1563,7 @@ public void byColumnAndMax() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedDoc)); + .body("data.documents[0]", jsonEquals(expectedDoc)); } @Test @@ -1627,7 +1627,7 @@ public void byColumnMaxNonNumeric() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedDoc)); + .body("data.documents[0]", jsonEquals(expectedDoc)); } @Test @@ -1692,7 +1692,7 @@ public void byColumnMaxMixedTypes() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedDoc)); + .body("data.documents[0]", jsonEquals(expectedDoc)); } } @@ -1768,7 +1768,7 @@ public void byColumnAndRename() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedDoc)); + .body("data.documents[0]", jsonEquals(expectedDoc)); } } @@ -1840,7 +1840,7 @@ public void byColumnUseSetAndUnset() { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedDoc)); + .body("data.documents[0]", jsonEquals(expectedDoc)); } } @@ -1939,7 +1939,7 @@ public void concurrentUpdates() throws Exception { .post(CollectionResource.BASE_PATH, namespaceName, collectionName) .then() .statusCode(200) - .body("data.docs[0]", jsonEquals(expectedDoc)); + .body("data.documents[0]", jsonEquals(expectedDoc)); } } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/AddToSetOperationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/AddToSetOperationTest.java index 52fdc857fb..9e1a29cf61 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/AddToSetOperationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/AddToSetOperationTest.java @@ -103,7 +103,7 @@ public void addToNewArrayNested() { } } - // Since equality semantics of sub-docs differ, have separate sets for them + // Since equality semantics of sub-documents differ, have separate sets for them @Nested class AddToSetWithSubDocs { @Test diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/DeleteOperationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/DeleteOperationTest.java index 28fa480d4b..a0cc2c831c 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/DeleteOperationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/DeleteOperationTest.java @@ -199,8 +199,8 @@ public void deleteOneAndReturnById() { // then result CommandResult result = execute.get(); assertThat(result.status()).hasSize(1).containsEntry(CommandStatus.DELETED_COUNT, 1); - assertThat(result.data().docs()).hasSize(1); - assertThat(result.data().docs().get(0).toString()).isEqualTo(docJson); + assertThat(result.data().documents()).hasSize(1); + assertThat(result.data().documents().get(0).toString()).isEqualTo(docJson); } @Test @@ -317,7 +317,7 @@ public void deleteOneAndReturnWithSort() { // then result CommandResult result = execute.get(); assertThat(result.status()).hasSize(1).containsEntry(CommandStatus.DELETED_COUNT, 1); - assertThat(result.data().docs().get(0).toString()).isEqualTo(docJson1); + assertThat(result.data().documents().get(0).toString()).isEqualTo(docJson1); } @Test @@ -434,7 +434,7 @@ public void deleteOneAndReturnWithSortDesc() { // then result CommandResult result = execute.get(); assertThat(result.status()).hasSize(1).containsEntry(CommandStatus.DELETED_COUNT, 1); - assertThat(result.data().docs().get(0).toString()).isEqualTo(docJson2); + assertThat(result.data().documents().get(0).toString()).isEqualTo(docJson2); } @Test diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/FindOperationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/FindOperationTest.java index c61086dca8..891b4ca727 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/FindOperationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/FindOperationTest.java @@ -125,7 +125,7 @@ public void findAll() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()) + assertThat(result.data().documents()) .hasSize(2) .containsOnly(objectMapper.readTree(doc1), objectMapper.readTree(doc2)); assertThat(result.status()).isNullOrEmpty(); @@ -240,7 +240,7 @@ public void byIdWithInOperator() throws Exception { candidatesAssert2.assertExecuteCount().isOne(); // then result CommandResult result = execute.get(); - assertThat(result.data().docs()) + assertThat(result.data().documents()) .hasSize(2) .contains(objectMapper.readTree(doc1), objectMapper.readTree(doc2)); assertThat(result.status()).isNullOrEmpty(); @@ -275,7 +275,7 @@ public void byIdWithInEmptyArray() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()).hasSize(0); + assertThat(result.data().documents()).hasSize(0); assertThat(result.status()).isNullOrEmpty(); assertThat(result.errors()).isNullOrEmpty(); } @@ -392,7 +392,7 @@ public void byIdWithInAndOtherOperator() throws Exception { candidatesAssert2.assertExecuteCount().isOne(); // then result CommandResult result = execute.get(); - assertThat(result.data().docs()) + assertThat(result.data().documents()) .hasSize(2) .contains(objectMapper.readTree(doc1), objectMapper.readTree(doc2)); assertThat(result.status()).isNullOrEmpty(); @@ -507,7 +507,7 @@ public void findOneByIdWithInOperator() throws Exception { candidatesAssert2.assertExecuteCount().isOne(); // then result CommandResult result = execute.get(); - assertThat(result.data().docs()) + assertThat(result.data().documents()) .hasSize(1) .containsAnyOf(objectMapper.readTree(doc1), objectMapper.readTree(doc2)); assertThat(result.status()).isNullOrEmpty(); @@ -585,7 +585,7 @@ public void findWithId() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); + assertThat(result.data().documents()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); assertThat(result.status()).isNullOrEmpty(); assertThat(result.errors()).isNullOrEmpty(); } @@ -648,7 +648,7 @@ public void findWithIdNoData() { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()).isEmpty(); + assertThat(result.data().documents()).isEmpty(); assertThat(result.status()).isNullOrEmpty(); assertThat(result.errors()).isNullOrEmpty(); } @@ -723,7 +723,7 @@ public void findWithDynamic() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); + assertThat(result.data().documents()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); assertThat(result.status()).isNullOrEmpty(); assertThat(result.errors()).isNullOrEmpty(); } @@ -800,7 +800,7 @@ public void findWithBooleanFilter() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); + assertThat(result.data().documents()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); assertThat(result.status()).isNullOrEmpty(); assertThat(result.errors()).isNullOrEmpty(); } @@ -880,7 +880,7 @@ public void findWithDateFilter() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); + assertThat(result.data().documents()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); assertThat(result.status()).isNullOrEmpty(); assertThat(result.errors()).isNullOrEmpty(); } @@ -953,7 +953,7 @@ public void findWithExistsFilter() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); + assertThat(result.data().documents()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); assertThat(result.status()).isNullOrEmpty(); assertThat(result.errors()).isNullOrEmpty(); } @@ -1030,7 +1030,7 @@ public void findWithAllFilter() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); + assertThat(result.data().documents()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); assertThat(result.status()).isNullOrEmpty(); assertThat(result.errors()).isNullOrEmpty(); } @@ -1104,7 +1104,7 @@ public void findWithSizeFilter() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); + assertThat(result.data().documents()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); assertThat(result.status()).isNullOrEmpty(); assertThat(result.errors()).isNullOrEmpty(); } @@ -1180,7 +1180,7 @@ public void findWithArrayEqualFilter() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); + assertThat(result.data().documents()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); assertThat(result.status()).isNullOrEmpty(); assertThat(result.errors()).isNullOrEmpty(); } @@ -1257,7 +1257,7 @@ public void findWithSubDocEqualFilter() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); + assertThat(result.data().documents()).hasSize(1).containsOnly(objectMapper.readTree(doc1)); assertThat(result.status()).isNullOrEmpty(); assertThat(result.errors()).isNullOrEmpty(); } @@ -1508,7 +1508,7 @@ public void findAllSort() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()) + assertThat(result.data().documents()) .hasSize(5) .isEqualTo( List.of( @@ -1721,7 +1721,7 @@ public void findAllSortByDate() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()) + assertThat(result.data().documents()) .hasSize(5) .isEqualTo( List.of( @@ -1915,7 +1915,9 @@ public void findAllSortWithSkip() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()).hasSize(1).isEqualTo(List.of(objectMapper.readTree(doc6))); + assertThat(result.data().documents()) + .hasSize(1) + .isEqualTo(List.of(objectMapper.readTree(doc6))); assertThat(result.status()).isNullOrEmpty(); assertThat(result.errors()).isNullOrEmpty(); } @@ -2105,7 +2107,7 @@ public void findAllSortDescending() throws Exception { // then result CommandResult result = execute.get(); - assertThat(result.data().docs()) + assertThat(result.data().documents()) .hasSize(5) .isEqualTo( List.of( diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/ReadAndUpdateOperationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/ReadAndUpdateOperationTest.java index f49e942f29..a772fcde3a 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/ReadAndUpdateOperationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/ReadAndUpdateOperationTest.java @@ -318,7 +318,7 @@ public void noChange() throws Exception { .containsEntry(CommandStatus.MATCHED_COUNT, 1) .containsEntry(CommandStatus.MODIFIED_COUNT, 0); assertThat(result.errors()).isNull(); - assertThat(result.data().docs()).hasSize(1); + assertThat(result.data().documents()).hasSize(1); } @Test diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/shredding/model/DocValueHasherTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/shredding/model/DocValueHasherTest.java index fa553f59ab..211e2d45d6 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/shredding/model/DocValueHasherTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/shredding/model/DocValueHasherTest.java @@ -99,7 +99,7 @@ public void testNestedObject() throws Exception { // long enough to require MD5 hashing assertMD5Base64(hash); - // 3 documents (main doc, 2 sub-docs) + // 3 documents (main doc, 2 sub-documents) // Note: unlike with atomic values, // structured values are not de-duplicated (JsonNode identity only used to avoid // re-processing)