diff --git a/pom.xml b/pom.xml index bf1b421f05..9cd3cdf532 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.stargate sgv2-api-parent - 2.1.0-BETA-11 + 2.1.0-BETA-12 sgv2-jsonapi 1.0.8-SNAPSHOT @@ -294,9 +294,9 @@ - com.coveo + com.spotify.fmt fmt-maven-plugin - 2.13 + 2.23 process-sources diff --git a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/filter/FilterClause.java b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/filter/FilterClause.java index 63ba9dcf2f..4ecab9b4ff 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/filter/FilterClause.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/filter/FilterClause.java @@ -16,7 +16,8 @@ @Schema( type = SchemaType.OBJECT, implementation = Object.class, - example = """ + example = + """ {"name": "Aaron", "country": "US"} """) public record FilterClause(LogicalExpression logicalExpression) { diff --git a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/sort/SortClause.java b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/sort/SortClause.java index 0789acefb3..298795b813 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/sort/SortClause.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/sort/SortClause.java @@ -21,7 +21,8 @@ @Schema( type = SchemaType.OBJECT, implementation = Map.class, - example = """ + example = + """ {"user.age" : -1, "user.name" : 1} """) public record SortClause(@Valid List sortExpressions) { diff --git a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/ActionWithLocator.java b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/ActionWithLocator.java index ffce9b681c..636a9d6196 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/ActionWithLocator.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/ActionWithLocator.java @@ -6,7 +6,9 @@ * Interface needed to allow easy sorting by {@code path} property exposed by Action record types. */ public interface ActionWithLocator { - /** @return Path that the action targets (dotted notation) */ + /** + * @return Path that the action targets (dotted notation) + */ PathMatchLocator locator(); /** Convenience method: path from {@code action()} */ diff --git a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/UpdateOperation.java b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/UpdateOperation.java index b7605881db..97f80a63a7 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/UpdateOperation.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/clause/update/UpdateOperation.java @@ -23,6 +23,7 @@ protected UpdateOperation(List actions) { public List actions() { return actions; } + /** * Method called to apply operation to given document. * diff --git a/src/main/java/io/stargate/sgv2/jsonapi/config/AuthConfig.java b/src/main/java/io/stargate/sgv2/jsonapi/config/AuthConfig.java index 8cb859ba17..4c949d3496 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/config/AuthConfig.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/config/AuthConfig.java @@ -28,14 +28,18 @@ @ConfigMapping(prefix = "stargate.auth") public interface AuthConfig { - /** @return Header based authentication setup. */ + /** + * @return Header based authentication setup. + */ @Valid HeaderBasedAuthConfig headerBased(); /** Configuration for the header based authentication. */ interface HeaderBasedAuthConfig { - /** @return If the header based auth is enabled. */ + /** + * @return If the header based auth is enabled. + */ @WithDefault("true") boolean enabled(); @@ -47,12 +51,16 @@ interface HeaderBasedAuthConfig { @WithDefault(HttpConstants.AUTHENTICATION_TOKEN_HEADER_NAME) String headerName(); - /** @return If the customization of the challenge sending should be done. */ + /** + * @return If the customization of the challenge sending should be done. + */ @WithDefault("${stargate.exception-mappers.enabled:true}") boolean customChallengeEnabled(); } - /** @return Configuration for the cassandra token resolver. */ + /** + * @return Configuration for the cassandra token resolver. + */ @Valid TokenResolverConfig tokenResolver(); @@ -80,7 +88,9 @@ interface TokenResolverConfig { @WithDefault("principal") Optional<@Pattern(regexp = "header|principal|fixed|custom") String> type(); - /** @return Specific settings for the header token resolver type. */ + /** + * @return Specific settings for the header token resolver type. + */ @Valid HeaderTokenResolverConfig header(); @@ -95,13 +105,17 @@ interface HeaderTokenResolverConfig { String headerName(); } - /** @return Specific settings for the fixed token resolver type. */ + /** + * @return Specific settings for the fixed token resolver type. + */ @Valid FixedTokenResolverConfig fixed(); interface FixedTokenResolverConfig { - /** @return Token value. */ + /** + * @return Token value. + */ Optional token(); } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/config/CommandLevelLoggingConfig.java b/src/main/java/io/stargate/sgv2/jsonapi/config/CommandLevelLoggingConfig.java index b11acb7ce0..54d133de64 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/config/CommandLevelLoggingConfig.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/config/CommandLevelLoggingConfig.java @@ -28,15 +28,21 @@ @ConfigMapping(prefix = "stargate.jsonapi.logging") public interface CommandLevelLoggingConfig { - /** @return If request info logging is enabled. */ + /** + * @return If request info logging is enabled. + */ @WithDefault("false") boolean enabled(); - /** @return If only requests with errors should be logged. */ + /** + * @return If only requests with errors should be logged. + */ @WithDefault("true") boolean onlyResultsWithErrors(); - /** @return Set of tenants for which the request info should be logged. */ + /** + * @return Set of tenants for which the request info should be logged. + */ @WithDefault(ALL_TENANTS) Optional> enabledTenants(); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/config/DocumentLimitsConfig.java b/src/main/java/io/stargate/sgv2/jsonapi/config/DocumentLimitsConfig.java index d3bc4277c4..2f2a92b89a 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/config/DocumentLimitsConfig.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/config/DocumentLimitsConfig.java @@ -63,7 +63,9 @@ public interface DocumentLimitsConfig { @WithDefault("" + DEFAULT_MAX_DOCUMENT_SIZE) int maxSize(); - /** @return Defines the maximum document depth (nesting), defaults to {@code 8 levels} */ + /** + * @return Defines the maximum document depth (nesting), defaults to {@code 8 levels} + */ @Positive @WithDefault("" + DEFAULT_MAX_DOCUMENT_DEPTH) int maxDepth(); @@ -94,22 +96,30 @@ public interface DocumentLimitsConfig { @WithDefault("" + DEFAULT_MAX_DOC_PROPERTIES) int maxDocumentProperties(); - /** @return Defines the maximum length of a single Number value (in characters). */ + /** + * @return Defines the maximum length of a single Number value (in characters). + */ @Positive @WithDefault("" + DEFAULT_MAX_NUMBER_LENGTH) int maxNumberLength(); - /** @return Defines the maximum length of a single String value (in bytes). */ + /** + * @return Defines the maximum length of a single String value (in bytes). + */ @Positive @WithDefault("" + DEFAULT_MAX_STRING_LENGTH_IN_BYTES) int maxStringLengthInBytes(); - /** @return Maximum length of an indexable Array in document (in elements). */ + /** + * @return Maximum length of an indexable Array in document (in elements). + */ @Positive @WithDefault("" + DEFAULT_MAX_ARRAY_LENGTH) int maxArrayLength(); - /** @return Maximum length of Vector ($vector) array allowed. */ + /** + * @return Maximum length of Vector ($vector) array allowed. + */ @Positive @WithDefault("" + DEFAULT_MAX_VECTOR_EMBEDDING_LENGTH) int maxVectorEmbeddingLength(); diff --git a/src/main/java/io/stargate/sgv2/jsonapi/config/MultiTenancyConfig.java b/src/main/java/io/stargate/sgv2/jsonapi/config/MultiTenancyConfig.java index 9864c4d5c6..4d1998f9bb 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/config/MultiTenancyConfig.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/config/MultiTenancyConfig.java @@ -27,11 +27,15 @@ @ConfigMapping(prefix = "stargate.multi-tenancy") public interface MultiTenancyConfig { - /** @return If multi-tenancy is enabled. */ + /** + * @return If multi-tenancy is enabled. + */ @WithDefault("false") boolean enabled(); - /** @return Tenant resolver in case the multi-tenancy is active. */ + /** + * @return Tenant resolver in case the multi-tenancy is active. + */ @Valid TenantResolverConfig tenantResolver(); @@ -55,26 +59,36 @@ interface TenantResolverConfig { */ Optional<@Pattern(regexp = "subdomain|fixed|custom") String> type(); - /** @return Specific settings for the fixed tenant resolver type. */ + /** + * @return Specific settings for the fixed tenant resolver type. + */ @Valid FixedTenantResolverConfig fixed(); - /** @return Specific settings for the subdomain tenant resolver type. */ + /** + * @return Specific settings for the subdomain tenant resolver type. + */ @Valid SubdomainTenantResolverConfig subdomain(); interface FixedTenantResolverConfig { - /** @return Tenant ID value. */ + /** + * @return Tenant ID value. + */ Optional tenantId(); } interface SubdomainTenantResolverConfig { - /** @return Maximum characters to pull from the subdomain. */ + /** + * @return Maximum characters to pull from the subdomain. + */ OptionalInt maxChars(); - /** @return The regex to validate the resolved tenant against. */ + /** + * @return The regex to validate the resolved tenant against. + */ Optional regex(); } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/config/OperationsConfig.java b/src/main/java/io/stargate/sgv2/jsonapi/config/OperationsConfig.java index c86c24af92..e98ff5388e 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/config/OperationsConfig.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/config/OperationsConfig.java @@ -43,7 +43,9 @@ public interface OperationsConfig { */ public static final int DEFAULT_MAX_DOCUMENT_INSERT_COUNT = 100; - /** @return Defines the default document page size, defaults to 20. */ + /** + * @return Defines the default document page size, defaults to 20. + */ @Max(500) @Positive @WithDefault("20") @@ -101,7 +103,9 @@ public interface OperationsConfig { @WithDefault("" + DEFAULT_MAX_FILTER_SIZE) int maxFilterObjectProperties(); - /** @return Maximum size of values array that can be sent in $in/$nin operator */ + /** + * @return Maximum size of values array that can be sent in $in/$nin operator + */ @Max(100) @Positive @WithDefault("100") @@ -123,7 +127,9 @@ public interface OperationsConfig { @WithDefault("1000") int maxCountLimit(); - /** @return Boolean flag to enable astra index guardrail too many indexes rollback */ + /** + * @return Boolean flag to enable astra index guardrail too many indexes rollback + */ @WithDefault("true") boolean tooManyIndexesRollbackEnabled(); @@ -144,7 +150,9 @@ public interface OperationsConfig { /** Configuration setup for the Light-weight transactions. */ interface LwtConfig { - /** @return Defines the maximum retry for lwt failure 3. */ + /** + * @return Defines the maximum retry for lwt failure 3. + */ @Max(5) @Positive @WithDefault("3") @@ -214,48 +222,67 @@ interface DatabaseConfig { interface QueriesConfig { - /** @return Settings for the consistency level. */ + /** + * @return Settings for the consistency level. + */ @Valid ConsistencyConfig consistency(); - /** @return Serial Consistency for queries. */ + /** + * @return Serial Consistency for queries. + */ @WithDefault("LOCAL_SERIAL") @WithConverter(ConsistencyLevelConverter.class) ConsistencyLevel serialConsistency(); - /** @return Settings for the consistency level. */ + /** + * @return Settings for the consistency level. + */ interface ConsistencyConfig { - /** @return Consistency for queries making schema changes. */ + /** + * @return Consistency for queries making schema changes. + */ @WithDefault("LOCAL_QUORUM") @NotNull @WithConverter(ConsistencyLevelConverter.class) ConsistencyLevel schemaChanges(); - /** @return Consistency for queries writing the data. */ + /** + * @return Consistency for queries writing the data. + */ @WithDefault("LOCAL_QUORUM") @NotNull @WithConverter(ConsistencyLevelConverter.class) ConsistencyLevel writes(); - /** @return Consistency for queries reading the data. */ + /** + * @return Consistency for queries reading the data. + */ @WithDefault("LOCAL_QUORUM") @NotNull @WithConverter(ConsistencyLevelConverter.class) ConsistencyLevel reads(); - /** @return Consistency for vector search queries. */ + /** + * @return Consistency for vector search queries. + */ @WithDefault("LOCAL_ONE") @NotNull @WithConverter(ConsistencyLevelConverter.class) ConsistencyLevel vectorSearch(); } } - /** @return Flag to enable server side vectorization. */ + + /** + * @return Flag to enable server side vectorization. + */ @WithDefault("false") boolean vectorizeEnabled(); - /** @return Flag to enable vectorization using embedding-gateway. */ + /** + * @return Flag to enable vectorization using embedding-gateway. + */ @WithDefault("false") boolean enableEmbeddingGateway(); diff --git a/src/main/java/io/stargate/sgv2/jsonapi/config/constants/HttpConstants.java b/src/main/java/io/stargate/sgv2/jsonapi/config/constants/HttpConstants.java index 0263ea5e02..0cd86ee6ad 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/config/constants/HttpConstants.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/config/constants/HttpConstants.java @@ -15,7 +15,9 @@ public interface HttpConstants { /** JSON API Embedding serive Authentication token header name. */ String EMBEDDING_AUTHENTICATION_TOKEN_HEADER_NAME = "x-embedding-api-key"; - /** @return Embedding service header name 20. */ + /** + * @return Embedding service header name 20. + */ @WithDefault(EMBEDDING_AUTHENTICATION_TOKEN_HEADER_NAME) String embeddingApiKey(); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/config/constants/TableCommentConstants.java b/src/main/java/io/stargate/sgv2/jsonapi/config/constants/TableCommentConstants.java index c841364a89..2c55c87d5e 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/config/constants/TableCommentConstants.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/config/constants/TableCommentConstants.java @@ -4,18 +4,25 @@ public interface TableCommentConstants { /** Top-level key for table comment json */ String TOP_LEVEL_KEY = "collection"; + /** Create collection options key */ String OPTIONS_KEY = "options"; + /** Collection name key */ String COLLECTION_NAME_KEY = "name"; + /** Collection indexing key */ String COLLECTION_INDEXING_KEY = "indexing"; + /** Collection vector key */ String COLLECTION_VECTOR_KEY = "vector"; + /** Schema version key */ String SCHEMA_VERSION_KEY = "schema_version"; + /** Default id type key */ String DEFAULT_ID_KEY = "defaultId"; + /** Schema version value */ int SCHEMA_VERSION_VALUE = 1; } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/cql/ColumnUtils.java b/src/main/java/io/stargate/sgv2/jsonapi/service/cql/ColumnUtils.java index e7452aa1d8..b172ea2357 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/cql/ColumnUtils.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/cql/ColumnUtils.java @@ -23,6 +23,7 @@ public class ColumnUtils { private static final Pattern PATTERN_DOUBLE_QUOTE = Pattern.compile("\"", Pattern.LITERAL); private static final String ESCAPED_DOUBLE_QUOTE = Matcher.quoteReplacement("\"\""); + /** * Updated regex pattern to support selecting collection entry lime map_column['entry_key'], * set_column['set_value'] diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/cql/builder/QueryBuilder.java b/src/main/java/io/stargate/sgv2/jsonapi/service/cql/builder/QueryBuilder.java index 28098ea78a..93df2a28f6 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/cql/builder/QueryBuilder.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/cql/builder/QueryBuilder.java @@ -209,8 +209,9 @@ private void addExpressionCql( condition.jsonTerm.addToCqlValues(values); sb.append(" ").append(condition.predicate.toString()).append(" ?"); } - default -> throw new IllegalArgumentException( - String.format("Unsupported expression type %s", outerExpression.getExprType())); + default -> + throw new IllegalArgumentException( + String.format("Unsupported expression type %s", outerExpression.getExprType())); } } @@ -261,15 +262,18 @@ private String formatFunctionCall(QueryBuilder.FunctionCall functionCall, List functionCalls.add( - FunctionCall.similarityFunctionCall(columnName, "SIMILARITY_COSINE")); - case EUCLIDEAN -> functionCalls.add( - FunctionCall.similarityFunctionCall(columnName, "SIMILARITY_EUCLIDEAN")); - case DOT_PRODUCT -> functionCalls.add( - FunctionCall.similarityFunctionCall(columnName, "SIMILARITY_DOT_PRODUCT")); - default -> throw new JsonApiException( - ErrorCode.VECTOR_SEARCH_INVALID_FUNCTION_NAME, - ErrorCode.VECTOR_SEARCH_INVALID_FUNCTION_NAME.getMessage() + similarityFunction); + case COSINE, UNDEFINED -> + functionCalls.add(FunctionCall.similarityFunctionCall(columnName, "SIMILARITY_COSINE")); + case EUCLIDEAN -> + functionCalls.add( + FunctionCall.similarityFunctionCall(columnName, "SIMILARITY_EUCLIDEAN")); + case DOT_PRODUCT -> + functionCalls.add( + FunctionCall.similarityFunctionCall(columnName, "SIMILARITY_DOT_PRODUCT")); + default -> + throw new JsonApiException( + ErrorCode.VECTOR_SEARCH_INVALID_FUNCTION_NAME, + ErrorCode.VECTOR_SEARCH_INVALID_FUNCTION_NAME.getMessage() + similarityFunction); } return this; } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/CQLSessionCache.java b/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/CQLSessionCache.java index 9c1163c237..8dfb6e12fa 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/CQLSessionCache.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/CQLSessionCache.java @@ -43,14 +43,19 @@ public class CQLSessionCache { * request */ private static final String DEFAULT_TENANT = "default_tenant"; + /** CQL username to be used when the backend is AstraDB */ private static final String TOKEN = "token"; + /** CQLSession cache. */ private final LoadingCache sessionCache; + /** Database type Astra */ public static final String ASTRA = "astra"; + /** Database type OSS cassandra */ public static final String CASSANDRA = "cassandra"; + /** Persistence type SSTable Writer */ public static final String OFFLINE_WRITER = "offline_writer"; diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/TenantAwareCqlSessionBuilder.java b/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/TenantAwareCqlSessionBuilder.java index a7430553fe..317fe32d99 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/TenantAwareCqlSessionBuilder.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/TenantAwareCqlSessionBuilder.java @@ -19,6 +19,7 @@ public class TenantAwareCqlSessionBuilder extends CqlSessionBuilder { * TenantAwareDriverContext */ public static final String TENANT_ID_PROPERTY_KEY = "TENANT_ID"; + /** Tenant ID that will be passed to the CQLSession via TenantAwareDriverContext */ private final String tenantId; diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/executor/CollectionSettings.java b/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/executor/CollectionSettings.java index a1a266ed52..06620a4a27 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/executor/CollectionSettings.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/executor/CollectionSettings.java @@ -176,9 +176,10 @@ public static SimilarityFunction fromString(String similarityFunction) { case "cosine" -> COSINE; case "euclidean" -> EUCLIDEAN; case "dot_product" -> DOT_PRODUCT; - default -> throw new JsonApiException( - ErrorCode.VECTOR_SEARCH_INVALID_FUNCTION_NAME, - ErrorCode.VECTOR_SEARCH_INVALID_FUNCTION_NAME.getMessage() + similarityFunction); + default -> + throw new JsonApiException( + ErrorCode.VECTOR_SEARCH_INVALID_FUNCTION_NAME, + ErrorCode.VECTOR_SEARCH_INVALID_FUNCTION_NAME.getMessage() + similarityFunction); }; } } @@ -226,8 +227,9 @@ public static AuthenticationType fromString(String authenticationType) { case "none" -> NONE; case "header" -> HEADER; case "shared_secret" -> SHARED_SECRET; - default -> throw ErrorCode.VECTORIZE_INVALID_AUTHENTICATION_TYPE.toApiException( - "'%s'", authenticationType); + default -> + throw ErrorCode.VECTORIZE_INVALID_AUTHENTICATION_TYPE.toApiException( + "'%s'", authenticationType); }; } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/executor/QueryExecutor.java b/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/executor/QueryExecutor.java index c19f91f22a..652238ac25 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/executor/QueryExecutor.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/cqldriver/executor/QueryExecutor.java @@ -96,6 +96,7 @@ public CompletionStage executeEstimatedCount( return cqlSessionCache.getSession(dataApiRequestInfo).executeAsync(simpleStatement); } + /** * Execute vector search query with bound statement. * diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/ReadOperation.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/ReadOperation.java index d3967eeddd..c3dc8db378 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/ReadOperation.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/ReadOperation.java @@ -167,6 +167,7 @@ default Uni findDocument( } byte true_byte = (byte) 1; + /** * This method reads upto system fixed limit * @@ -360,6 +361,7 @@ private String extractPageStateFromResultSet(AsyncResultSet rSet) { } return null; } + /** * Default implementation to run count query and parse the result set, this approach counts by key * field diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/DBFilterBase.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/DBFilterBase.java index 4b8db81756..90e51fe2a0 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/DBFilterBase.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/DBFilterBase.java @@ -650,6 +650,7 @@ boolean canAddField() { return false; } } + /** Filter for document where array matches (data in same order) as the array in request */ public static class ArrayEqualsFilter extends MapFilterBase { private final List arrayValue; @@ -700,6 +701,7 @@ boolean canAddField() { return true; } } + /** * Return JsonNode for a filter conditions value, used to set in new document created for upsert. * diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/CommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/CommandResolver.java index 8294595846..7db6b8fd73 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/CommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/CommandResolver.java @@ -27,7 +27,9 @@ */ public interface CommandResolver { - /** @return Returns class of the command the resolver is able to process. */ + /** + * @return Returns class of the command the resolver is able to process. + */ Class getCommandClass(); /** diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/matcher/FilterMatchRules.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/matcher/FilterMatchRules.java index 781c5fb332..a4a0853c3c 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/matcher/FilterMatchRules.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/matcher/FilterMatchRules.java @@ -25,6 +25,7 @@ public class FilterMatchRules { // use the interface rather than MatchRule class so the streaming works. private final List>> matchRules = new ArrayList<>(); + /** * Adds a rule that will result in the specified resolveFunction being called. * diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/schema/model/CqlColumnMatcher.java b/src/main/java/io/stargate/sgv2/jsonapi/service/schema/model/CqlColumnMatcher.java index 0a5569bda8..b64a04e95c 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/schema/model/CqlColumnMatcher.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/schema/model/CqlColumnMatcher.java @@ -10,10 +10,14 @@ /** Interface for matching a CQL column name and type. */ public interface CqlColumnMatcher extends Predicate { - /** @return Column name for the matcher. */ + /** + * @return Column name for the matcher. + */ CqlIdentifier name(); - /** @return If column type is matching. */ + /** + * @return If column type is matching. + */ boolean typeMatches(ColumnMetadata columnSpec); default boolean test(ColumnMetadata columnSpec) { diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/shredding/JsonPath.java b/src/main/java/io/stargate/sgv2/jsonapi/service/shredding/JsonPath.java index 16ba679456..a31a3c7ce3 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/shredding/JsonPath.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/shredding/JsonPath.java @@ -73,7 +73,9 @@ public static Builder rootBuilder() { return new Builder(null); } - /** @return Whether path points to an array element or not */ + /** + * @return Whether path points to an array element or not + */ public boolean isArrayElement() { return arrayElement; } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/shredding/model/DocValueHasher.java b/src/main/java/io/stargate/sgv2/jsonapi/service/shredding/model/DocValueHasher.java index 28f9bf4c55..96fcec6e0b 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/shredding/model/DocValueHasher.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/shredding/model/DocValueHasher.java @@ -46,10 +46,11 @@ public DocValueHash hash(JsonNode value) { case STRING -> stringValue(value.textValue()).hash(); default -> // case BINARY, MISSING, POJO - throw new JsonApiException( - ErrorCode.SHRED_UNRECOGNIZED_NODE_TYPE, - String.format( - "%s: %s", ErrorCode.SHRED_UNRECOGNIZED_NODE_TYPE.getMessage(), value.getNodeType())); + throw new JsonApiException( + ErrorCode.SHRED_UNRECOGNIZED_NODE_TYPE, + String.format( + "%s: %s", + ErrorCode.SHRED_UNRECOGNIZED_NODE_TYPE.getMessage(), value.getNodeType())); }; } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/MetricsTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/MetricsTest.java index 3357e4cabf..06e10b7d1d 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/MetricsTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/MetricsTest.java @@ -51,7 +51,8 @@ public void unauthorizedNamespaceResource() { @Test public void unauthorizedCollectionResource() { - String json = """ + String json = + """ { "find": { } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/configuration/ObjectMapperConfigurationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/configuration/ObjectMapperConfigurationTest.java index 980f708c7d..b521cbd32d 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/configuration/ObjectMapperConfigurationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/configuration/ObjectMapperConfigurationTest.java @@ -281,7 +281,7 @@ public void failForNonEmptyOptions() throws Exception { public void failForTooLongNumbers() { String tooLongNumStr = "1234567890".repeat(11); String json = - """ + """ { "insertOne": { "document": { diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/FilterClauseDeserializerTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/FilterClauseDeserializerTest.java index 8ca94cf556..58d9af91b2 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/FilterClauseDeserializerTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/FilterClauseDeserializerTest.java @@ -35,7 +35,8 @@ class Deserialize { @Test public void happyPath() throws Exception { - String json = """ + String json = + """ {"username": "aaron"} """; @@ -94,7 +95,8 @@ public void testRangeComparisonOperator( @Test public void mustErrorNonNumberAndDateRange() throws Exception { - String json = """ + String json = + """ {"amount": {"$gte" : "ABC"}} """; @@ -120,7 +122,8 @@ public void mustHandleNull() throws Exception { @Test public void mustHandleEmpty() throws Exception { - String json = """ + String json = + """ {} """; @@ -131,7 +134,8 @@ public void mustHandleEmpty() throws Exception { @Test public void mustHandleString() throws Exception { - String json = """ + String json = + """ {"username": "aaron"} """; final ComparisonExpression expectedResult = @@ -153,7 +157,8 @@ ValueComparisonOperator.EQ, new JsonLiteral("aaron", JsonType.STRING))), @Test public void mustHandleNumber() throws Exception { - String json = """ + String json = + """ {"numberType": 40} """; final ComparisonExpression expectedResult = @@ -176,7 +181,8 @@ public void mustHandleNumber() throws Exception { @Test public void mustHandleBoolean() throws Exception { - String json = """ + String json = + """ {"boolType": true} """; final ComparisonExpression expectedResult = @@ -198,7 +204,8 @@ ValueComparisonOperator.EQ, new JsonLiteral(true, JsonType.BOOLEAN))), @Test public void mustHandleDate() throws Exception { - String json = """ + String json = + """ {"dateType": {"$date": 1672531200000}} """; final ComparisonExpression expectedResult = @@ -258,7 +265,8 @@ public void mustHandleDateAndOr() throws Exception { @Test public void mustHandleDateAsEpoch() throws Exception { - String json = """ + String json = + """ {"dateType": {"$date": "2023-01-01"}} """; @@ -275,7 +283,8 @@ public void mustHandleDateAsEpoch() throws Exception { @Test public void mustHandleDateAsEpochAndOr() throws Exception { - String json = """ + String json = + """ { "$or" : [{"dateType": {"$date": "2023-01-01"}}]} """; @@ -385,7 +394,8 @@ ValueComparisonOperator.EQ, new JsonLiteral("testAge", JsonType.STRING))), @Test public void mustHandleAllNonArray() throws Exception { - String json = """ + String json = + """ {"allPath" : {"$all": "abc"}} """; Throwable throwable = catchThrowable(() -> objectMapper.readValue(json, FilterClause.class)); @@ -399,7 +409,8 @@ public void mustHandleAllNonArray() throws Exception { @Test public void mustHandleAllNonEmptyArray() throws Exception { - String json = """ + String json = + """ {"allPath" : {"$all": []}} """; Throwable throwable = catchThrowable(() -> objectMapper.readValue(json, FilterClause.class)); @@ -413,7 +424,8 @@ public void mustHandleAllNonEmptyArray() throws Exception { @Test public void mustHandleSize() throws Exception { - String json = """ + String json = + """ {"sizePath" : {"$size": 2}} """; final ComparisonExpression expectedResult = @@ -436,7 +448,8 @@ public void mustHandleSize() throws Exception { @Test public void mustHandleIntegerWithTrailingZeroSize() throws Exception { - String json = """ + String json = + """ {"sizePath" : {"$size": 0.0}} """; final ComparisonExpression expectedResult = @@ -456,7 +469,8 @@ public void mustHandleIntegerWithTrailingZeroSize() throws Exception { assertThat(filterClause.logicalExpression().comparisonExpressions.get(0).getPath()) .isEqualTo(expectedResult.getPath()); - String json1 = """ + String json1 = + """ {"sizePath" : {"$size": 5.0}} """; final ComparisonExpression expectedResult1 = @@ -479,7 +493,8 @@ public void mustHandleIntegerWithTrailingZeroSize() throws Exception { @Test public void mustHandleSizeNonNumber() throws Exception { - String json = """ + String json = + """ {"sizePath" : {"$size": "2"}} """; Throwable throwable = catchThrowable(() -> objectMapper.readValue(json, FilterClause.class)); @@ -494,7 +509,8 @@ public void mustHandleSizeNonNumber() throws Exception { // Notice, 0.0, -0.0, 5.0, etc are still considered as Integer @Test public void mustHandleSizeNonInteger() throws Exception { - String json = """ + String json = + """ {"sizePath" : {"$size": "1.1"}} """; Throwable throwable = catchThrowable(() -> objectMapper.readValue(json, FilterClause.class)); @@ -505,7 +521,8 @@ public void mustHandleSizeNonInteger() throws Exception { assertThat(t.getMessage()).isEqualTo("$size operator must have integer"); }); - String json1 = """ + String json1 = + """ {"sizePath" : {"$size": "5.4"}} """; Throwable throwable1 = @@ -520,7 +537,8 @@ public void mustHandleSizeNonInteger() throws Exception { @Test public void mustHandleSizeNegative() throws Exception { - String json = """ + String json = + """ {"sizePath" : {"$size": -2}} """; Throwable throwable = catchThrowable(() -> objectMapper.readValue(json, FilterClause.class)); @@ -534,7 +552,8 @@ public void mustHandleSizeNegative() throws Exception { @Test public void mustHandleSubDocEq() throws Exception { - String json = """ + String json = + """ {"sub_doc" : {"col": 2}} """; Map value = new LinkedHashMap<>(); @@ -558,7 +577,8 @@ ValueComparisonOperator.EQ, new JsonLiteral(value, JsonType.SUB_DOC))), @Test public void mustHandleArrayNe() throws Exception { - String json = """ + String json = + """ {"col" : {"$ne": ["1","2"]}} """; final ComparisonExpression expectedResult = @@ -581,7 +601,8 @@ public void mustHandleArrayNe() throws Exception { @Test public void mustHandleArrayEq() throws Exception { - String json = """ + String json = + """ {"col" : {"$eq": ["3","4"]}} """; final ComparisonExpression expectedResult = @@ -604,7 +625,8 @@ public void mustHandleArrayEq() throws Exception { @Test public void mustHandleSubDocNe() throws Exception { - String json = """ + String json = + """ {"sub_doc" : {"$ne" : {"col": 2}}} """; Map value = new LinkedHashMap<>(); @@ -675,7 +697,8 @@ ElementComparisonOperator.EXISTS, new JsonLiteral(true, JsonType.BOOLEAN))), @Test public void mustHandleIdFieldIn() throws Exception { - String json = """ + String json = + """ {"_id" : {"$in": ["2", "3"]}} """; final ComparisonExpression expectedResult = @@ -700,7 +723,8 @@ public void mustHandleIdFieldIn() throws Exception { @Test public void mustHandleNonIdFieldIn() throws Exception { - String json = """ + String json = + """ {"name" : {"$in": ["name1", "name2"]}} """; final ComparisonExpression expectedResult = @@ -1412,7 +1436,8 @@ ValueComparisonOperator.NE, new JsonLiteral("testAddress", JsonType.STRING))), @Test public void mustHandleInArrayNonEmpty() throws Exception { - String json = """ + String json = + """ {"_id" : {"$in": []}} """; final ComparisonExpression expectedResult = @@ -1434,7 +1459,8 @@ ValueComparisonOperator.IN, new JsonLiteral(List.of(), JsonType.ARRAY))), @Test public void mustHandleNinArrayNonEmpty() throws Exception { - String json = """ + String json = + """ {"_id" : {"$nin": []}} """; final ComparisonExpression expectedResult = @@ -1456,7 +1482,8 @@ ValueComparisonOperator.NIN, new JsonLiteral(List.of(), JsonType.ARRAY))), @Test public void mustHandleInArrayOnly() throws Exception { - String json = """ + String json = + """ {"_id" : {"$in": "aaa"}} """; Throwable throwable = catchThrowable(() -> objectMapper.readValue(json, FilterClause.class)); @@ -1470,7 +1497,8 @@ public void mustHandleInArrayOnly() throws Exception { @Test public void mustHandleNinArrayOnly() throws Exception { - String json = """ + String json = + """ {"_id" : {"$nin": "random"}} """; Throwable throwable = catchThrowable(() -> objectMapper.readValue(json, FilterClause.class)); @@ -1575,7 +1603,8 @@ public void multipleIdFilterAndOr() throws Exception { @Test public void invalidPathName() throws Exception { - String json = """ + String json = + """ {"$gt" : {"test" : 5}} """; Throwable throwable = catchThrowable(() -> objectMapper.readValue(json, FilterClause.class)); @@ -1592,7 +1621,8 @@ public void invalidPathName() throws Exception { @Test public void valid$vectorPathName() throws Exception { - String json = """ + String json = + """ {"$vector" : {"$exists": true}} """; @@ -1614,7 +1644,8 @@ public void invalidPathName() throws Exception { @Test public void invalid$vectorPathName() throws Exception { - String json = """ + String json = + """ {"$exists" : {"$vector": true}} """; @@ -1630,7 +1661,8 @@ public void invalidPathName() throws Exception { @Test public void invalidPathNameWithValidOperator() { - String json = """ + String json = + """ {"$exists" : {"$exists": true}} """; Throwable throwable = catchThrowable(() -> objectMapper.readValue(json, FilterClause.class)); @@ -1651,9 +1683,11 @@ class DeserializeWithJsonExtensions { @Test public void mustHandleObjectIdAsId() throws Exception { final String OBJECT_ID = "5f3e3d1e1e6e6f1e6e6e6f1e"; - String json = """ + String json = + """ {"_id": {"$objectId": "%s"}} - """.formatted(OBJECT_ID); + """ + .formatted(OBJECT_ID); final ComparisonExpression expectedResult = new ComparisonExpression( "_id", @@ -1680,9 +1714,10 @@ public void mustHandleObjectIdAsId() throws Exception { public void mustHandleObjectIdAsRegularField() throws Exception { final String OBJECT_ID = "5f3e3d1e1e6e6f1e6e6e6f1e"; String json = - """ + """ {"nested.path": {"$objectId": "%s"}} - """.formatted(OBJECT_ID); + """ + .formatted(OBJECT_ID); final ComparisonExpression expectedResult = new ComparisonExpression( "nested.path", @@ -1703,9 +1738,11 @@ ValueComparisonOperator.EQ, new JsonLiteral(OBJECT_ID, JsonType.STRING))), @Test public void mustHandleUUIDAsId() throws Exception { final String UUID = "16725312-0000-0000-0000-000000000000"; - String json = """ + String json = + """ {"_id": {"$uuid": "%s"}} - """.formatted(UUID); + """ + .formatted(UUID); final ComparisonExpression expectedResult = new ComparisonExpression( "_id", @@ -1730,9 +1767,11 @@ public void mustHandleUUIDAsId() throws Exception { @Test public void mustHandleUUIDAsRegularField() throws Exception { final String UUID = "16725312-0000-0000-0000-000000000000"; - String json = """ + String json = + """ {"value": {"$uuid": "%s"}} - """.formatted(UUID); + """ + .formatted(UUID); final ComparisonExpression expectedResult = new ComparisonExpression( "value", @@ -1752,7 +1791,8 @@ ValueComparisonOperator.EQ, new JsonLiteral(UUID, JsonType.STRING))), @Test public void mustFailOnBadUUIDAsId() throws Exception { - String json = """ + String json = + """ {"_id": {"$uuid": "abc"}} """; @@ -1769,7 +1809,8 @@ public void mustFailOnBadUUIDAsId() throws Exception { @Test public void mustFailOnBadObjectIdAsId() throws Exception { - String json = """ + String json = + """ {"_id": {"$objectId": "xyz"}} """; @@ -1786,7 +1827,8 @@ public void mustFailOnBadObjectIdAsId() throws Exception { @Test public void mustFailOnUnknownOperatorAsId() throws Exception { - String json = """ + String json = + """ {"_id": {"$GUID": "abc"}} """; @@ -1801,7 +1843,8 @@ public void mustFailOnUnknownOperatorAsId() throws Exception { @Test public void mustFailOnBadUUIDAsField() throws Exception { - String json = """ + String json = + """ {"field": {"$uuid": "abc"}} """; diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/SortClauseDeserializerTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/SortClauseDeserializerTest.java index ba37ecbd74..f5b429c5af 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/SortClauseDeserializerTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/SortClauseDeserializerTest.java @@ -45,7 +45,8 @@ public void happyPath() throws Exception { @Test public void happyPathVectorSearch() throws Exception { - String json = """ + String json = + """ { "$vector" : [0.11, 0.22, 0.33] } @@ -62,7 +63,8 @@ public void happyPathVectorSearch() throws Exception { @Test public void vectorSearchEmpty() { - String json = """ + String json = + """ { "$vector" : [] } @@ -76,7 +78,8 @@ public void vectorSearchEmpty() { @Test public void vectorSearchNonArray() { - String json = """ + String json = + """ { "$vector" : 0.55 } @@ -90,7 +93,8 @@ public void vectorSearchNonArray() { @Test public void vectorSearchNonArrayObject() { - String json = """ + String json = + """ { "$vector" : {} } @@ -103,7 +107,8 @@ public void vectorSearchNonArrayObject() { } public void vectorSearchInvalidData() { - String json = """ + String json = + """ { "$vector" : [0.11, "abc", true] } @@ -133,7 +138,8 @@ public void vectorSearchInvalidSortClause() { @Test public void happyPathVectorizeSearch() throws Exception { - String json = """ + String json = + """ { "$vectorize" : "test data" } @@ -149,7 +155,8 @@ public void happyPathVectorizeSearch() throws Exception { @Test public void vectorizeSearchNonText() { - String json = """ + String json = + """ { "$vectorize" : 0.55 } @@ -164,7 +171,8 @@ public void vectorizeSearchNonText() { @Test public void vectorizeSearchObject() { - String json = """ + String json = + """ { "$vectorize" : {} } @@ -196,7 +204,8 @@ public void vectorizeSearchWithOtherSort() { @Test public void mustTrimPath() throws Exception { - String json = """ + String json = + """ {"some.path " : 1} """; @@ -219,7 +228,8 @@ public void mustHandleNull() throws Exception { @Test public void mustBeObject() { - String json = """ + String json = + """ ["primitive"] """; @@ -230,7 +240,8 @@ public void mustBeObject() { @Test public void mustBeCorrectContainerNode() { - String json = """ + String json = + """ {"path": "value"} """; @@ -241,7 +252,8 @@ public void mustBeCorrectContainerNode() { @Test public void mustNotContainBlankString() { - String json = """ + String json = + """ {" " : 1} """; @@ -252,7 +264,8 @@ public void mustNotContainBlankString() { @Test public void mustNotContainEmptyString() { - String json = """ + String json = + """ {"": 1} """; @@ -263,7 +276,8 @@ public void mustNotContainEmptyString() { @Test public void invalidPathName() { - String json = """ + String json = + """ {"$gt": 1} """; Throwable throwable = catchThrowable(() -> objectMapper.readValue(json, SortClause.class)); diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/UpdateClauseDeserializerTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/UpdateClauseDeserializerTest.java index eb49ba43d3..32cc9946d3 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/UpdateClauseDeserializerTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/deserializers/UpdateClauseDeserializerTest.java @@ -52,7 +52,8 @@ public void mustHandleNull() throws Exception { @Test public void mustHandleEmpty() throws Exception { - String json = """ + String json = + """ {} """; @@ -75,7 +76,8 @@ public void mustHandleString() throws Exception { @Test public void mustHandleNumber() throws Exception { - String json = """ + String json = + """ {"$set" : {"numberType": 40}} """; final UpdateOperation operation = @@ -87,7 +89,8 @@ public void mustHandleNumber() throws Exception { @Test public void mustHandleBoolean() throws Exception { - String json = """ + String json = + """ {"$set" : {"boolType": true}} """; final UpdateOperation operation = @@ -99,7 +102,8 @@ public void mustHandleBoolean() throws Exception { @Test public void mustHandleArray() throws Exception { - String json = """ + String json = + """ {"$set" : {"arrayType": ["a"]}} """; diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/CreateCollectionCommandTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/CreateCollectionCommandTest.java index 2e4960ec92..f04fcac40b 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/CreateCollectionCommandTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/CreateCollectionCommandTest.java @@ -68,7 +68,7 @@ public void nameBlank() throws Exception { public void nameTooLong() throws Exception { String name = RandomStringUtils.randomAlphabetic(49); String json = - """ + """ { "createCollection": { "name": "%s" diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/CreateNamespaceCommandTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/CreateNamespaceCommandTest.java index 383f218ffe..a14bc32463 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/CreateNamespaceCommandTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/CreateNamespaceCommandTest.java @@ -47,7 +47,7 @@ public void noName() throws Exception { @Test public void nameTooLong() throws Exception { String json = - """ + """ { "createNamespace": { "name": "%s" diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/DeleteCollectionCommandTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/DeleteCollectionCommandTest.java index 62a0e63ca7..513a42e46e 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/DeleteCollectionCommandTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/DeleteCollectionCommandTest.java @@ -68,7 +68,7 @@ public void nameBlank() throws Exception { public void nameTooLong() throws Exception { String name = RandomStringUtils.randomAlphabetic(49); String json = - """ + """ { "deleteCollection": { "name": "%s" diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/DropNamespaceCommandTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/DropNamespaceCommandTest.java index 3590f40219..f95a22ec22 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/DropNamespaceCommandTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/impl/DropNamespaceCommandTest.java @@ -47,7 +47,7 @@ public void noName() throws Exception { @Test public void nameTooLong() throws Exception { String json = - """ + """ { "dropNamespace": { "name": "%s" diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/serializers/ErrorSerializerTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/serializers/ErrorSerializerTest.java index a5b21b0ad7..a84099d060 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/serializers/ErrorSerializerTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/model/command/serializers/ErrorSerializerTest.java @@ -36,7 +36,8 @@ public void happyPath() throws Exception { String result = objectMapper.writeValueAsString(error); assertThat(result) - .isEqualTo(""" + .isEqualTo( + """ {"message":"My message.","field":"value"}"""); } @@ -48,7 +49,9 @@ public void withoutProps() throws Exception { String result = objectMapper.writeValueAsString(error); - assertThat(result).isEqualTo(""" + assertThat(result) + .isEqualTo( + """ {"message":"My message."}"""); } @@ -74,7 +77,9 @@ public void withNulls() throws Exception { String result = objectMapper.writeValueAsString(error); - assertThat(result).isEqualTo(""" + assertThat(result) + .isEqualTo( + """ {"message":null}"""); } } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/AbstractCollectionIntegrationTestBase.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/AbstractCollectionIntegrationTestBase.java index 648b38f5a0..e272afb909 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/AbstractCollectionIntegrationTestBase.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/AbstractCollectionIntegrationTestBase.java @@ -33,7 +33,7 @@ protected void createSimpleCollection(String collectionToCreate) { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "createCollection": { "name": "%s" @@ -53,7 +53,7 @@ protected void createComplexCollection(String collectionSetting) { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "createCollection": %s } @@ -67,7 +67,8 @@ protected void createComplexCollection(String collectionSetting) { /** Utility to delete all documents from the test collection. */ protected void deleteAllDocuments() { - String json = """ + String json = + """ { "deleteMany": { } @@ -97,7 +98,7 @@ protected void deleteAllDocuments() { /** Utility to insert a doc to the test collection. */ protected void insertDoc(String docJson) { String doc = - """ + """ { "insertOne": { "document": %s @@ -120,7 +121,7 @@ protected void insertDoc(String docJson) { protected void insertDoc(String collection, String docJson) { String doc = - """ + """ { "insertOne": { "document": %s @@ -144,7 +145,7 @@ protected void insertDoc(String collection, String docJson) { /** Utility to insert many docs to the test collection. */ protected void insertManyDocs(String docsJson, int docsAmount) { String doc = - """ + """ { "insertMany": { "documents": %s diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/AbstractNamespaceIntegrationTestBase.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/AbstractNamespaceIntegrationTestBase.java index 45fd2a7364..2521444abb 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/AbstractNamespaceIntegrationTestBase.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/AbstractNamespaceIntegrationTestBase.java @@ -49,7 +49,7 @@ public void createNamespace() { protected void createNamespace(String nsToCreate) { String json = - """ + """ { "createNamespace": { "name": "%s" @@ -74,7 +74,7 @@ protected void createNamespace(String nsToCreate) { @AfterAll public void dropNamespace() { String json = - """ + """ { "dropNamespace": { "name": "%s" diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateCollectionIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateCollectionIntegrationTest.java index 4e82da9c3e..53693d7457 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateCollectionIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateCollectionIntegrationTest.java @@ -75,7 +75,7 @@ class CreateCollection { public void happyPath() { final String collectionName = "col" + RandomStringUtils.randomNumeric(16); String json = - """ + """ { "createCollection": { "name": "%s" @@ -1054,7 +1054,7 @@ private void deleteCollection(String collectionName) { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "deleteCollection": { "name": "%s" diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateNamespaceIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateNamespaceIntegrationTest.java index 58056a19b4..25f52eec8f 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateNamespaceIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateNamespaceIntegrationTest.java @@ -31,7 +31,7 @@ public static void enableLog() { @AfterEach public void deleteKeyspace() { String json = - """ + """ { "dropNamespace": { "name": "%s" @@ -57,7 +57,7 @@ class CreateNamespace { @Test public final void happyPath() { String json = - """ + """ { "createNamespace": { "name": "%s" @@ -80,7 +80,7 @@ public final void happyPath() { @Test public final void alreadyExists() { String json = - """ + """ { "createNamespace": { "name": "%s" @@ -103,7 +103,7 @@ public final void alreadyExists() { @Test public final void withReplicationFactor() { String json = - """ + """ { "createNamespace": { "name": "%s", diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DeleteCollectionIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DeleteCollectionIntegrationTest.java index 561fbc990c..65b12cf438 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DeleteCollectionIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DeleteCollectionIntegrationTest.java @@ -29,7 +29,7 @@ public void happyPath() { // first create String createJson = - """ + """ { "createCollection": { "name": "%s" @@ -50,7 +50,7 @@ public void happyPath() { // then delete String json = - """ + """ { "deleteCollection": { "name": "%s" @@ -76,7 +76,7 @@ public void notExisting() { // delete not existing String json = - """ + """ { "deleteCollection": { "name": "%s" 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 ae18a8c5ff..953acd45fc 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 @@ -234,7 +234,8 @@ public void noFilter() { .body("errors", is(nullValue())); // ensure find does not find the documents - json = """ + json = + """ { "find": { } @@ -283,7 +284,8 @@ public void emptyFilter() { .body("errors", is(nullValue())); // ensure find does not find the documents - json = """ + json = + """ { "find": { } @@ -330,7 +332,8 @@ public void withFilterMoreDataFlag() { .body("errors", is(nullValue())); // ensure only 20 are really deleted - json = """ + json = + """ { "find": { } 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 d6742ced35..41766f0538 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 @@ -427,7 +427,8 @@ class Concurrency { @RepeatedTest(10) public void concurrentDeletes() throws Exception { - String document = """ + String document = + """ { "_id": "concurrent" } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DropNamespaceIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DropNamespaceIntegrationTest.java index 63ee9835d5..a0ff812654 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DropNamespaceIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/DropNamespaceIntegrationTest.java @@ -28,7 +28,7 @@ class DropNamespace { @Test public final void happyPath() { String json = - """ + """ { "dropNamespace": { "name": "%s" @@ -73,7 +73,7 @@ public final void withExistingCollection() { String collection = "c%s".formatted(RandomStringUtils.randomAlphanumeric(8)).toLowerCase(); String createNamespace = - """ + """ { "createNamespace": { "name": "%s" @@ -82,7 +82,7 @@ public final void withExistingCollection() { """ .formatted(keyspace); String createCollection = - """ + """ { "createCollection": { "name": "%s" @@ -111,7 +111,7 @@ public final void withExistingCollection() { .body("status.ok", is(1)); String json = - """ + """ { "dropNamespace": { "name": "%s" diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindCollectionsIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindCollectionsIntegrationTest.java index 85f483d65c..9b7a8a27eb 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindCollectionsIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindCollectionsIntegrationTest.java @@ -66,7 +66,7 @@ public void happyPath() { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "createCollection": { "name": "%s" @@ -102,7 +102,7 @@ public void happyPath() { @Order(3) public void happyPathWithExplain() { String json = - """ + """ { "createCollection": { "name": "%s", @@ -131,7 +131,7 @@ public void happyPathWithExplain() { .body("status.ok", is(1)); String expected1 = - """ + """ { "name": "%s", "options":{} @@ -139,7 +139,7 @@ public void happyPathWithExplain() { """ .formatted("collection1"); String expected2 = - """ + """ { "name": "%s", "options": { @@ -223,7 +223,7 @@ public void emptyNamespace() { // create namespace first String namespace = "nam" + RandomStringUtils.randomNumeric(16); String json = - """ + """ { "createNamespace": { "name": "%s" @@ -263,7 +263,7 @@ public void emptyNamespace() { // cleanup json = - """ + """ { "dropNamespace": { "name": "%s" @@ -313,7 +313,7 @@ public void notExistingNamespace() { @Order(7) public void happyPathIndexingWithExplain() { String json = - """ + """ { "createCollection": { "name": "%s", @@ -350,10 +350,12 @@ public void happyPathIndexingWithExplain() { } } """; - String expected1 = """ + String expected1 = + """ {"name":"TableName","options":{}} """; - String expected2 = """ + String expected2 = + """ {"name":"collection1", "options":{}} """; String expected3 = 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 e5582c70e5..600ca6f057 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 @@ -407,7 +407,8 @@ public void byIdWithProjection() { } """; - String expected = """ + String expected = + """ {"username":"user1"} """; given() @@ -1317,7 +1318,8 @@ public void OrWithIdIn() { @Test public void dollarOperatorInSortPathExpression() { - String json = """ + String json = + """ { "find": { "sort" : {"$gt" : 1} } } """; given() @@ -1339,7 +1341,8 @@ public void dollarOperatorInSortPathExpression() { @Test void emptyPathExpressionInSort() { - String json = """ + String json = + """ { "find": { "sort" : {"" : 1} } } """; given() 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 4447d758fc..b3029f65cb 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 @@ -339,7 +339,7 @@ public void withUpsert() { public void withUpsertNewId() { final String newId = "new-id-1234"; String json = - """ + """ { "findOneAndReplace": { "filter" : {}, @@ -724,7 +724,7 @@ public void projectionBeforeWithoutId() { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "find": { "filter" : {"_id" : "%s"} @@ -762,7 +762,7 @@ public void tryReplaceWithTooLongNumber() { // Max number length: 100; use 110 String tooLongNumStr = "1234567890".repeat(11); String json = - """ + """ { "findOneAndReplace": { "filter" : {"_id" : "tooLongNumber1"}, 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 1a1feaaffe..5a19f19bbf 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 @@ -986,7 +986,7 @@ public void tryUpdateWithTooLongNumber() { // Max number length: 100; use 110 String tooLongNumStr = "1234567890".repeat(11); String json = - """ + """ { "findOneAndUpdate": { "filter" : {"_id" : "update_doc_too_long_number"}, diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndUpdateNoIndexIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndUpdateNoIndexIntegrationTest.java index 61dda88a10..88e396b254 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndUpdateNoIndexIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindOneAndUpdateNoIndexIntegrationTest.java @@ -35,7 +35,7 @@ class CreateCollection { @Test public void createBaseCollection() { String json = - """ + """ { "createCollection": { "name": "%s", @@ -150,7 +150,7 @@ public void byIdBeforeUpdate() { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "insertOne": { "document": %s @@ -207,7 +207,7 @@ public void allowNonIndexedBigArray() { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "findOneAndUpdate": { "filter" : {"_id" : "array_size_big_noindex_doc"}, @@ -238,7 +238,7 @@ public void failOnIndexedTooBigArray() { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "findOneAndUpdate": { "filter" : {"_id" : "array_size_too_big_doc"}, @@ -278,7 +278,7 @@ public void allowNonIndexedBigObject() { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "findOneAndUpdate": { "filter" : {"_id" : "object_size_big_noindex_doc"}, @@ -310,7 +310,7 @@ public void failOnIndexedTooBigObject() { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "findOneAndUpdate": { "filter" : {"_id" : "object_size_too_big_doc"}, @@ -342,7 +342,7 @@ private void insertEmptyDoc(String docId) { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "insertOne": { "document": { 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 467118dbc6..04669865f7 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 @@ -765,7 +765,7 @@ class FindOneWithJSONExtensions { private final String UUID_X = "BB3F3A87-98B7-4B85-B1D1-706A9FBC6807"; private final String DOC1 = - """ + """ { "_id": {"$objectId": "%s"}, "value": 1, @@ -777,7 +777,7 @@ class FindOneWithJSONExtensions { .formatted(OBJECTID_ID1); private final String DOC2 = - """ + """ { "_id": {"$uuid": "%s"}, "value": 2, @@ -788,7 +788,7 @@ class FindOneWithJSONExtensions { """ .formatted(UUID_ID1); private final String DOC3 = - """ + """ { "_id": "id3", "value": 3, @@ -799,7 +799,7 @@ class FindOneWithJSONExtensions { """ .formatted(OBJECTID_LEAF); private final String DOC4 = - """ + """ { "_id": "id4", "value": 4, @@ -823,7 +823,7 @@ public void setUp() { @Order(2) public void inConditionForObjectIdId() { final String request = - """ + """ { "findOne": { "filter" : {"_id" : {"$in": [ @@ -854,7 +854,7 @@ public void inConditionForObjectIdId() { @Order(3) public void inConditionForUUIDId() { final String request = - """ + """ { "findOne": { "filter" : {"_id" : {"$in": [ @@ -885,7 +885,7 @@ public void inConditionForUUIDId() { @Order(4) public void inConditionForObjectIdField() { final String request = - """ + """ { "findOne": { "filter" : {"stuff.id" : {"$in": [ @@ -916,7 +916,7 @@ public void inConditionForObjectIdField() { @Order(5) public void inConditionForUUIDField() { final String request = - """ + """ { "findOne": { "filter" : {"stuff.id" : {"$in": [ 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 e5118ed3ae..18f7ea2231 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 @@ -192,7 +192,7 @@ class ProjectionWithJSONExtensions { private static final String UUID1 = "123e4567-e89b-12d3-a456-426614174000"; private static final String OBJECTID1 = "5f3b3e3b3e3b3e3b3e3b3e3b"; private static final String EXT_DOC1 = - """ + """ { "_id": "ext1", "username": "user1", @@ -250,7 +250,7 @@ public void byIdIncludeExtValues() { .body( "data.document", jsonEquals( - """ + """ { "_id": "ext1", "uid": { "$uuid": "%s" }, diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/IndexingConfigIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/IndexingConfigIntegrationTest.java index 0a8b5c4852..7208681b5d 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/IndexingConfigIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/IndexingConfigIntegrationTest.java @@ -58,7 +58,7 @@ public void createCollectionAndData() { } """; String denyOneIndexingCollectionSetting = - """ + """ { "name": "%s", "options" : { @@ -74,7 +74,7 @@ public void createCollectionAndData() { """ .formatted(denyOneIndexingCollection); String denyManyIndexingCollectionSetting = - """ + """ { "name": "%s", "options" : { @@ -90,7 +90,7 @@ public void createCollectionAndData() { """ .formatted(denyManyIndexingCollection); String denyAllIndexingCollectionSetting = - """ + """ { "name": "%s", "options" : { @@ -106,7 +106,7 @@ public void createCollectionAndData() { """ .formatted(denyAllIndexingCollection); String allowOneIndexingCollectionSetting = - """ + """ { "name": "%s", "options" : { @@ -122,7 +122,7 @@ public void createCollectionAndData() { """ .formatted(allowOneIndexingCollection); String allowManyIndexingCollectionSetting = - """ + """ { "name": "%s", "options" : { 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 de183887d8..0717eed72c 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 @@ -531,7 +531,7 @@ class InsertOneWithJsonExtensions { @Test void createCollectionWithAutoGenerated() { createComplexCollection( - """ + """ { "name": "%s", "options" : { @@ -549,7 +549,7 @@ void createCollectionWithAutoGenerated() { public void insertDocWithUUIDKey() { final String UUID_KEY = UUID.randomUUID().toString(); String doc = - """ + """ { "_id": { "$uuid": "%s"}, "value": 42 @@ -598,7 +598,7 @@ public void insertDocWithUUIDKey() { public void insertDocWithObjectIdKey() { final String OBJECTID_KEY = new ObjectId().toHexString(); String doc = - """ + """ { "_id": { "$objectId": "%s"}, "value": "unknown" @@ -698,7 +698,7 @@ public void insertDocWithUUIDValues() { final String UUID_VALUE = UUID.randomUUID().toString(); final String UUID_VALUE2 = UUID.randomUUID().toString(); String doc = - """ + """ { "_id": "%s", "value": { "$uuid": "%s"}, @@ -738,7 +738,7 @@ public void insertDocWithObjectIdValues() { final String OBJECTID_VALUE = new ObjectId().toHexString(); final String OBJECTID_VALUE2 = new ObjectId().toHexString(); String doc = - """ + """ { "_id": "%s", "subdoc": { @@ -883,7 +883,7 @@ public void tryInsertTooBigArray() { arr.add(i); } final String json = - """ + """ { "insertOne": { "document": %s @@ -935,7 +935,7 @@ public void tryInsertTooLongPath() { ObjectNode prop3 = prop2.putObject("c".repeat(250)); prop3.put("d".repeat(250), true); final String json = - """ + """ { "insertOne": { "document": %s @@ -985,7 +985,7 @@ public void tryInsertTooLongNumber() { // Max number length: 100; use 110 String tooLongNumStr = "1234567890".repeat(11); String json = - """ + """ { "insertOne": { "document": { @@ -1034,7 +1034,7 @@ public void tryInsertTooLongString() { final String tooLongString = createBigString(DocumentLimitsConfig.DEFAULT_MAX_STRING_LENGTH_IN_BYTES + 50); String json = - """ + """ { "insertOne": { "document": { @@ -1102,7 +1102,7 @@ public void tryInsertTooLongDoc() throws Exception { JsonNode bigDoc = createBigDoc("bigValidDoc", DocumentLimitsConfig.DEFAULT_MAX_DOCUMENT_SIZE + 100_000); String json = - """ + """ { "insertOne": { "document": %s @@ -1139,7 +1139,7 @@ public void tryInsertDocWithTooBigObject() { } String json = - """ + """ { "insertOne": { "document": %s @@ -1182,7 +1182,7 @@ public void tryInsertDocWithTooManyProps() { } String json = - """ + """ { "insertOne": { "document": %s @@ -1210,7 +1210,7 @@ public void tryInsertDocWithTooManyProps() { private void _verifyInsert(String docId, JsonNode doc) { final String json = - """ + """ { "insertOne": { "document": %s @@ -1236,7 +1236,7 @@ private void _verifyInsert(String docId, JsonNode doc) { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "find": { "filter": {"_id" : "%s"} @@ -1741,7 +1741,7 @@ public void tryInsertTooLongNumber() { String tooLongNumStr = "1234567890".repeat(11); String json = - """ + """ { "insertMany": { "documents": [ @@ -1779,7 +1779,7 @@ public void insertBigButNotTooBigPayload() { final int bigSize = DocumentLimitsConfig.DEFAULT_MAX_DOCUMENT_SIZE - 50_000; // 5 x bit under 4 M should be just under limit String json = - """ + """ { "insertMany": { "documents": [ @@ -1814,7 +1814,7 @@ public void insertBigButNotTooBigPayload() { public void tryInsertTooBigPayload() { final int bigSize = DocumentLimitsConfig.DEFAULT_MAX_DOCUMENT_SIZE - 50_000; String json = - """ + """ { "insertMany": { "documents": [ @@ -1879,7 +1879,7 @@ public void insertManyWithTooManyDocuments() { docs.add(doc); } String json = - """ + """ { "insertMany": { "documents": %s 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 2bde18d5ac..403a105e94 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 @@ -97,7 +97,8 @@ public void mixedOperations() throws Exception { latch.await(); // ensure there's nothing left - String json = """ + String json = + """ { "find": { } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/PaginationIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/PaginationIntegrationTest.java index 44e213cedc..9a94f1c008 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/PaginationIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/PaginationIntegrationTest.java @@ -27,7 +27,7 @@ class NormalFunction { public void setUp() { for (int i = 0; i < documentAmount; i++) { insert( - """ + """ { "insertOne": { "document": { @@ -78,7 +78,7 @@ public void twoPagesCheck() { .path("data.nextPageState"); String json1 = - """ + """ { "find": { "options":{ @@ -107,7 +107,7 @@ public void twoPagesCheck() { @Order(3) public void pageLimitCheck() { String json = - """ + """ { "find": { "options": { 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 8ba425e99f..a7faaea760 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 @@ -181,7 +181,8 @@ public void byColumn() { .body("errors", is(nullValue())); // assert all updated - json = """ + json = + """ { "find": { } @@ -320,7 +321,7 @@ public void updatePagination() { .path("status.nextPageState"); json = - """ + """ { "updateMany": { "filter" : {"active_user" : true}, diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorSearchIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorSearchIntegrationTest.java index b2b6030ff7..38763dc9e2 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorSearchIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorSearchIntegrationTest.java @@ -100,7 +100,7 @@ public void failForTooBigVector() { .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "createCollection": { "name" : "TooBigVectorCollection", @@ -260,7 +260,7 @@ public void insertBigVectorThenSearch() { // And finally search for it (with different vector) final String vectorSearchStr = buildVectorElements(3, BIG_VECTOR_SIZE); final String findRequest = - """ + """ { "find": { "sort" : {"$vector" : [%s]}, @@ -1200,7 +1200,7 @@ public void setBigVectorOperation() { // then set the vector final String vectorStr = buildVectorElements(7, BIG_VECTOR_SIZE); String json = - """ + """ { "findOneAndUpdate": { "filter" : {"_id": "bigVectorForSet"}, @@ -1425,7 +1425,7 @@ public void findOneAndReplaceWithBigVector() { // then set the vector final String vectorStr = buildVectorElements(2, BIG_VECTOR_SIZE); String json = - """ + """ { "findOneAndReplace": { "filter" : {"_id" : "bigVectorForFindReplace"}, @@ -1561,7 +1561,7 @@ public void insertVectorWithUnmatchedSize() { // Insert data with $vector array size less than vector index defined size. final String vectorStrCount3 = buildVectorElements(0, 3); String jsonVectorStrCount3 = - """ + """ { "insertOne": { "document": { @@ -1589,7 +1589,7 @@ public void insertVectorWithUnmatchedSize() { // Insert data with $vector array size greater than vector index defined size. final String vectorStrCount7 = buildVectorElements(0, 7); String jsonVectorStrCount7 = - """ + """ { "insertOne": { "document": { @@ -1621,7 +1621,7 @@ public void findVectorWithUnmatchedSize() { // Sort clause with $vector array size greater than vector index defined size. final String vectorStrCount3 = buildVectorElements(0, 3); String jsonVectorStrCount3 = - """ + """ { "find": { "sort" : {"$vector" : [ %s ]}, @@ -1647,7 +1647,7 @@ public void findVectorWithUnmatchedSize() { // Insert data with $vector array size greater than vector index defined size. final String vectorStrCount7 = buildVectorElements(0, 7); String jsonVectorStrCount7 = - """ + """ { "find": { "sort" : {"$vector" : [ %s ]}, @@ -1742,7 +1742,7 @@ private void createVectorCollection(String namespaceName, String collectionName, .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "createCollection": { "name" : "%s", @@ -1765,7 +1765,7 @@ private void createVectorCollection(String namespaceName, String collectionName, private void insertBigVectorDoc(String id, String name, String description, String vectorStr) { final String vectorDoc = - """ + """ { "_id": "%s", "name": "%s", @@ -1782,7 +1782,7 @@ private void insertBigVectorDoc(String id, String name, String description, Stri .headers(getHeaders()) .contentType(ContentType.JSON) .body( - """ + """ { "insertOne": { "document": %s diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorizeSearchIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorizeSearchIntegrationTest.java index 0d58a5a7c6..767a5c6653 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorizeSearchIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorizeSearchIntegrationTest.java @@ -442,7 +442,8 @@ public void insertVectorSearch() { } public void insertVectorDocuments() { - String json = """ + String json = + """ { "deleteMany": { } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/IncOperationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/IncOperationTest.java index 792b54c4fa..4d416de5d8 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/IncOperationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/IncOperationTest.java @@ -214,6 +214,7 @@ public void testIncWithNonNumberParam() { ErrorCode.UNSUPPORTED_UPDATE_OPERATION_PARAM.getMessage() + ": $inc requires numeric parameter, got: STRING"); } + // Not legal to try to modify doc id (immutable): @Test public void testIncOnDocumentId() { @@ -237,7 +238,8 @@ public void testIncOnRootStringProperty() { """); UpdateOperation oper = UpdateOperator.INC.resolveOperation( - objectFromJson(""" + objectFromJson( + """ { "prop" : 57 } """)); Exception e = diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/MulOperationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/MulOperationTest.java index 6b89c1600c..281e1bae72 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/MulOperationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/MulOperationTest.java @@ -198,6 +198,7 @@ public void testMulWithNonNumberParam() { ErrorCode.UNSUPPORTED_UPDATE_OPERATION_PARAM.getMessage() + ": $mul requires numeric parameter, got: STRING"); } + // Not legal to try to modify doc id (immutable): @Test public void testMulOnDocumentId() { diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/SetOperationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/SetOperationTest.java index 2e32cc36dc..0ed9da50aa 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/SetOperationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/SetOperationTest.java @@ -117,7 +117,8 @@ public void testOrderedSetOfNonExisting() { public void testSimpleSetWithoutChange() { UpdateOperation oper = UpdateOperator.SET.resolveOperation( - objectFromJson(""" + objectFromJson( + """ { "c" : true } """)); assertThat(oper).isInstanceOf(SetOperation.class); @@ -327,7 +328,8 @@ public void testNoChangeForIdenticalObject() { ObjectNode expected = doc.deepCopy(); UpdateOperation oper = UpdateOperator.SET.resolveOperation( - objectFromJson(""" + objectFromJson( + """ { "people" : { "name":"Bob", "age":42 } } """)); // No actual change @@ -348,7 +350,8 @@ public void testChangeForObjectWithDifferentFieldOrder() { """); UpdateOperation oper = UpdateOperator.SET.resolveOperation( - objectFromJson(""" + objectFromJson( + """ { "people": { "age":42, "name":"Bob" } } """)); ObjectNode expected = @@ -393,18 +396,22 @@ public void testNoReplacingDocIdWithSet() { public void testReplaceDocIdWithSetOnInsert() { UpdateOperation oper = UpdateOperator.SET_ON_INSERT.resolveOperation( - objectFromJson(""" + objectFromJson( + """ { "_id": 1 } """)); assertThat(oper).isInstanceOf(SetOperation.class); // Should indicate document being modified ObjectNode doc = - objectFromJson(""" + objectFromJson( + """ { "_id": 0, "a": 1 } """); assertThat(oper.updateDocument(doc)).isTrue(); assertThat(doc) - .isEqualTo(fromJson(""" + .isEqualTo( + fromJson( + """ { "_id": 1, "a": 1 } """)); } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/UnsetOperationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/UnsetOperationTest.java index d042d31c1e..258465c4b1 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/UnsetOperationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/operation/model/command/clause/update/UnsetOperationTest.java @@ -28,7 +28,8 @@ public void testSimpleUnsetOfExisting() { // Remove 2 of 3 properties: UpdateOperation oper = UpdateOperator.UNSET.resolveOperation( - objectFromJson(""" + objectFromJson( + """ { "a" : 1, "b" : 1 } """)); assertThat(oper).isInstanceOf(UnsetOperation.class); @@ -37,7 +38,9 @@ public void testSimpleUnsetOfExisting() { assertThat(oper.updateDocument(doc)).isTrue(); // and be left with just one property assertThat(doc) - .isEqualTo(fromJson(""" + .isEqualTo( + fromJson( + """ { "c" : true } """)); } @@ -47,7 +50,8 @@ public void testSimpleUnsetOfExistingVector() { // Remove 2 of 3 properties: UpdateOperation oper = UpdateOperator.UNSET.resolveOperation( - objectFromJson(""" + objectFromJson( + """ { "$vector" : null } """)); assertThat(oper).isInstanceOf(UnsetOperation.class); diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/processor/MeteredCommandProcessorTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/processor/MeteredCommandProcessorTest.java index edf707230e..1de0a3af0d 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/processor/MeteredCommandProcessorTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/processor/MeteredCommandProcessorTest.java @@ -89,7 +89,8 @@ public void metrics() throws Exception { @Test public void errorMetricsWithNoErrorCode() throws Exception { - String json = """ + String json = + """ { "find": { diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/FindCommandResolverTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/FindCommandResolverTest.java index e8d14343d0..ea2643e1ff 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/FindCommandResolverTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/FindCommandResolverTest.java @@ -280,7 +280,8 @@ public void byIdInAndOtherConditionTogether() throws Exception { @Test public void noFilterCondition() throws Exception { - String json = """ + String json = + """ { "find": { } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/shredding/ShredderTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/shredding/ShredderTest.java index c3917d9558..953758a6fd 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/shredding/ShredderTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/shredding/ShredderTest.java @@ -225,7 +225,7 @@ class EJSONDateTime { public void shredDocWithDateTimeColumn() { final long testTimestamp = defaultTestDate().getTime(); final String inputJson = - """ + """ { "_id" : 123, "name" : "Bob", @@ -418,7 +418,7 @@ public void shredVectorize9K() throws Exception { Arrays.fill(arr, 'A'); String str = new String(arr); final String inputJson = - """ + """ { "_id" : 123, "name" : "Bob", "values" : [ 1, 2 ], @@ -649,7 +649,7 @@ public void shredWithIndexDenyAll() throws Exception { public void shredWithHugeNonIndexedString() throws Exception { final String hugeString = "abcd".repeat(240_000); // about 960K, close to max doc of 1M final String inputJson = - """ + """ { "_id": 1, "name": "Mo", "blob": "%s" diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/shredding/ShredderWithExtendedTypesTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/shredding/ShredderWithExtendedTypesTest.java index 28aad6a5b8..039428ea50 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/shredding/ShredderWithExtendedTypesTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/shredding/ShredderWithExtendedTypesTest.java @@ -52,7 +52,7 @@ public void shredSimpleWithUUIDKeyAndValue() throws Exception { final String idUUID = defaultTestUUID().toString(); final String valueUUID = defaultTestUUID2().toString(); final String inputJson = - """ + """ { "_id" : {"$uuid": "%s"}, "name" : "Bob", "extraId" : {"$uuid": "%s"} @@ -104,7 +104,7 @@ public void shredSimpleWithObjectIdKeyAndValue() throws Exception { final String idObjectId = defaultTestObjectId().toString(); final String valueObjectId = defaultTestObjectId2().toString(); final String inputJson = - """ + """ { "_id" : {"$objectId": "%s"}, "name" : "Bob", "objectId2" : {"$objectId": "%s"} diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/updater/DocumentUpdaterTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/updater/DocumentUpdaterTest.java index 39f9f527da..1ed14f2557 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/updater/DocumentUpdaterTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/updater/DocumentUpdaterTest.java @@ -142,7 +142,8 @@ public void setVectorData() throws Exception { JsonNode baseData = objectMapper.readTree(BASE_DOC_JSON_VECTOR); JsonNode expectedData = objectMapper.readTree(expected); - String vectorData = """ + String vectorData = + """ {"$vector" : [0.25, 0.25, 0.25] } """; DocumentUpdater documentUpdater = @@ -242,7 +243,8 @@ public void unsetUpdateData() throws Exception { class UpdateDocumentInvalid { @Test public void invalidUpdateOperator() throws Exception { - String updateClause = """ + String updateClause = + """ {"location": "New York"}, """; Throwable t = @@ -259,7 +261,8 @@ public void invalidUpdateOperator() throws Exception { @Test public void unsupportedUpdateOperator() throws Exception { - String updateClause = """ + String updateClause = + """ {"$pullAll": { "count" : 5}} """; Throwable t = diff --git a/src/test/offline/io/stargate/sgv2/jsonapi/service/cqldriver/sstablewriter/FileWriterSessionTest.java b/src/test/offline/io/stargate/sgv2/jsonapi/service/cqldriver/sstablewriter/FileWriterSessionTest.java index 7bb08c0713..8fd4a26c3d 100644 --- a/src/test/offline/io/stargate/sgv2/jsonapi/service/cqldriver/sstablewriter/FileWriterSessionTest.java +++ b/src/test/offline/io/stargate/sgv2/jsonapi/service/cqldriver/sstablewriter/FileWriterSessionTest.java @@ -34,7 +34,10 @@ public static void setup(@TempDir File tempDir) throws IOException { @Test public void testInit() - throws IOException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException, + throws IOException, + NoSuchFieldException, + IllegalAccessException, + NoSuchMethodException, InvocationTargetException { CQLSessionCache cqlSessionCache = mock(CQLSessionCache.class); CQLSessionCache.SessionCacheKey cacheKey = null;