Skip to content

Commit

Permalink
realtes to #178: adapt delete commands per spec, improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Senic committed Mar 2, 2023
1 parent e6c9f3f commit 8c91a0d
Show file tree
Hide file tree
Showing 10 changed files with 848 additions and 373 deletions.
19 changes: 15 additions & 4 deletions src/main/java/io/stargate/sgv2/jsonapi/StargateJsonApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"""
{
"deleteMany": {
"filter": {"city": "London"}
"filter": {"location": "London"}
}
}
"""),
Expand Down Expand Up @@ -379,13 +379,24 @@
}
"""),
@ExampleObject(
name = "resultDelete",
summary = "Delete command result",
name = "resultDeleteOne",
summary = "`deleteOne` command result",
value =
"""
{
"status": {
"deletedIds": ["1", "2"],
"deletedCount": 1
}
}
"""),
@ExampleObject(
name = "resultDeleteMany",
summary = "`deleteMany` command result",
value =
"""
{
"status": {
"deletedCount": 2,
"moreData" : true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,23 @@
import io.stargate.sgv2.jsonapi.api.model.command.Filterable;
import io.stargate.sgv2.jsonapi.api.model.command.ModifyCommand;
import io.stargate.sgv2.jsonapi.api.model.command.clause.filter.FilterClause;
import javax.annotation.Nullable;
import javax.validation.Valid;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

/**
* Representation of the deleteMany API {@link Command}.
*
* @param filterClause {@link FilterClause} used to identify the document.
* @param filterClause {@link FilterClause} used to identify documents.
*/
@Schema(
description =
"Command that finds documents based on the filter and deletes it from a collection")
"Command that finds documents based on the filter and deletes them from a collection")
@JsonTypeName("deleteMany")
public record DeleteManyCommand(
@Schema(
description = "Filter clause based on which document is identified",
description = "Filter clause based on which documents are identified",
implementation = FilterClause.class)
@Valid
@JsonProperty("filter")
FilterClause filterClause,
@Nullable Options options)
implements ModifyCommand, Filterable {
public record Options() {}
}
FilterClause filterClause)
implements ModifyCommand, Filterable {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
import io.stargate.sgv2.jsonapi.api.model.command.Filterable;
import io.stargate.sgv2.jsonapi.api.model.command.ModifyCommand;
import io.stargate.sgv2.jsonapi.api.model.command.clause.filter.FilterClause;
import javax.annotation.Nullable;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

/**
* Representation of the deleteOne API {@link Command}.
*
* @param filterClause {@link FilterClause} used to identify the document.
* @param filterClause {@link FilterClause} used to identify a document.
*/
@Schema(description = "Command that finds a single document and deletes it from a collection")
@JsonTypeName("deleteOne")
Expand All @@ -25,8 +24,5 @@ public record DeleteOneCommand(
implementation = FilterClause.class)
@Valid
@JsonProperty("filter")
FilterClause filterClause,
@Nullable Options options)
implements ModifyCommand, Filterable {
public record Options() {}
}
FilterClause filterClause)
implements ModifyCommand, Filterable {}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public CollectionResource(CommandProcessor commandProcessor) {
@ExampleObject(ref = "resultFindOneAndUpdate"),
@ExampleObject(ref = "resultInsert"),
@ExampleObject(ref = "resultError"),
@ExampleObject(ref = "resultDelete"),
@ExampleObject(ref = "resultDeleteOne"),
@ExampleObject(ref = "resultDeleteMany"),
@ExampleObject(ref = "resultUpdateMany"),
@ExampleObject(ref = "resultUpdateOne"),
})))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ public static void enableLog() {
}

@Test
@Order(1)
@Order(Integer.MIN_VALUE)
public final void createCollection() {
String json =
String.format(
"""
{
"createCollection": {
"name": "%s"
}
}
""",
{
"createCollection": {
"name": "%s"
}
}
""",
collectionName);

given()
.header(HttpConstants.AUTHENTICATION_TOKEN_HEADER_NAME, getAuthToken())
.contentType(ContentType.JSON)
Expand Down
Loading

0 comments on commit 8c91a0d

Please sign in to comment.