From 5b5bb94587e09882ef9fd4be2f7abffb820bea02 Mon Sep 17 00:00:00 2001 From: Michele Rastelli Date: Fri, 1 Mar 2024 16:10:32 +0100 Subject: [PATCH 1/2] versionAttribute in document API --- .../internal/InternalArangoCollection.java | 4 + .../arangodb/model/DocumentCreateOptions.java | 31 ++ .../model/DocumentReplaceOptions.java | 29 ++ .../arangodb/model/DocumentUpdateOptions.java | 28 ++ .../arangodb/ArangoCollectionAsyncTest.java | 334 +++++++++++++++++ .../com/arangodb/ArangoCollectionTest.java | 335 ++++++++++++++++++ 6 files changed, 761 insertions(+) diff --git a/core/src/main/java/com/arangodb/internal/InternalArangoCollection.java b/core/src/main/java/com/arangodb/internal/InternalArangoCollection.java index 3d89ca5b5..5be1d1015 100644 --- a/core/src/main/java/com/arangodb/internal/InternalArangoCollection.java +++ b/core/src/main/java/com/arangodb/internal/InternalArangoCollection.java @@ -51,6 +51,7 @@ public abstract class InternalArangoCollection extends ArangoExecuteable { private static final String MERGE_OBJECTS = "mergeObjects"; private static final String KEEP_NULL = "keepNull"; private static final String REFILL_INDEX_CACHES = "refillIndexCaches"; + private static final String VERSION_ATTRIBUTE = "versionAttribute"; private static final String IGNORE_REVS = "ignoreRevs"; private static final String RETURN_NEW = "returnNew"; private static final String RETURN_OLD = "returnOld"; @@ -103,6 +104,7 @@ private InternalRequest createInsertDocumentRequest(final DocumentCreateOptions request.putQueryParam(MERGE_OBJECTS, params.getMergeObjects()); request.putQueryParam(KEEP_NULL, params.getKeepNull()); request.putQueryParam(REFILL_INDEX_CACHES, params.getRefillIndexCaches()); + request.putQueryParam(VERSION_ATTRIBUTE, params.getVersionAttribute()); request.putHeaderParam(TRANSACTION_ID, params.getStreamTransactionId()); return request; } @@ -241,6 +243,7 @@ private InternalRequest createReplaceDocumentRequest(final DocumentReplaceOption request.putQueryParam(RETURN_OLD, params.getReturnOld()); request.putQueryParam(SILENT, params.getSilent()); request.putQueryParam(REFILL_INDEX_CACHES, params.getRefillIndexCaches()); + request.putQueryParam(VERSION_ATTRIBUTE, params.getVersionAttribute()); return request; } @@ -303,6 +306,7 @@ private InternalRequest createUpdateDocumentRequest(final DocumentUpdateOptions request.putQueryParam(RETURN_OLD, params.getReturnOld()); request.putQueryParam(SILENT, params.getSilent()); request.putQueryParam(REFILL_INDEX_CACHES, params.getRefillIndexCaches()); + request.putQueryParam(VERSION_ATTRIBUTE, params.getVersionAttribute()); return request; } diff --git a/core/src/main/java/com/arangodb/model/DocumentCreateOptions.java b/core/src/main/java/com/arangodb/model/DocumentCreateOptions.java index 55a9fb9ca..3bac8c242 100644 --- a/core/src/main/java/com/arangodb/model/DocumentCreateOptions.java +++ b/core/src/main/java/com/arangodb/model/DocumentCreateOptions.java @@ -37,6 +37,7 @@ public final class DocumentCreateOptions { private Boolean mergeObjects; private Boolean keepNull; private Boolean refillIndexCaches; + private String versionAttribute; public DocumentCreateOptions() { super(); @@ -177,4 +178,34 @@ public DocumentCreateOptions refillIndexCaches(Boolean refillIndexCaches) { this.refillIndexCaches = refillIndexCaches; return this; } + + public String getVersionAttribute() { + return versionAttribute; + } + + /** + * Only applicable if {@link #overwriteMode(OverwriteMode)} is set to {@link OverwriteMode#update} or + * {@link OverwriteMode#replace}. + * You can use the {@code versionAttribute} option for external versioning support. + * If set, the attribute with the name specified by the option is looked up in the stored document and the attribute + * value is compared numerically to the value of the versioning attribute in the supplied document that is supposed + * to update/replace it. + * If the version number in the new document is higher (rounded down to a whole number) than in the document that + * already exists in the database, then the update/replace operation is performed normally. This is also the case if + * the new versioning attribute has a non-numeric value, if it is a negative number, or if the attribute doesn't + * exist in the supplied or stored document. + * If the version number in the new document is lower or equal to what exists in the database, the operation is not + * performed and the existing document thus not changed. No error is returned in this case. + * The attribute can only be a top-level attribute. + * You can check if _oldRev (if present) and _rev are different to determine if the document has been changed. + * + * @param versionAttribute the attribute name to use for versioning + * @return options + * @since ArangoDB 3.12 + */ + public DocumentCreateOptions versionAttribute(String versionAttribute) { + this.versionAttribute = versionAttribute; + return this; + } + } diff --git a/core/src/main/java/com/arangodb/model/DocumentReplaceOptions.java b/core/src/main/java/com/arangodb/model/DocumentReplaceOptions.java index b8f9fa9a7..98bdf8221 100644 --- a/core/src/main/java/com/arangodb/model/DocumentReplaceOptions.java +++ b/core/src/main/java/com/arangodb/model/DocumentReplaceOptions.java @@ -36,6 +36,7 @@ public final class DocumentReplaceOptions { private Boolean silent; private String streamTransactionId; private Boolean refillIndexCaches; + private String versionAttribute; public DocumentReplaceOptions() { super(); @@ -154,4 +155,32 @@ public DocumentReplaceOptions refillIndexCaches(Boolean refillIndexCaches) { this.refillIndexCaches = refillIndexCaches; return this; } + + public String getVersionAttribute() { + return versionAttribute; + } + + /** + * You can use the {@code versionAttribute} option for external versioning support. + * If set, the attribute with the name specified by the option is looked up in the stored document and the attribute + * value is compared numerically to the value of the versioning attribute in the supplied document that is supposed + * to update/replace it. + * If the version number in the new document is higher (rounded down to a whole number) than in the document that + * already exists in the database, then the update/replace operation is performed normally. This is also the case if + * the new versioning attribute has a non-numeric value, if it is a negative number, or if the attribute doesn't + * exist in the supplied or stored document. + * If the version number in the new document is lower or equal to what exists in the database, the operation is not + * performed and the existing document thus not changed. No error is returned in this case. + * The attribute can only be a top-level attribute. + * You can check if _oldRev (if present) and _rev are different to determine if the document has been changed. + * + * @param versionAttribute the attribute name to use for versioning + * @return options + * @since ArangoDB 3.12 + */ + public DocumentReplaceOptions versionAttribute(String versionAttribute) { + this.versionAttribute = versionAttribute; + return this; + } + } diff --git a/core/src/main/java/com/arangodb/model/DocumentUpdateOptions.java b/core/src/main/java/com/arangodb/model/DocumentUpdateOptions.java index 0b7d73126..b9166c6b9 100644 --- a/core/src/main/java/com/arangodb/model/DocumentUpdateOptions.java +++ b/core/src/main/java/com/arangodb/model/DocumentUpdateOptions.java @@ -38,6 +38,7 @@ public final class DocumentUpdateOptions { private Boolean silent; private String streamTransactionId; private Boolean refillIndexCaches; + private String versionAttribute; public DocumentUpdateOptions() { super(); @@ -190,4 +191,31 @@ public DocumentUpdateOptions refillIndexCaches(Boolean refillIndexCaches) { return this; } + public String getVersionAttribute() { + return versionAttribute; + } + + /** + * You can use the {@code versionAttribute} option for external versioning support. + * If set, the attribute with the name specified by the option is looked up in the stored document and the attribute + * value is compared numerically to the value of the versioning attribute in the supplied document that is supposed + * to update/replace it. + * If the version number in the new document is higher (rounded down to a whole number) than in the document that + * already exists in the database, then the update/replace operation is performed normally. This is also the case if + * the new versioning attribute has a non-numeric value, if it is a negative number, or if the attribute doesn't + * exist in the supplied or stored document. + * If the version number in the new document is lower or equal to what exists in the database, the operation is not + * performed and the existing document thus not changed. No error is returned in this case. + * The attribute can only be a top-level attribute. + * You can check if _oldRev (if present) and _rev are different to determine if the document has been changed. + * + * @param versionAttribute the attribute name to use for versioning + * @return options + * @since ArangoDB 3.12 + */ + public DocumentUpdateOptions versionAttribute(String versionAttribute) { + this.versionAttribute = versionAttribute; + return this; + } + } diff --git a/driver/src/test/java/com/arangodb/ArangoCollectionAsyncTest.java b/driver/src/test/java/com/arangodb/ArangoCollectionAsyncTest.java index e2c3ca18d..2c9766415 100644 --- a/driver/src/test/java/com/arangodb/ArangoCollectionAsyncTest.java +++ b/driver/src/test/java/com/arangodb/ArangoCollectionAsyncTest.java @@ -310,6 +310,184 @@ void insertDocumentOverwriteModeUpdateKeepNullFalse(ArangoCollectionAsync collec assertThat(updated.getProperties()).doesNotContainKey("foo"); } + @ParameterizedTest + @MethodSource("asyncCols") + void insertDocumentOverwriteModeUpdateWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc).get(); + doc.addAttribute("_version", 2); + DocumentCreateEntity updateResult = collection.insertDocument( + doc, + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.update) + .versionAttribute("_version") + .returnNew(true) + ).get(); + assertThat(updateResult.getNew().getAttribute("_version")).isEqualTo(2); + } + + @ParameterizedTest + @MethodSource("asyncCols") + void insertDocumentOverwriteModeUpdateWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc).get(); + doc.addAttribute("_version", 0); + DocumentCreateEntity updateResult = collection.insertDocument( + doc, + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.update) + .versionAttribute("_version") + .returnNew(true) + ).get(); + assertThat(updateResult.getNew().getAttribute("_version")).isEqualTo(1); + + } + + @ParameterizedTest + @MethodSource("asyncCols") + void insertDocumentsOverwriteModeUpdateWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)).get(); + + d1.addAttribute("_version", 2); + d2.addAttribute("_version", 2); + MultiDocumentEntity> updateResult = collection.insertDocuments( + Arrays.asList(d1, d2), + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.update) + .versionAttribute("_version") + .returnNew(true), + BaseDocument.class + ).get(); + + assertThat(updateResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(2); + }); + } + + @ParameterizedTest + @MethodSource("asyncCols") + void insertDocumentsOverwriteModeUpdateWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)).get(); + + d1.addAttribute("_version", 0); + d2.addAttribute("_version", 0); + MultiDocumentEntity> updateResult = collection.insertDocuments( + Arrays.asList(d1, d2), + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.update) + .versionAttribute("_version") + .returnNew(true), + BaseDocument.class + ).get(); + + assertThat(updateResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(1); + }); + } + + @ParameterizedTest + @MethodSource("asyncCols") + void insertDocumentOverwriteModeReplaceWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc).get(); + doc.addAttribute("_version", 2); + DocumentCreateEntity updateResult = collection.insertDocument( + doc, + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.replace) + .versionAttribute("_version") + .returnNew(true) + ).get(); + assertThat(updateResult.getNew().getAttribute("_version")).isEqualTo(2); + } + + @ParameterizedTest + @MethodSource("asyncCols") + void insertDocumentOverwriteModeReplaceUpdateWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc).get(); + doc.addAttribute("_version", 0); + DocumentCreateEntity updateResult = collection.insertDocument( + doc, + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.replace) + .versionAttribute("_version") + .returnNew(true) + ).get(); + assertThat(updateResult.getNew().getAttribute("_version")).isEqualTo(1); + + } + + @ParameterizedTest + @MethodSource("asyncCols") + void insertDocumentsOverwriteModeReplaceWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)).get(); + + d1.addAttribute("_version", 2); + d2.addAttribute("_version", 2); + MultiDocumentEntity> updateResult = collection.insertDocuments( + Arrays.asList(d1, d2), + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.replace) + .versionAttribute("_version") + .returnNew(true), + BaseDocument.class + ).get(); + + assertThat(updateResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(2); + }); + } + + @ParameterizedTest + @MethodSource("asyncCols") + void insertDocumentsOverwriteModeReplaceWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)).get(); + + d1.addAttribute("_version", 0); + d2.addAttribute("_version", 0); + MultiDocumentEntity> updateResult = collection.insertDocuments( + Arrays.asList(d1, d2), + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.replace) + .versionAttribute("_version") + .returnNew(true), + BaseDocument.class + ).get(); + + assertThat(updateResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(1); + }); + } + @ParameterizedTest @MethodSource("asyncCols") void insertDocumentWaitForSync(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { @@ -704,6 +882,84 @@ void updateDocumentIfMatchFail(ArangoCollectionAsync collection) throws Executio assertThat(thrown).isInstanceOf(ArangoDBException.class); } + @ParameterizedTest + @MethodSource("asyncCols") + void updateDocumentWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc).get(); + doc.addAttribute("_version", 2); + DocumentUpdateEntity updateResult = collection.updateDocument( + doc.getKey(), + doc, + new DocumentUpdateOptions().versionAttribute("_version").returnNew(true) + ).get(); + assertThat(updateResult.getNew().getAttribute("_version")).isEqualTo(2); + } + + @ParameterizedTest + @MethodSource("asyncCols") + void updateDocumentWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc).get(); + doc.addAttribute("_version", 0); + DocumentUpdateEntity updateResult = collection.updateDocument( + doc.getKey(), + doc, + new DocumentUpdateOptions().versionAttribute("_version").returnNew(true) + ).get(); + assertThat(updateResult.getNew().getAttribute("_version")).isEqualTo(1); + } + + @ParameterizedTest + @MethodSource("asyncCols") + void updateDocumentsWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)).get(); + + d1.addAttribute("_version", 2); + d2.addAttribute("_version", 2); + MultiDocumentEntity> updateResult = collection.updateDocuments( + Arrays.asList(d1, d2), + new DocumentUpdateOptions().versionAttribute("_version").returnNew(true), + BaseDocument.class + ).get(); + + assertThat(updateResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(2); + }); + } + + @ParameterizedTest + @MethodSource("asyncCols") + void updateDocumentsWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)).get(); + + d1.addAttribute("_version", 0); + d2.addAttribute("_version", 0); + MultiDocumentEntity> updateResult = collection.updateDocuments( + Arrays.asList(d1, d2), + new DocumentUpdateOptions().versionAttribute("_version").returnNew(true), + BaseDocument.class + ).get(); + + assertThat(updateResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(1); + }); + } + @ParameterizedTest @MethodSource("asyncCols") void updateDocumentReturnNew(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { @@ -1077,6 +1333,84 @@ void replaceDocumentIgnoreRevsFalse(ArangoCollectionAsync collection) throws Exe assertThat(thrown).isInstanceOf(ArangoDBException.class); } + @ParameterizedTest + @MethodSource("asyncCols") + void replaceDocumentWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc).get(); + doc.addAttribute("_version", 2); + DocumentUpdateEntity replaceResult = collection.replaceDocument( + doc.getKey(), + doc, + new DocumentReplaceOptions().versionAttribute("_version").returnNew(true) + ).get(); + assertThat(replaceResult.getNew().getAttribute("_version")).isEqualTo(2); + } + + @ParameterizedTest + @MethodSource("asyncCols") + void replaceDocumentWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc).get(); + doc.addAttribute("_version", 0); + DocumentUpdateEntity replaceResult = collection.replaceDocument( + doc.getKey(), + doc, + new DocumentReplaceOptions().versionAttribute("_version").returnNew(true) + ).get(); + assertThat(replaceResult.getNew().getAttribute("_version")).isEqualTo(1); + } + + @ParameterizedTest + @MethodSource("asyncCols") + void replaceDocumentsWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)).get(); + + d1.addAttribute("_version", 2); + d2.addAttribute("_version", 2); + MultiDocumentEntity> replaceResult = collection.replaceDocuments( + Arrays.asList(d1, d2), + new DocumentReplaceOptions().versionAttribute("_version").returnNew(true), + BaseDocument.class + ).get(); + + assertThat(replaceResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(2); + }); + } + + @ParameterizedTest + @MethodSource("asyncCols") + void replaceDocumentsWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)).get(); + + d1.addAttribute("_version", 0); + d2.addAttribute("_version", 0); + MultiDocumentEntity> replaceResult = collection.replaceDocuments( + Arrays.asList(d1, d2), + new DocumentReplaceOptions().versionAttribute("_version").returnNew(true), + BaseDocument.class + ).get(); + + assertThat(replaceResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(1); + }); + } + @ParameterizedTest @MethodSource("asyncCols") void replaceDocumentReturnNew(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { diff --git a/driver/src/test/java/com/arangodb/ArangoCollectionTest.java b/driver/src/test/java/com/arangodb/ArangoCollectionTest.java index 8d1087992..a317c543c 100644 --- a/driver/src/test/java/com/arangodb/ArangoCollectionTest.java +++ b/driver/src/test/java/com/arangodb/ArangoCollectionTest.java @@ -40,6 +40,7 @@ import org.junit.jupiter.params.provider.MethodSource; import java.util.*; +import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; @@ -313,6 +314,184 @@ void insertDocumentOverwriteModeUpdateKeepNullFalse(ArangoCollection collection) assertThat(updated.getProperties()).doesNotContainKey("foo"); } + @ParameterizedTest + @MethodSource("cols") + void insertDocumentOverwriteModeUpdateWithExternalVersioning(ArangoCollection collection) { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc); + doc.addAttribute("_version", 2); + DocumentCreateEntity updateResult = collection.insertDocument( + doc, + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.update) + .versionAttribute("_version") + .returnNew(true) + ); + assertThat(updateResult.getNew().getAttribute("_version")).isEqualTo(2); + } + + @ParameterizedTest + @MethodSource("cols") + void insertDocumentOverwriteModeUpdateWithExternalVersioningFail(ArangoCollection collection) { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc); + doc.addAttribute("_version", 0); + DocumentCreateEntity updateResult = collection.insertDocument( + doc, + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.update) + .versionAttribute("_version") + .returnNew(true) + ); + assertThat(updateResult.getNew().getAttribute("_version")).isEqualTo(1); + + } + + @ParameterizedTest + @MethodSource("cols") + void insertDocumentsOverwriteModeUpdateWithExternalVersioning(ArangoCollection collection) { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)); + + d1.addAttribute("_version", 2); + d2.addAttribute("_version", 2); + MultiDocumentEntity> updateResult = collection.insertDocuments( + Arrays.asList(d1, d2), + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.update) + .versionAttribute("_version") + .returnNew(true), + BaseDocument.class + ); + + assertThat(updateResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(2); + }); + } + + @ParameterizedTest + @MethodSource("cols") + void insertDocumentsOverwriteModeUpdateWithExternalVersioningFail(ArangoCollection collection) { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)); + + d1.addAttribute("_version", 0); + d2.addAttribute("_version", 0); + MultiDocumentEntity> updateResult = collection.insertDocuments( + Arrays.asList(d1, d2), + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.update) + .versionAttribute("_version") + .returnNew(true), + BaseDocument.class + ); + + assertThat(updateResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(1); + }); + } + + @ParameterizedTest + @MethodSource("cols") + void insertDocumentOverwriteModeReplaceWithExternalVersioning(ArangoCollection collection) { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc); + doc.addAttribute("_version", 2); + DocumentCreateEntity updateResult = collection.insertDocument( + doc, + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.replace) + .versionAttribute("_version") + .returnNew(true) + ); + assertThat(updateResult.getNew().getAttribute("_version")).isEqualTo(2); + } + + @ParameterizedTest + @MethodSource("cols") + void insertDocumentOverwriteModeReplaceUpdateWithExternalVersioningFail(ArangoCollection collection) { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc); + doc.addAttribute("_version", 0); + DocumentCreateEntity updateResult = collection.insertDocument( + doc, + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.replace) + .versionAttribute("_version") + .returnNew(true) + ); + assertThat(updateResult.getNew().getAttribute("_version")).isEqualTo(1); + + } + + @ParameterizedTest + @MethodSource("cols") + void insertDocumentsOverwriteModeReplaceWithExternalVersioning(ArangoCollection collection) { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)); + + d1.addAttribute("_version", 2); + d2.addAttribute("_version", 2); + MultiDocumentEntity> updateResult = collection.insertDocuments( + Arrays.asList(d1, d2), + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.replace) + .versionAttribute("_version") + .returnNew(true), + BaseDocument.class + ); + + assertThat(updateResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(2); + }); + } + + @ParameterizedTest + @MethodSource("cols") + void insertDocumentsOverwriteModeReplaceWithExternalVersioningFail(ArangoCollection collection) { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)); + + d1.addAttribute("_version", 0); + d2.addAttribute("_version", 0); + MultiDocumentEntity> updateResult = collection.insertDocuments( + Arrays.asList(d1, d2), + new DocumentCreateOptions() + .overwriteMode(OverwriteMode.replace) + .versionAttribute("_version") + .returnNew(true), + BaseDocument.class + ); + + assertThat(updateResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(1); + }); + } + @ParameterizedTest @MethodSource("cols") void insertDocumentWaitForSync(ArangoCollection collection) { @@ -729,6 +908,84 @@ void updateDocumentIfMatchFail(ArangoCollection collection) { assertThat(thrown).isInstanceOf(ArangoDBException.class); } + @ParameterizedTest + @MethodSource("cols") + void updateDocumentWithExternalVersioning(ArangoCollection collection) { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc); + doc.addAttribute("_version", 2); + DocumentUpdateEntity updateResult = collection.updateDocument( + doc.getKey(), + doc, + new DocumentUpdateOptions().versionAttribute("_version").returnNew(true) + ); + assertThat(updateResult.getNew().getAttribute("_version")).isEqualTo(2); + } + + @ParameterizedTest + @MethodSource("cols") + void updateDocumentWithExternalVersioningFail(ArangoCollection collection) { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc); + doc.addAttribute("_version", 0); + DocumentUpdateEntity updateResult = collection.updateDocument( + doc.getKey(), + doc, + new DocumentUpdateOptions().versionAttribute("_version").returnNew(true) + ); + assertThat(updateResult.getNew().getAttribute("_version")).isEqualTo(1); + } + + @ParameterizedTest + @MethodSource("cols") + void updateDocumentsWithExternalVersioning(ArangoCollection collection) { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)); + + d1.addAttribute("_version", 2); + d2.addAttribute("_version", 2); + MultiDocumentEntity> updateResult = collection.updateDocuments( + Arrays.asList(d1, d2), + new DocumentUpdateOptions().versionAttribute("_version").returnNew(true), + BaseDocument.class + ); + + assertThat(updateResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(2); + }); + } + + @ParameterizedTest + @MethodSource("cols") + void updateDocumentsWithExternalVersioningFail(ArangoCollection collection) { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)); + + d1.addAttribute("_version", 0); + d2.addAttribute("_version", 0); + MultiDocumentEntity> updateResult = collection.updateDocuments( + Arrays.asList(d1, d2), + new DocumentUpdateOptions().versionAttribute("_version").returnNew(true), + BaseDocument.class + ); + + assertThat(updateResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(1); + }); + } + @ParameterizedTest @MethodSource("cols") void updateDocumentReturnNew(ArangoCollection collection) { @@ -1102,6 +1359,84 @@ void replaceDocumentIgnoreRevsFalse(ArangoCollection collection) { assertThat(thrown).isInstanceOf(ArangoDBException.class); } + @ParameterizedTest + @MethodSource("cols") + void replaceDocumentWithExternalVersioning(ArangoCollection collection) { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc); + doc.addAttribute("_version", 2); + DocumentUpdateEntity replaceResult = collection.replaceDocument( + doc.getKey(), + doc, + new DocumentReplaceOptions().versionAttribute("_version").returnNew(true) + ); + assertThat(replaceResult.getNew().getAttribute("_version")).isEqualTo(2); + } + + @ParameterizedTest + @MethodSource("cols") + void replaceDocumentWithExternalVersioningFail(ArangoCollection collection) { + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); + doc.addAttribute("_version", 1); + collection.insertDocument(doc); + doc.addAttribute("_version", 0); + DocumentUpdateEntity replaceResult = collection.replaceDocument( + doc.getKey(), + doc, + new DocumentReplaceOptions().versionAttribute("_version").returnNew(true) + ); + assertThat(replaceResult.getNew().getAttribute("_version")).isEqualTo(1); + } + + @ParameterizedTest + @MethodSource("cols") + void replaceDocumentsWithExternalVersioning(ArangoCollection collection) { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)); + + d1.addAttribute("_version", 2); + d2.addAttribute("_version", 2); + MultiDocumentEntity> replaceResult = collection.replaceDocuments( + Arrays.asList(d1, d2), + new DocumentReplaceOptions().versionAttribute("_version").returnNew(true), + BaseDocument.class + ); + + assertThat(replaceResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(2); + }); + } + + @ParameterizedTest + @MethodSource("cols") + void replaceDocumentsWithExternalVersioningFail(ArangoCollection collection) { + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); + d1.addAttribute("_version", 1); + BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); + d2.addAttribute("_version", 1); + + collection.insertDocuments(Arrays.asList(d1, d2)); + + d1.addAttribute("_version", 0); + d2.addAttribute("_version", 0); + MultiDocumentEntity> replaceResult = collection.replaceDocuments( + Arrays.asList(d1, d2), + new DocumentReplaceOptions().versionAttribute("_version").returnNew(true), + BaseDocument.class + ); + + assertThat(replaceResult.getDocuments()).allSatisfy(it -> { + assertThat(it.getNew()).isNotNull(); + assertThat(it.getNew().getAttribute("_version")).isEqualTo(1); + }); + } + @ParameterizedTest @MethodSource("cols") void replaceDocumentReturnNew(ArangoCollection collection) { From 70b306b403ecc3bff5daa98eb6b2a3a3d8067175 Mon Sep 17 00:00:00 2001 From: Michele Rastelli Date: Fri, 1 Mar 2024 20:31:20 +0100 Subject: [PATCH 2/2] tests fix --- .../arangodb/ArangoCollectionAsyncTest.java | 32 +++++++++++++++++++ .../com/arangodb/ArangoCollectionTest.java | 32 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/driver/src/test/java/com/arangodb/ArangoCollectionAsyncTest.java b/driver/src/test/java/com/arangodb/ArangoCollectionAsyncTest.java index 2c9766415..4628699bc 100644 --- a/driver/src/test/java/com/arangodb/ArangoCollectionAsyncTest.java +++ b/driver/src/test/java/com/arangodb/ArangoCollectionAsyncTest.java @@ -313,6 +313,8 @@ void insertDocumentOverwriteModeUpdateKeepNullFalse(ArangoCollectionAsync collec @ParameterizedTest @MethodSource("asyncCols") void insertDocumentOverwriteModeUpdateWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc).get(); @@ -330,6 +332,8 @@ void insertDocumentOverwriteModeUpdateWithExternalVersioning(ArangoCollectionAsy @ParameterizedTest @MethodSource("asyncCols") void insertDocumentOverwriteModeUpdateWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc).get(); @@ -348,6 +352,8 @@ void insertDocumentOverwriteModeUpdateWithExternalVersioningFail(ArangoCollectio @ParameterizedTest @MethodSource("asyncCols") void insertDocumentsOverwriteModeUpdateWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -375,6 +381,8 @@ void insertDocumentsOverwriteModeUpdateWithExternalVersioning(ArangoCollectionAs @ParameterizedTest @MethodSource("asyncCols") void insertDocumentsOverwriteModeUpdateWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -402,6 +410,8 @@ void insertDocumentsOverwriteModeUpdateWithExternalVersioningFail(ArangoCollecti @ParameterizedTest @MethodSource("asyncCols") void insertDocumentOverwriteModeReplaceWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc).get(); @@ -419,6 +429,8 @@ void insertDocumentOverwriteModeReplaceWithExternalVersioning(ArangoCollectionAs @ParameterizedTest @MethodSource("asyncCols") void insertDocumentOverwriteModeReplaceUpdateWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc).get(); @@ -437,6 +449,8 @@ void insertDocumentOverwriteModeReplaceUpdateWithExternalVersioningFail(ArangoCo @ParameterizedTest @MethodSource("asyncCols") void insertDocumentsOverwriteModeReplaceWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -464,6 +478,8 @@ void insertDocumentsOverwriteModeReplaceWithExternalVersioning(ArangoCollectionA @ParameterizedTest @MethodSource("asyncCols") void insertDocumentsOverwriteModeReplaceWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -885,6 +901,8 @@ void updateDocumentIfMatchFail(ArangoCollectionAsync collection) throws Executio @ParameterizedTest @MethodSource("asyncCols") void updateDocumentWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc).get(); @@ -900,6 +918,8 @@ void updateDocumentWithExternalVersioning(ArangoCollectionAsync collection) thro @ParameterizedTest @MethodSource("asyncCols") void updateDocumentWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc).get(); @@ -915,6 +935,8 @@ void updateDocumentWithExternalVersioningFail(ArangoCollectionAsync collection) @ParameterizedTest @MethodSource("asyncCols") void updateDocumentsWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -939,6 +961,8 @@ void updateDocumentsWithExternalVersioning(ArangoCollectionAsync collection) thr @ParameterizedTest @MethodSource("asyncCols") void updateDocumentsWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -1336,6 +1360,8 @@ void replaceDocumentIgnoreRevsFalse(ArangoCollectionAsync collection) throws Exe @ParameterizedTest @MethodSource("asyncCols") void replaceDocumentWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc).get(); @@ -1351,6 +1377,8 @@ void replaceDocumentWithExternalVersioning(ArangoCollectionAsync collection) thr @ParameterizedTest @MethodSource("asyncCols") void replaceDocumentWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc).get(); @@ -1366,6 +1394,8 @@ void replaceDocumentWithExternalVersioningFail(ArangoCollectionAsync collection) @ParameterizedTest @MethodSource("asyncCols") void replaceDocumentsWithExternalVersioning(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -1390,6 +1420,8 @@ void replaceDocumentsWithExternalVersioning(ArangoCollectionAsync collection) th @ParameterizedTest @MethodSource("asyncCols") void replaceDocumentsWithExternalVersioningFail(ArangoCollectionAsync collection) throws ExecutionException, InterruptedException { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); diff --git a/driver/src/test/java/com/arangodb/ArangoCollectionTest.java b/driver/src/test/java/com/arangodb/ArangoCollectionTest.java index a317c543c..35d6ce98d 100644 --- a/driver/src/test/java/com/arangodb/ArangoCollectionTest.java +++ b/driver/src/test/java/com/arangodb/ArangoCollectionTest.java @@ -317,6 +317,8 @@ void insertDocumentOverwriteModeUpdateKeepNullFalse(ArangoCollection collection) @ParameterizedTest @MethodSource("cols") void insertDocumentOverwriteModeUpdateWithExternalVersioning(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc); @@ -334,6 +336,8 @@ void insertDocumentOverwriteModeUpdateWithExternalVersioning(ArangoCollection co @ParameterizedTest @MethodSource("cols") void insertDocumentOverwriteModeUpdateWithExternalVersioningFail(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc); @@ -352,6 +356,8 @@ void insertDocumentOverwriteModeUpdateWithExternalVersioningFail(ArangoCollectio @ParameterizedTest @MethodSource("cols") void insertDocumentsOverwriteModeUpdateWithExternalVersioning(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -379,6 +385,8 @@ void insertDocumentsOverwriteModeUpdateWithExternalVersioning(ArangoCollection c @ParameterizedTest @MethodSource("cols") void insertDocumentsOverwriteModeUpdateWithExternalVersioningFail(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -406,6 +414,8 @@ void insertDocumentsOverwriteModeUpdateWithExternalVersioningFail(ArangoCollecti @ParameterizedTest @MethodSource("cols") void insertDocumentOverwriteModeReplaceWithExternalVersioning(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc); @@ -423,6 +433,8 @@ void insertDocumentOverwriteModeReplaceWithExternalVersioning(ArangoCollection c @ParameterizedTest @MethodSource("cols") void insertDocumentOverwriteModeReplaceUpdateWithExternalVersioningFail(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc); @@ -441,6 +453,8 @@ void insertDocumentOverwriteModeReplaceUpdateWithExternalVersioningFail(ArangoCo @ParameterizedTest @MethodSource("cols") void insertDocumentsOverwriteModeReplaceWithExternalVersioning(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -468,6 +482,8 @@ void insertDocumentsOverwriteModeReplaceWithExternalVersioning(ArangoCollection @ParameterizedTest @MethodSource("cols") void insertDocumentsOverwriteModeReplaceWithExternalVersioningFail(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -911,6 +927,8 @@ void updateDocumentIfMatchFail(ArangoCollection collection) { @ParameterizedTest @MethodSource("cols") void updateDocumentWithExternalVersioning(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc); @@ -926,6 +944,8 @@ void updateDocumentWithExternalVersioning(ArangoCollection collection) { @ParameterizedTest @MethodSource("cols") void updateDocumentWithExternalVersioningFail(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc); @@ -941,6 +961,8 @@ void updateDocumentWithExternalVersioningFail(ArangoCollection collection) { @ParameterizedTest @MethodSource("cols") void updateDocumentsWithExternalVersioning(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -965,6 +987,8 @@ void updateDocumentsWithExternalVersioning(ArangoCollection collection) { @ParameterizedTest @MethodSource("cols") void updateDocumentsWithExternalVersioningFail(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -1362,6 +1386,8 @@ void replaceDocumentIgnoreRevsFalse(ArangoCollection collection) { @ParameterizedTest @MethodSource("cols") void replaceDocumentWithExternalVersioning(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc); @@ -1377,6 +1403,8 @@ void replaceDocumentWithExternalVersioning(ArangoCollection collection) { @ParameterizedTest @MethodSource("cols") void replaceDocumentWithExternalVersioningFail(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument doc = new BaseDocument(UUID.randomUUID().toString()); doc.addAttribute("_version", 1); collection.insertDocument(doc); @@ -1392,6 +1420,8 @@ void replaceDocumentWithExternalVersioningFail(ArangoCollection collection) { @ParameterizedTest @MethodSource("cols") void replaceDocumentsWithExternalVersioning(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString()); @@ -1416,6 +1446,8 @@ void replaceDocumentsWithExternalVersioning(ArangoCollection collection) { @ParameterizedTest @MethodSource("cols") void replaceDocumentsWithExternalVersioningFail(ArangoCollection collection) { + assumeTrue(isAtLeastVersion(3, 12)); + BaseDocument d1 = new BaseDocument(UUID.randomUUID().toString()); d1.addAttribute("_version", 1); BaseDocument d2 = new BaseDocument(UUID.randomUUID().toString());