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 5b60582ff..fdde608ea 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 @@ -13,7 +13,7 @@ /** * Use the {@link CommandResultBuilder} to create a {@link CommandResult} for a command response, - * for creation see {@link #singleDocumentBuilder(boolean, boolean)} and the other factory methods. + * for creation see {@link #singleDocumentBuilder(boolean)} and the other factory methods. * *

Comments on {@link CommandResultBuilder} explain future work here. */ @@ -65,24 +65,18 @@ public record CommandResult( * Also the {@link io.stargate.sgv2.jsonapi.service.operation.OperationAttemptPageBuilder} is how * things will turn out. */ - public static CommandResultBuilder singleDocumentBuilder( - boolean useErrorObjectV2, boolean debugMode) { - return new CommandResultBuilder( - CommandResultBuilder.ResponseType.SINGLE_DOCUMENT, useErrorObjectV2, debugMode); + public static CommandResultBuilder singleDocumentBuilder(boolean debugMode) { + return new CommandResultBuilder(CommandResultBuilder.ResponseType.SINGLE_DOCUMENT, debugMode); } - /** See {@link #singleDocumentBuilder(boolean, boolean)} */ - public static CommandResultBuilder multiDocumentBuilder( - boolean useErrorObjectV2, boolean debugMode) { - return new CommandResultBuilder( - CommandResultBuilder.ResponseType.MULTI_DOCUMENT, useErrorObjectV2, debugMode); + /** See {@link #singleDocumentBuilder(boolean)} */ + public static CommandResultBuilder multiDocumentBuilder(boolean debugMode) { + return new CommandResultBuilder(CommandResultBuilder.ResponseType.MULTI_DOCUMENT, debugMode); } - /** See {@link #singleDocumentBuilder(boolean, boolean)} */ - public static CommandResultBuilder statusOnlyBuilder( - boolean useErrorObjectV2, boolean debugMode) { - return new CommandResultBuilder( - CommandResultBuilder.ResponseType.STATUS_ONLY, useErrorObjectV2, debugMode); + /** See {@link #singleDocumentBuilder(boolean)} */ + public static CommandResultBuilder statusOnlyBuilder(boolean debugMode) { + return new CommandResultBuilder(CommandResultBuilder.ResponseType.STATUS_ONLY, debugMode); } /** diff --git a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/CommandResultBuilder.java b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/CommandResultBuilder.java index 44d27850b..7e33eb820 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/CommandResultBuilder.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/CommandResultBuilder.java @@ -37,9 +37,6 @@ public enum ResponseType { // If the debug mode is enabled, errors include the errorclass private final boolean debugMode; - // Flagged true to include the new error object v2 - private final boolean useErrorObjectV2; - // Created in the Ctor private final APIExceptionCommandErrorBuilder apiExceptionToError; @@ -47,13 +44,12 @@ public enum ResponseType { // but may not be returning V2 errors in the result private final APIExceptionCommandErrorBuilder apiWarningToError; - CommandResultBuilder(ResponseType responseType, boolean useErrorObjectV2, boolean debugMode) { + CommandResultBuilder(ResponseType responseType, boolean debugMode) { this.responseType = responseType; - this.useErrorObjectV2 = useErrorObjectV2; this.debugMode = debugMode; - this.apiExceptionToError = new APIExceptionCommandErrorBuilder(debugMode, useErrorObjectV2); - this.apiWarningToError = new APIExceptionCommandErrorBuilder(debugMode, true); + this.apiExceptionToError = new APIExceptionCommandErrorBuilder(debugMode); + this.apiWarningToError = new APIExceptionCommandErrorBuilder(debugMode); } public CommandResultBuilder addStatus(CommandStatus status, Object value) { @@ -103,9 +99,7 @@ public CommandResultBuilder nextPageState(String nextPageState) { return this; } - /** - * Gets the appropriately formatted error given {@link #useErrorObjectV2} and {@link #debugMode}. - */ + /** Gets the appropriately formatted error given {@link #debugMode}. */ public CommandResult.Error throwableToCommandError(Throwable throwable) { if (throwable instanceof APIException apiException) { diff --git a/src/main/java/io/stargate/sgv2/jsonapi/api/security/challenge/impl/ErrorChallengeSender.java b/src/main/java/io/stargate/sgv2/jsonapi/api/security/challenge/impl/ErrorChallengeSender.java index 1a165b66c..0413bb991 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/api/security/challenge/impl/ErrorChallengeSender.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/api/security/challenge/impl/ErrorChallengeSender.java @@ -44,8 +44,7 @@ public ErrorChallengeSender(ObjectMapper objectMapper) { CommandResult.Error error = new CommandResult.Error( message, Collections.emptyMap(), Collections.emptyMap(), Response.Status.UNAUTHORIZED); - commandResult = - CommandResult.statusOnlyBuilder(false, false).addCommandResultError(error).build(); + commandResult = CommandResult.statusOnlyBuilder(false).addCommandResultError(error).build(); } /** {@inheritDoc} */ 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 0f502ad38..e6743af44 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/config/OperationsConfig.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/config/OperationsConfig.java @@ -66,12 +66,6 @@ public interface OperationsConfig { @WithDefault("false") boolean enableEmbeddingGateway(); - /** - * @return Flag to extend error response with additional information. - */ - @WithDefault("true") - boolean extendError(); - /** * @return Defines the maximum limit of document read to perform in memory sorting 10000 * . diff --git a/src/main/java/io/stargate/sgv2/jsonapi/exception/APIExceptionCommandErrorBuilder.java b/src/main/java/io/stargate/sgv2/jsonapi/exception/APIExceptionCommandErrorBuilder.java index 3fdf5026c..fb492684b 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/exception/APIExceptionCommandErrorBuilder.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/exception/APIExceptionCommandErrorBuilder.java @@ -18,20 +18,15 @@ public class APIExceptionCommandErrorBuilder { private final boolean debugEnabled; - private final boolean returnErrorObjectV2; /** * Create a new instance that will create a {@link CommandResult.Error} with the given options. * * @param debugEnabled if true the {@link CommandResult.Error} will include the * {@link ErrorObjectV2Constants.Fields#EXCEPTION_CLASS} field. - * @param returnErrorObjectV2 if true will include the fields for the V2 error object - * such as family etc */ - public APIExceptionCommandErrorBuilder(boolean debugEnabled, boolean returnErrorObjectV2) { - + public APIExceptionCommandErrorBuilder(boolean debugEnabled) { this.debugEnabled = debugEnabled; - this.returnErrorObjectV2 = returnErrorObjectV2; } /** @@ -57,12 +52,11 @@ public CommandResult.Error buildLegacyCommandResultError(APIException apiExcepti // errorFields.put(ErrorObjectV2Constants.Fields.MESSAGE, apiException.body); errorFields.put(ErrorObjectV2Constants.Fields.CODE, apiException.code); - if (returnErrorObjectV2) { - errorFields.put(ErrorObjectV2Constants.Fields.FAMILY, apiException.family.name()); - errorFields.put(ErrorObjectV2Constants.Fields.SCOPE, apiException.scope); - errorFields.put(ErrorObjectV2Constants.Fields.TITLE, apiException.title); - errorFields.put(ErrorObjectV2Constants.Fields.ID, apiException.errorId); - } + errorFields.put(ErrorObjectV2Constants.Fields.FAMILY, apiException.family.name()); + errorFields.put(ErrorObjectV2Constants.Fields.SCOPE, apiException.scope); + errorFields.put(ErrorObjectV2Constants.Fields.TITLE, apiException.title); + errorFields.put(ErrorObjectV2Constants.Fields.ID, apiException.errorId); + if (debugEnabled) { errorFields.put( ErrorObjectV2Constants.Fields.EXCEPTION_CLASS, apiException.getClass().getSimpleName()); @@ -83,16 +77,6 @@ public CommandResult.Error buildLegacyCommandResultError(APIException apiExcepti * @return a {@link CommandErrorV2} that represents the apiException. */ public CommandErrorV2 buildCommandErrorV2(APIException apiException) { - if (!returnErrorObjectV2) { - // aaron - oct 9 - I know this seems silly, we are in the process on moving all the errors to - // the V2 - // i added this function to be used with WARNING errors, once we have rolled out the use of - // CommandErrorV2 - // everywhere we wont need this test and there will be one build function - throw new IllegalStateException( - "Cannot build a V2 error object when returnErrorObjectV2 is false"); - } - var builder = CommandErrorV2.builderV2(); if (debugEnabled) { diff --git a/src/main/java/io/stargate/sgv2/jsonapi/exception/JsonApiException.java b/src/main/java/io/stargate/sgv2/jsonapi/exception/JsonApiException.java index 9f273e6ed..692794ebb 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/exception/JsonApiException.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/exception/JsonApiException.java @@ -135,7 +135,7 @@ public CommandResult get() { message = errorCode.getMessage(); } - var builder = CommandResult.statusOnlyBuilder(false, false); + var builder = CommandResult.statusOnlyBuilder(false); // construct and return builder.addCommandResultError(getCommandResultError(message, httpStatus)); @@ -163,26 +163,21 @@ public CommandResult.Error getCommandResultError(String message, Response.Status } DebugModeConfig debugModeConfig = config.getConfigMapping(DebugModeConfig.class); final boolean debugEnabled = debugModeConfig.enabled(); - final boolean extendError = config.getConfigMapping(OperationsConfig.class).extendError(); Map fields; - if (extendError) { - fields = - new HashMap<>( - Map.of( - "id", - id, - "errorCode", - errorCode.name(), - "family", - errorFamily, - "scope", - errorScope, - "title", - title)); - } else { - fields = new HashMap<>(Map.of("errorCode", errorCode.name())); - } + fields = + new HashMap<>( + Map.of( + "id", + id, + "errorCode", + errorCode.name(), + "family", + errorFamily, + "scope", + errorScope, + "title", + title)); if (debugEnabled) { fields.put("exceptionClass", this.getClass().getSimpleName()); diff --git a/src/main/java/io/stargate/sgv2/jsonapi/exception/mappers/ConstraintViolationExceptionMapper.java b/src/main/java/io/stargate/sgv2/jsonapi/exception/mappers/ConstraintViolationExceptionMapper.java index 29ca731be..a70771723 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/exception/mappers/ConstraintViolationExceptionMapper.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/exception/mappers/ConstraintViolationExceptionMapper.java @@ -34,7 +34,7 @@ public RestResponse constraintViolationException( ConstraintViolationException exception) { // map all violations to errors Set> violations = exception.getConstraintViolations(); - var builder = CommandResult.statusOnlyBuilder(false, false); + var builder = CommandResult.statusOnlyBuilder(false); violations.stream() .map(ConstraintViolationExceptionMapper::getError) .distinct() diff --git a/src/main/java/io/stargate/sgv2/jsonapi/exception/mappers/ThrowableCommandResultSupplier.java b/src/main/java/io/stargate/sgv2/jsonapi/exception/mappers/ThrowableCommandResultSupplier.java index 090319f12..2f14338ab 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/exception/mappers/ThrowableCommandResultSupplier.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/exception/mappers/ThrowableCommandResultSupplier.java @@ -14,7 +14,7 @@ public record ThrowableCommandResultSupplier(Throwable t) implements Supplier webApplicationExceptionMapper(WebApplicationE // V2 Error are returned as APIException, this is required to translate the exception to // CommandResult if the exception thrown as part of command deserialization if (toReport instanceof APIException ae) { - var errorBuilder = - new APIExceptionCommandErrorBuilder( - debugModeConfig.enabled(), operationsConfig.extendError()); + var errorBuilder = new APIExceptionCommandErrorBuilder(debugModeConfig.enabled()); return RestResponse.ok( - CommandResult.statusOnlyBuilder(false, false) + CommandResult.statusOnlyBuilder(false) .addCommandResultError(errorBuilder.buildLegacyCommandResultError(ae)) .build()); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/DeleteAttemptPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/DeleteAttemptPage.java index 221525295..3aab50b78 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/DeleteAttemptPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/DeleteAttemptPage.java @@ -50,8 +50,7 @@ public DeleteAttemptPage getOperationPage() { // returning a document // e.g. for findOneAndDelete, for now it is always status only - return new DeleteAttemptPage<>( - attempts, CommandResult.statusOnlyBuilder(useErrorObjectV2, debugMode)); + return new DeleteAttemptPage<>(attempts, CommandResult.statusOnlyBuilder(debugMode)); } } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/InsertAttemptPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/InsertAttemptPage.java index 1d01b3316..832809cf0 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/InsertAttemptPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/InsertAttemptPage.java @@ -177,9 +177,7 @@ public Builder returnDocumentResponses(boolean returnDocumentResponses) public InsertAttemptPage getOperationPage() { return new InsertAttemptPage<>( - attempts, - CommandResult.statusOnlyBuilder(useErrorObjectV2, debugMode), - returnDocumentResponses); + attempts, CommandResult.statusOnlyBuilder(debugMode), returnDocumentResponses); } } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/InsertOperationPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/InsertOperationPage.java index 193682ea0..c63d5f706 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/InsertOperationPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/InsertOperationPage.java @@ -79,7 +79,7 @@ public InsertOperationPage( this.failedInsertions = new ArrayList<>(allAttemptedInsertions.size()); this.debugMode = debugMode; this.useErrorObjectV2 = useErrorObjectV2; - this.apiExceptionToError = new APIExceptionCommandErrorBuilder(debugMode, useErrorObjectV2); + this.apiExceptionToError = new APIExceptionCommandErrorBuilder(debugMode); } enum InsertionStatus { @@ -102,7 +102,7 @@ public CommandResult get() { // TODO AARON used to only sort the success list when not returning detailed responses, check OK Collections.sort(successfulInsertions); - var builder = CommandResult.statusOnlyBuilder(useErrorObjectV2, debugMode); + var builder = CommandResult.statusOnlyBuilder(debugMode); return returnDocumentResponses ? perDocumentResult(builder) : nonPerDocumentResult(builder); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/MetadataAttemptPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/MetadataAttemptPage.java index 210295116..4a65681ba 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/MetadataAttemptPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/MetadataAttemptPage.java @@ -67,10 +67,7 @@ public Builder usingCommandStatus(CommandStatus statusKey) { public Supplier getOperationPage() { return new MetadataAttemptPage<>( - attempts, - CommandResult.statusOnlyBuilder(useErrorObjectV2, debugMode), - showSchema, - statusKey) {}; + attempts, CommandResult.statusOnlyBuilder(debugMode), showSchema, statusKey) {}; } } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/OperationAttemptPageBuilder.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/OperationAttemptPageBuilder.java index 2b4c70bdf..345bec09d 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/OperationAttemptPageBuilder.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/OperationAttemptPageBuilder.java @@ -18,7 +18,6 @@ public abstract class OperationAttemptPageBuilder< SchemaT extends SchemaObject, AttemptT extends OperationAttempt> extends OperationAttemptAccumulator { - protected boolean useErrorObjectV2 = false; protected boolean debugMode = false; /** @@ -29,16 +28,6 @@ public abstract class OperationAttemptPageBuilder< */ public abstract Supplier getOperationPage(); - /** - * Sets if the error object v2 formatting should be used when building the {@link CommandResult}. - */ - @SuppressWarnings("unchecked") - public > SubT useErrorObjectV2( - boolean useErrorObjectV2) { - this.useErrorObjectV2 = useErrorObjectV2; - return (SubT) this; - } - /** * Set if API is running in debug mode, this adds additional info to the response. See {@link * io.stargate.sgv2.jsonapi.api.model.command.CommandResultBuilder}. diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/ReadAttemptPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/ReadAttemptPage.java index 6635078e5..28a2e9b34 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/ReadAttemptPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/ReadAttemptPage.java @@ -139,8 +139,8 @@ public ReadAttemptPage getOperationPage() { var resultBuilder = singleResponse - ? CommandResult.singleDocumentBuilder(useErrorObjectV2, debugMode) - : CommandResult.multiDocumentBuilder(useErrorObjectV2, debugMode); + ? CommandResult.singleDocumentBuilder(debugMode) + : CommandResult.multiDocumentBuilder(debugMode); return new ReadAttemptPage<>( attempts, resultBuilder, pagingState, includeSortVector, sortVector); diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/ReadOperationPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/ReadOperationPage.java index e910d9641..2f0b0d35a 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/ReadOperationPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/ReadOperationPage.java @@ -32,8 +32,8 @@ public CommandResult get() { var builder = singleResponse - ? CommandResult.singleDocumentBuilder(false, false) - : CommandResult.multiDocumentBuilder(false, false); + ? CommandResult.singleDocumentBuilder(false) + : CommandResult.multiDocumentBuilder(false); if (includeSortVector) { builder.addStatus(CommandStatus.SORT_VECTOR, vector); diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/SchemaAttemptPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/SchemaAttemptPage.java index 66793631c..7d4b44c40 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/SchemaAttemptPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/SchemaAttemptPage.java @@ -36,8 +36,7 @@ public static class Builder @Override public SchemaAttemptPage getOperationPage() { - return new SchemaAttemptPage<>( - attempts, CommandResult.statusOnlyBuilder(useErrorObjectV2, debugMode)); + return new SchemaAttemptPage<>(attempts, CommandResult.statusOnlyBuilder(debugMode)); } } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/TruncateAttemptPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/TruncateAttemptPage.java index cdf1b9e6a..e3339e70a 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/TruncateAttemptPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/TruncateAttemptPage.java @@ -42,8 +42,7 @@ public static class Builder @Override public TruncateAttemptPage getOperationPage() { - return new TruncateAttemptPage<>( - attempts, CommandResult.statusOnlyBuilder(useErrorObjectV2, debugMode)); + return new TruncateAttemptPage<>(attempts, CommandResult.statusOnlyBuilder(debugMode)); } } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/UpdateAttemptPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/UpdateAttemptPage.java index b91522493..c17698c33 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/UpdateAttemptPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/UpdateAttemptPage.java @@ -50,8 +50,7 @@ public UpdateAttemptPage getOperationPage() { // when we refactor collections to use the OperationAttempt this will need to support // returning a document // e.g. for findOneAndDelete, for now it is always status only - return new UpdateAttemptPage<>( - attempts, CommandResult.statusOnlyBuilder(useErrorObjectV2, debugMode)); + return new UpdateAttemptPage<>(attempts, CommandResult.statusOnlyBuilder(debugMode)); } } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/CountOperationPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/CountOperationPage.java index 1b565a3ce..b22bd4803 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/CountOperationPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/CountOperationPage.java @@ -9,8 +9,7 @@ public record CountOperationPage(long count, boolean moreData) implements Suppli public CommandResult get() { var builder = - CommandResult.statusOnlyBuilder(false, false) - .addStatus(CommandStatus.COUNTED_DOCUMENT, count); + CommandResult.statusOnlyBuilder(false).addStatus(CommandStatus.COUNTED_DOCUMENT, count); if (moreData) { builder.addStatus(CommandStatus.MORE_DATA, true); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/DeleteOperationPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/DeleteOperationPage.java index 8f90eedb4..136f5b1ef 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/DeleteOperationPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/DeleteOperationPage.java @@ -44,18 +44,18 @@ public CommandResult get() { // aaron - this is a giant hack 21 oct 2024 if (returnDocument()) { if (singleDocument()) { - return CommandResult.singleDocumentBuilder(false, false) + return CommandResult.singleDocumentBuilder(false) .addStatus(CommandStatus.DELETED_COUNT, 0) .addDocument(null) .build(); } else { - return CommandResult.multiDocumentBuilder(false, false) + return CommandResult.multiDocumentBuilder(false) .addStatus(CommandStatus.DELETED_COUNT, 0) .addDocument(null) .build(); } } else { - return CommandResult.statusOnlyBuilder(false, false) + return CommandResult.statusOnlyBuilder(false) .addStatus(CommandStatus.DELETED_COUNT, -1) .build(); } @@ -107,16 +107,16 @@ public CommandResult get() { CommandResultBuilder builder = null; if (returnDocument()) { if (singleDocument()) { - builder = CommandResult.singleDocumentBuilder(false, false); + builder = CommandResult.singleDocumentBuilder(false); } else { - builder = CommandResult.multiDocumentBuilder(false, false); + builder = CommandResult.multiDocumentBuilder(false); } // aaron - ok to add the list to the builder as I assume there will only be one id single doc // return. // the builder will fail if we created single doc and then added more than one builder.addDocuments(deletedDoc); } else { - builder = CommandResult.statusOnlyBuilder(false, false); + builder = CommandResult.statusOnlyBuilder(false); } builder.addStatus(CommandStatus.DELETED_COUNT, deletedCount).addCommandResultError(errors); diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/EstimatedCountResult.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/EstimatedCountResult.java index 13456eb32..e2d41906a 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/EstimatedCountResult.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/EstimatedCountResult.java @@ -7,7 +7,7 @@ public record EstimatedCountResult(long count) implements Supplier { @Override public CommandResult get() { - return CommandResult.statusOnlyBuilder(false, false) + return CommandResult.statusOnlyBuilder(false) .addStatus(CommandStatus.COUNTED_DOCUMENT, count) .build(); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/FindCollectionsCollectionOperation.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/FindCollectionsCollectionOperation.java index c6feca762..7a733e441 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/FindCollectionsCollectionOperation.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/FindCollectionsCollectionOperation.java @@ -96,7 +96,7 @@ private record Result(boolean explain, List collections) @Override public CommandResult get() { - var builder = CommandResult.statusOnlyBuilder(false, false); + var builder = CommandResult.statusOnlyBuilder(false); if (explain) { final List createCollectionCommands = collections.stream() diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/SchemaChangeResult.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/SchemaChangeResult.java index b71f2a079..ac8c31467 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/SchemaChangeResult.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/SchemaChangeResult.java @@ -7,7 +7,7 @@ public record SchemaChangeResult(boolean schemaChanged) implements Supplier { @Override public CommandResult get() { - return CommandResult.statusOnlyBuilder(false, false) + return CommandResult.statusOnlyBuilder(false) .addStatus(CommandStatus.OK, schemaChanged ? 1 : 0) .build(); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/ServiceRegistrationResult.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/ServiceRegistrationResult.java index 70e0517e7..61b7e76a4 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/ServiceRegistrationResult.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/ServiceRegistrationResult.java @@ -7,6 +7,6 @@ public record ServiceRegistrationResult() implements Supplier { @Override public CommandResult get() { - return CommandResult.singleDocumentBuilder(false, false).addStatus(CommandStatus.OK, 1).build(); + return CommandResult.singleDocumentBuilder(false).addStatus(CommandStatus.OK, 1).build(); } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/UpdateCollectionOperationPage.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/UpdateCollectionOperationPage.java index b7b4fc730..979da1d1f 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/UpdateCollectionOperationPage.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/collections/UpdateCollectionOperationPage.java @@ -30,8 +30,8 @@ public CommandResult get() { var builder = returnDocs - ? CommandResult.singleDocumentBuilder(false, false) - : CommandResult.statusOnlyBuilder(false, false); + ? CommandResult.singleDocumentBuilder(false) + : CommandResult.statusOnlyBuilder(false); // aggregate the errors by error code or error class Multimap groupedErrorUpdates = diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/embeddings/FindEmbeddingProvidersOperation.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/embeddings/FindEmbeddingProvidersOperation.java index 2bdb65eea..578ea76a8 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/embeddings/FindEmbeddingProvidersOperation.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/embeddings/FindEmbeddingProvidersOperation.java @@ -41,7 +41,7 @@ private record Result(Map embeddingProviders) @Override public CommandResult get() { - return CommandResult.statusOnlyBuilder(false, false) + return CommandResult.statusOnlyBuilder(false) .addStatus(CommandStatus.EXISTING_VECTOR_PROVIDERS, embeddingProviders) .build(); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/keyspaces/FindKeyspacesOperation.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/keyspaces/FindKeyspacesOperation.java index 3cf349e57..dada17f96 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/keyspaces/FindKeyspacesOperation.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/keyspaces/FindKeyspacesOperation.java @@ -68,7 +68,7 @@ public CommandResult get() { var statusKey = useKeyspaceNaming ? CommandStatus.EXISTING_KEYSPACES : CommandStatus.EXISTING_NAMESPACES; - return CommandResult.statusOnlyBuilder(false, false).addStatus(statusKey, keyspaces).build(); + return CommandResult.statusOnlyBuilder(false).addStatus(statusKey, keyspaces).build(); } } } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/processor/CommandProcessor.java b/src/main/java/io/stargate/sgv2/jsonapi/service/processor/CommandProcessor.java index cdf696a67..6d4772992 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/processor/CommandProcessor.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/processor/CommandProcessor.java @@ -7,7 +7,6 @@ import io.stargate.sgv2.jsonapi.api.model.command.DeprecatedCommand; import io.stargate.sgv2.jsonapi.api.request.DataApiRequestInfo; import io.stargate.sgv2.jsonapi.config.DebugModeConfig; -import io.stargate.sgv2.jsonapi.config.OperationsConfig; import io.stargate.sgv2.jsonapi.exception.APIException; import io.stargate.sgv2.jsonapi.exception.APIExceptionCommandErrorBuilder; import io.stargate.sgv2.jsonapi.exception.JsonApiException; @@ -66,7 +65,6 @@ public Uni processCom DataApiRequestInfo dataApiRequestInfo, CommandContext commandContext, T command) { var debugMode = commandContext.getConfig(DebugModeConfig.class).enabled(); - var errorObjectV2 = commandContext.getConfig(OperationsConfig.class).extendError(); // vectorize the data return dataVectorizerService @@ -100,13 +98,12 @@ public Uni processCom // new error object V2 var errorBuilder = new APIExceptionCommandErrorBuilder( - commandContext.getConfig(DebugModeConfig.class).enabled(), - commandContext.getConfig(OperationsConfig.class).extendError()); + commandContext.getConfig(DebugModeConfig.class).enabled()); // yet more mucking about with suppliers everywhere :( yield (Supplier) () -> - CommandResult.statusOnlyBuilder(errorObjectV2, debugMode) + CommandResult.statusOnlyBuilder(debugMode) .addCommandResultError( errorBuilder.buildLegacyCommandResultError(apiException)) .build(); @@ -139,7 +136,7 @@ public Uni processCom if (command instanceof DeprecatedCommand deprecatedCommand) { // for the warnings we always want V2 errors and do not want / need debug ? var errorV2 = - new APIExceptionCommandErrorBuilder(false, true) + new APIExceptionCommandErrorBuilder(false) .buildCommandErrorV2(deprecatedCommand.getDeprecationWarning()); commandResult.addWarning(errorV2); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/AlterTableCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/AlterTableCommandResolver.java index 06de62cb2..6473d24b9 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/AlterTableCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/AlterTableCommandResolver.java @@ -80,8 +80,7 @@ public Operation resolveTableCommand( var pageBuilder = SchemaAttemptPage.builder() - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation<>(attempts, pageBuilder, new TableDriverExceptionHandler()); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/CreateIndexCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/CreateIndexCommandResolver.java index 543720b33..9ad22600c 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/CreateIndexCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/CreateIndexCommandResolver.java @@ -57,8 +57,7 @@ public Operation resolveTableCommand( var pageBuilder = SchemaAttemptPage.builder() - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation<>( new OperationAttemptContainer<>(attempt), diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/CreateTableCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/CreateTableCommandResolver.java index a0dc4345d..86aedd40d 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/CreateTableCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/CreateTableCommandResolver.java @@ -64,8 +64,7 @@ public Operation resolveKeyspaceCommand( var pageBuilder = SchemaAttemptPage.builder() - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation<>( attempts, pageBuilder, new CreateTableExceptionHandler(tableName)); diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/CreateVectorIndexCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/CreateVectorIndexCommandResolver.java index d45bcb129..556765c2e 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/CreateVectorIndexCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/CreateVectorIndexCommandResolver.java @@ -54,8 +54,7 @@ public Operation resolveTableCommand( var pageBuilder = SchemaAttemptPage.builder() - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation<>( new OperationAttemptContainer<>(attempt), diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DeleteManyCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DeleteManyCommandResolver.java index bda380cb2..fdbdd796c 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DeleteManyCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DeleteManyCommandResolver.java @@ -70,8 +70,7 @@ public Operation resolveTableCommand( var attemptContainer = new OperationAttemptContainer<>(truncateAttempt); var truncatePageBuilder = TruncateAttemptPage.builder() - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation<>( attemptContainer, truncatePageBuilder, new TableDriverExceptionHandler()); } @@ -83,8 +82,7 @@ public Operation resolveTableCommand( ctx.schemaObject(), tableFilterResolver.resolve(ctx, command).target()); var deletePageBuilder = DeleteAttemptPage.builder() - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); var attempts = new OperationAttemptContainer<>(deleteAttemptBuilder.build(where)); return new GenericOperation<>(attempts, deletePageBuilder, new TableDriverExceptionHandler()); diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DeleteOneCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DeleteOneCommandResolver.java index 128786dc0..852e0afb3 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DeleteOneCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DeleteOneCommandResolver.java @@ -85,8 +85,7 @@ public Operation resolveTableCommand( var pageBuilder = DeleteAttemptPage.builder() - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation<>(attempts, pageBuilder, new TableDriverExceptionHandler()); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DropIndexCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DropIndexCommandResolver.java index 831da970e..c1f7e02bc 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DropIndexCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DropIndexCommandResolver.java @@ -55,8 +55,7 @@ public Operation resolveKeyspaceCommand( var pageBuilder = SchemaAttemptPage.builder() - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation<>(attempts, pageBuilder, new DropIndexExceptionHandler(indexName)); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DropTableCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DropTableCommandResolver.java index 9a719c2b0..cc05e4bbb 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DropTableCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/DropTableCommandResolver.java @@ -56,8 +56,7 @@ public Operation resolveKeyspaceCommand( var pageBuilder = SchemaAttemptPage.builder() - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation<>(attempts, pageBuilder, new DropTableExceptionHandler(tableName)); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/InsertManyCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/InsertManyCommandResolver.java index 14dadf889..fd586d2eb 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/InsertManyCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/InsertManyCommandResolver.java @@ -3,7 +3,6 @@ import io.stargate.sgv2.jsonapi.api.model.command.CommandContext; import io.stargate.sgv2.jsonapi.api.model.command.impl.InsertManyCommand; import io.stargate.sgv2.jsonapi.config.DebugModeConfig; -import io.stargate.sgv2.jsonapi.config.OperationsConfig; import io.stargate.sgv2.jsonapi.service.cqldriver.executor.TableSchemaObject; import io.stargate.sgv2.jsonapi.service.operation.*; import io.stargate.sgv2.jsonapi.service.operation.collections.CollectionInsertAttemptBuilder; @@ -71,8 +70,7 @@ public Operation resolveTableCommand( var pageBuilder = InsertAttemptPage.builder() .returnDocumentResponses(returnDocumentResponses) - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation<>(attempts, pageBuilder, new TableDriverExceptionHandler()); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/InsertOneCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/InsertOneCommandResolver.java index 0b097ec2e..54d01bcb4 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/InsertOneCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/InsertOneCommandResolver.java @@ -3,7 +3,6 @@ import io.stargate.sgv2.jsonapi.api.model.command.CommandContext; import io.stargate.sgv2.jsonapi.api.model.command.impl.InsertOneCommand; import io.stargate.sgv2.jsonapi.config.DebugModeConfig; -import io.stargate.sgv2.jsonapi.config.OperationsConfig; import io.stargate.sgv2.jsonapi.service.cqldriver.executor.TableSchemaObject; import io.stargate.sgv2.jsonapi.service.operation.*; import io.stargate.sgv2.jsonapi.service.operation.collections.CollectionInsertAttemptBuilder; @@ -62,8 +61,7 @@ public Operation resolveTableCommand( var pageBuilder = InsertAttemptPage.builder() .returnDocumentResponses(false) // always false for single document insert - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation<>(attempts, pageBuilder, new TableDriverExceptionHandler()); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/ListTablesCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/ListTablesCommandResolver.java index 09c15a305..463851752 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/ListTablesCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/ListTablesCommandResolver.java @@ -5,7 +5,6 @@ import io.stargate.sgv2.jsonapi.api.model.command.CommandStatus; import io.stargate.sgv2.jsonapi.api.model.command.impl.ListTablesCommand; import io.stargate.sgv2.jsonapi.config.DebugModeConfig; -import io.stargate.sgv2.jsonapi.config.OperationsConfig; import io.stargate.sgv2.jsonapi.service.cqldriver.CQLSessionCache; import io.stargate.sgv2.jsonapi.service.cqldriver.executor.KeyspaceSchemaObject; import io.stargate.sgv2.jsonapi.service.operation.GenericOperation; @@ -52,8 +51,7 @@ public Operation resolveKeyspaceCommand( MetadataAttemptPage.builder() .showSchema(explain) .usingCommandStatus(CommandStatus.EXISTING_TABLES) - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation(attempts, pageBuilder, new KeyspaceDriverExceptionHandler()); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/ReadCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/ReadCommandResolver.java index dbadcda90..d2d79d3ed 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/ReadCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/ReadCommandResolver.java @@ -119,9 +119,7 @@ protected GenericOperation> bu var attempts = new OperationAttemptContainer<>(attemptBuilder.build(where)); // the common page builder options - pageBuilder - .debugMode(commandContext.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(commandContext.getConfig(OperationsConfig.class).extendError()); + pageBuilder.debugMode(commandContext.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation<>(attempts, pageBuilder, new TableDriverExceptionHandler()); } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/UpdateOneCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/UpdateOneCommandResolver.java index 210d0c134..7261a251e 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/UpdateOneCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/UpdateOneCommandResolver.java @@ -101,8 +101,7 @@ public Operation resolveTableCommand( var pageBuilder = UpdateAttemptPage.builder() - .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()) - .useErrorObjectV2(ctx.getConfig(OperationsConfig.class).extendError()); + .debugMode(ctx.getConfig(DebugModeConfig.class).enabled()); return new GenericOperation<>(attempts, pageBuilder, new TableDriverExceptionHandler()); } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/response/CommandResultToRestResponseTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/response/CommandResultToRestResponseTest.java index 6a08cd4e1..ee0133f8d 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/response/CommandResultToRestResponseTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/response/CommandResultToRestResponseTest.java @@ -21,7 +21,7 @@ class RestResponseMapper { @Test public void happyPath() { CommandResult result = - CommandResult.statusOnlyBuilder(false, false).addStatus(CommandStatus.OK, 1).build(); + CommandResult.statusOnlyBuilder(false).addStatus(CommandStatus.OK, 1).build(); final RestResponse mappedResult = result.toRestResponse(); assertThat(mappedResult.getStatus()).isEqualTo(RestResponse.Status.OK.getStatusCode()); } @@ -29,7 +29,7 @@ public void happyPath() { @Test public void errorWithOkStatus() { CommandResult result = - CommandResult.statusOnlyBuilder(false, false) + CommandResult.statusOnlyBuilder(false) .addCommandResultError( new CommandResult.Error( "My message.", @@ -45,7 +45,7 @@ public void errorWithOkStatus() { @Test public void unauthorized() { CommandResult result = - CommandResult.statusOnlyBuilder(false, false) + CommandResult.statusOnlyBuilder(false) .addCommandResultError( new CommandResult.Error( "My message.", @@ -62,7 +62,7 @@ public void unauthorized() { @Test public void badGateway() { CommandResult result = - CommandResult.statusOnlyBuilder(false, false) + CommandResult.statusOnlyBuilder(false) .addCommandResultError( new CommandResult.Error( "My message.", @@ -79,7 +79,7 @@ public void badGateway() { @Test public void internalError() { CommandResult result = - CommandResult.statusOnlyBuilder(false, false) + CommandResult.statusOnlyBuilder(false) .addCommandResultError( new CommandResult.Error( "My message.", @@ -96,7 +96,7 @@ public void internalError() { @Test public void gatewayError() { CommandResult result = - CommandResult.statusOnlyBuilder(false, false) + CommandResult.statusOnlyBuilder(false) .addCommandResultError( new CommandResult.Error( "My message.", diff --git a/src/test/java/io/stargate/sgv2/jsonapi/exception/APIExceptionCommandErrorBuilderTest.java b/src/test/java/io/stargate/sgv2/jsonapi/exception/APIExceptionCommandErrorBuilderTest.java index 1293a2cce..d98fb2b27 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/exception/APIExceptionCommandErrorBuilderTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/exception/APIExceptionCommandErrorBuilderTest.java @@ -22,14 +22,14 @@ String getErrorConfigResource() { public void productionModeCommandResult() { var exception = TestRequestException.Code.NO_VARIABLES_TEMPLATE.get(); var result = - new APIExceptionCommandErrorBuilder(false, true).buildLegacyCommandResultError(exception); + new APIExceptionCommandErrorBuilder(false).buildLegacyCommandResultError(exception); assertCommandError(exception, result, 5, true); } @Test public void productionModeCommandErrorV2() { var exception = TestRequestException.Code.NO_VARIABLES_TEMPLATE.get(); - var result = new APIExceptionCommandErrorBuilder(false, true).buildCommandErrorV2(exception); + var result = new APIExceptionCommandErrorBuilder(false).buildCommandErrorV2(exception); assertCommandErrorV2(exception, result); } @@ -37,15 +37,14 @@ public void productionModeCommandErrorV2() { public void preErrorV2ModeCommandResult() { var exception = TestRequestException.Code.NO_VARIABLES_TEMPLATE.get(); var result = - new APIExceptionCommandErrorBuilder(false, true).buildLegacyCommandResultError(exception); + new APIExceptionCommandErrorBuilder(false).buildLegacyCommandResultError(exception); assertCommandError(exception, result, 1, false); } @Test public void debugModeCommandResult() { var exception = TestRequestException.Code.NO_VARIABLES_TEMPLATE.get(); - var result = - new APIExceptionCommandErrorBuilder(true, true).buildLegacyCommandResultError(exception); + var result = new APIExceptionCommandErrorBuilder(true).buildLegacyCommandResultError(exception); assertCommandError(exception, result, 6, true); assertThat(result) @@ -61,7 +60,7 @@ public void debugModeCommandResult() { @Test public void debugModeCommandErrorV2() { var exception = TestRequestException.Code.NO_VARIABLES_TEMPLATE.get(); - var result = new APIExceptionCommandErrorBuilder(true, true).buildCommandErrorV2(exception); + var result = new APIExceptionCommandErrorBuilder(true).buildCommandErrorV2(exception); assertCommandErrorV2(exception, result); assertThat(result) 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 fd57ada06..2cdd60ed4 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 @@ -52,7 +52,7 @@ public void metrics() throws Exception { objectMapper.readValue(json, CountDocumentsCommand.class); CommandContext commandContext = TestConstants.COLLECTION_CONTEXT; - CommandResult commandResult = CommandResult.statusOnlyBuilder(false, false).build(); + CommandResult commandResult = CommandResult.statusOnlyBuilder(false).build(); Mockito.when( commandProcessor.processCommand(dataApiRequestInfo, commandContext, countCommand)) @@ -108,7 +108,7 @@ public void errorMetricsWithNoErrorCode() throws Exception { CommandResult.Error error = new CommandResult.Error("message", fields, fields, Response.Status.OK); CommandResult commandResult = - CommandResult.statusOnlyBuilder(false, false).addCommandResultError(error).build(); + CommandResult.statusOnlyBuilder(false).addCommandResultError(error).build(); Mockito.when( commandProcessor.processCommand(dataApiRequestInfo, commandContext, countCommand)) @@ -168,7 +168,7 @@ public void errorMetrics() throws Exception { CommandResult.Error error = new CommandResult.Error("message", fields, fields, Response.Status.OK); CommandResult commandResult = - CommandResult.statusOnlyBuilder(false, false).addCommandResultError(error).build(); + CommandResult.statusOnlyBuilder(false).addCommandResultError(error).build(); Mockito.when( commandProcessor.processCommand(dataApiRequestInfo, commandContext, countCommand)) .thenReturn(Uni.createFrom().item(commandResult));