diff --git a/core/src/main/java/com/arangodb/internal/InternalArangoCollection.java b/core/src/main/java/com/arangodb/internal/InternalArangoCollection.java index ec5aef96b..6f054cf5e 100644 --- a/core/src/main/java/com/arangodb/internal/InternalArangoCollection.java +++ b/core/src/main/java/com/arangodb/internal/InternalArangoCollection.java @@ -363,6 +363,7 @@ private InternalRequest createDeleteDocumentRequest(final DocumentDeleteOptions request.putQueryParam(RETURN_OLD, params.getReturnOld()); request.putQueryParam(SILENT, params.getSilent()); request.putQueryParam(REFILL_INDEX_CACHES, params.getRefillIndexCaches()); + request.putQueryParam(IGNORE_REVS, params.getIgnoreRevs()); return request; } diff --git a/core/src/main/java/com/arangodb/model/DocumentDeleteOptions.java b/core/src/main/java/com/arangodb/model/DocumentDeleteOptions.java index 28259d657..f179fd944 100644 --- a/core/src/main/java/com/arangodb/model/DocumentDeleteOptions.java +++ b/core/src/main/java/com/arangodb/model/DocumentDeleteOptions.java @@ -31,6 +31,7 @@ public final class DocumentDeleteOptions extends TransactionalOptions newDoc = RequestContextHolder.INSTANCE.runWithCtx(RequestContext.EMPTY, () -> - collection.getSerde().deserializeUserData(createEntity.getNew().get(), Map.class)); + Map newDoc = collection.getSerde().getUserSerde().deserialize(createEntity.getNew().get(), Map.class); assertThat(newDoc).containsAllEntriesOf(doc); } @@ -1597,6 +1596,38 @@ void deleteDocumentIfMatchFail(ArangoCollectionAsync collection) throws Executio assertThat(thrown).isInstanceOf(ArangoDBException.class); } + @ParameterizedTest + @MethodSource("asyncCols") + void deleteDocuments(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + DocumentCreateEntity a = collection.insertDocument(new BaseDocument()).get(); + DocumentCreateEntity b = collection.insertDocument(new BaseDocument()).get(); + MultiDocumentEntity> info = collection.deleteDocuments( + Arrays.asList(a.getKey(), b.getKey())).get(); + assertThat(info).isNotNull(); + assertThat(info.getDocuments()).hasSize(2); + assertThat(info.getErrors()).isEmpty(); + } + + @ParameterizedTest + @MethodSource("asyncCols") + void deleteDocumentsWithRevs(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + DocumentCreateEntity a = collection.insertDocument(new BaseDocument()).get(); + DocumentCreateEntity b = collection.insertDocument(new BaseDocument()).get(); + MultiDocumentEntity> info = collection.deleteDocuments( + Arrays.asList( + JsonNodeFactory.instance.objectNode() + .put("_key", a.getKey()) + .put("_rev", a.getRev()), + JsonNodeFactory.instance.objectNode() + .put("_key", b.getKey()) + .put("_rev", "wrong") + ), new DocumentDeleteOptions().ignoreRevs(false)).get(); + assertThat(info).isNotNull(); + assertThat(info.getDocuments()).hasSize(1); + assertThat(info.getDocuments().get(0).getKey()).isEqualTo(a.getKey()); + assertThat(info.getErrors()).hasSize(1); + } + @ParameterizedTest @MethodSource("asyncCols") void deleteDocumentSilent(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { diff --git a/test-functional/src/test/java/com/arangodb/ArangoCollectionTest.java b/test-functional/src/test/java/com/arangodb/ArangoCollectionTest.java index 04fbcacc5..b70da4d4d 100644 --- a/test-functional/src/test/java/com/arangodb/ArangoCollectionTest.java +++ b/test-functional/src/test/java/com/arangodb/ArangoCollectionTest.java @@ -21,7 +21,6 @@ package com.arangodb; import com.arangodb.entity.*; -import com.arangodb.internal.RequestContextHolder; import com.arangodb.internal.serde.SerdeUtils; import com.arangodb.model.*; import com.arangodb.model.DocumentImportOptions.OnDuplicate; @@ -35,6 +34,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -560,8 +560,7 @@ void insertDocumentAsBytes(ArangoCollection collection) { assertThat(createEntity.getKey()).isEqualTo(key); assertThat(createEntity.getRev()).isNotNull(); assertThat(createEntity.getNew()).isNotNull().isInstanceOf(RawBytes.class); - Map newDoc = RequestContextHolder.INSTANCE.runWithCtx(RequestContext.EMPTY, () -> - collection.getSerde().deserializeUserData(createEntity.getNew().get(), Map.class)); + Map newDoc = collection.getSerde().getUserSerde().deserialize(createEntity.getNew().get(), Map.class); assertThat(newDoc).containsAllEntriesOf(doc); } @@ -1622,6 +1621,38 @@ void deleteDocumentIfMatchFail(ArangoCollection collection) { assertThat(thrown).isInstanceOf(ArangoDBException.class); } + @ParameterizedTest + @MethodSource("cols") + void deleteDocuments(ArangoCollection collection) { + DocumentCreateEntity a = collection.insertDocument(new BaseDocument()); + DocumentCreateEntity b = collection.insertDocument(new BaseDocument()); + MultiDocumentEntity> info = collection.deleteDocuments( + Arrays.asList(a.getKey(), b.getKey())); + assertThat(info).isNotNull(); + assertThat(info.getDocuments()).hasSize(2); + assertThat(info.getErrors()).isEmpty(); + } + + @ParameterizedTest + @MethodSource("cols") + void deleteDocumentsWithRevs(ArangoCollection collection) { + DocumentCreateEntity a = collection.insertDocument(new BaseDocument()); + DocumentCreateEntity b = collection.insertDocument(new BaseDocument()); + MultiDocumentEntity> info = collection.deleteDocuments( + Arrays.asList( + JsonNodeFactory.instance.objectNode() + .put("_key", a.getKey()) + .put("_rev", a.getRev()), + JsonNodeFactory.instance.objectNode() + .put("_key", b.getKey()) + .put("_rev", "wrong") + ), new DocumentDeleteOptions().ignoreRevs(false)); + assertThat(info).isNotNull(); + assertThat(info.getDocuments()).hasSize(1); + assertThat(info.getDocuments().get(0).getKey()).isEqualTo(a.getKey()); + assertThat(info.getErrors()).hasSize(1); + } + @ParameterizedTest @MethodSource("cols") void deleteDocumentSilent(ArangoCollection collection) {