diff --git a/src/main/java/org/springframework/data/couchbase/core/ExecutableInsertByIdOperation.java b/src/main/java/org/springframework/data/couchbase/core/ExecutableInsertByIdOperation.java index cb198560..0465d502 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ExecutableInsertByIdOperation.java +++ b/src/main/java/org/springframework/data/couchbase/core/ExecutableInsertByIdOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors + * Copyright 2012-2022 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -117,10 +117,10 @@ public interface ExecutableInsertByIdOperation { interface InsertByIdWithDurability extends InsertByIdInScope, WithDurability { @Override - InsertByIdInCollection withDurability(DurabilityLevel durabilityLevel); + InsertByIdInScope withDurability(DurabilityLevel durabilityLevel); @Override - InsertByIdInCollection withDurability(PersistTo persistTo, ReplicateTo replicateTo); + InsertByIdInScope withDurability(PersistTo persistTo, ReplicateTo replicateTo); } diff --git a/src/main/java/org/springframework/data/couchbase/core/ExecutableInsertByIdOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ExecutableInsertByIdOperationSupport.java index 52031af2..8eb4b99f 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ExecutableInsertByIdOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ExecutableInsertByIdOperationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors + * Copyright 2012-2022 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,14 +100,14 @@ public class ExecutableInsertByIdOperationSupport implements ExecutableInsertByI } @Override - public InsertByIdInCollection withDurability(final DurabilityLevel durabilityLevel) { + public InsertByIdInScope withDurability(final DurabilityLevel durabilityLevel) { Assert.notNull(durabilityLevel, "Durability Level must not be null."); return new ExecutableInsertByIdSupport<>(template, domainType, scope, collection, options, persistTo, replicateTo, durabilityLevel, expiry); } @Override - public InsertByIdInCollection withDurability(final PersistTo persistTo, final ReplicateTo replicateTo) { + public InsertByIdInScope withDurability(final PersistTo persistTo, final ReplicateTo replicateTo) { Assert.notNull(persistTo, "PersistTo must not be null."); Assert.notNull(replicateTo, "ReplicateTo must not be null."); return new ExecutableInsertByIdSupport<>(template, domainType, scope, collection, options, persistTo, replicateTo, diff --git a/src/main/java/org/springframework/data/couchbase/core/ExecutableRemoveByIdOperation.java b/src/main/java/org/springframework/data/couchbase/core/ExecutableRemoveByIdOperation.java index eb9cb214..02381669 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ExecutableRemoveByIdOperation.java +++ b/src/main/java/org/springframework/data/couchbase/core/ExecutableRemoveByIdOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors + * Copyright 2012-2022 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,10 +114,10 @@ public interface ExecutableRemoveByIdOperation { interface RemoveByIdWithDurability extends RemoveByIdInScope, WithDurability { @Override - RemoveByIdInCollection withDurability(DurabilityLevel durabilityLevel); + RemoveByIdInScope withDurability(DurabilityLevel durabilityLevel); @Override - RemoveByIdInCollection withDurability(PersistTo persistTo, ReplicateTo replicateTo); + RemoveByIdInScope withDurability(PersistTo persistTo, ReplicateTo replicateTo); } diff --git a/src/main/java/org/springframework/data/couchbase/core/ExecutableRemoveByIdOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ExecutableRemoveByIdOperationSupport.java index 9f79dad3..e0721ce5 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ExecutableRemoveByIdOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ExecutableRemoveByIdOperationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors + * Copyright 2012-2022 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,14 +92,14 @@ public class ExecutableRemoveByIdOperationSupport implements ExecutableRemoveByI } @Override - public RemoveByIdInCollection withDurability(final DurabilityLevel durabilityLevel) { + public RemoveByIdInScope withDurability(final DurabilityLevel durabilityLevel) { Assert.notNull(durabilityLevel, "Durability Level must not be null."); return new ExecutableRemoveByIdSupport(template, domainType, scope, collection, options, persistTo, replicateTo, durabilityLevel, cas); } @Override - public RemoveByIdInCollection withDurability(final PersistTo persistTo, final ReplicateTo replicateTo) { + public RemoveByIdInScope withDurability(final PersistTo persistTo, final ReplicateTo replicateTo) { Assert.notNull(persistTo, "PersistTo must not be null."); Assert.notNull(replicateTo, "ReplicateTo must not be null."); return new ExecutableRemoveByIdSupport(template, domainType, scope, collection, options, persistTo, replicateTo, diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperation.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperation.java index 953eff0e..6439879f 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperation.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors + * Copyright 2012-2022 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -113,10 +113,10 @@ public interface ReactiveInsertByIdOperation { interface InsertByIdWithDurability extends InsertByIdInScope, WithDurability { @Override - InsertByIdInCollection withDurability(DurabilityLevel durabilityLevel); + InsertByIdInScope withDurability(DurabilityLevel durabilityLevel); @Override - InsertByIdInCollection withDurability(PersistTo persistTo, ReplicateTo replicateTo); + InsertByIdInScope withDurability(PersistTo persistTo, ReplicateTo replicateTo); } diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java index 7514e8ba..0d319fb4 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors + * Copyright 2012-2022 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -125,14 +125,14 @@ public class ReactiveInsertByIdOperationSupport implements ReactiveInsertByIdOpe } @Override - public InsertByIdInCollection withDurability(final DurabilityLevel durabilityLevel) { + public InsertByIdInScope withDurability(final DurabilityLevel durabilityLevel) { Assert.notNull(durabilityLevel, "Durability Level must not be null."); return new ReactiveInsertByIdSupport<>(template, domainType, scope, collection, options, persistTo, replicateTo, durabilityLevel, expiry, support); } @Override - public InsertByIdInCollection withDurability(final PersistTo persistTo, final ReplicateTo replicateTo) { + public InsertByIdInScope withDurability(final PersistTo persistTo, final ReplicateTo replicateTo) { Assert.notNull(persistTo, "PersistTo must not be null."); Assert.notNull(replicateTo, "ReplicateTo must not be null."); return new ReactiveInsertByIdSupport<>(template, domainType, scope, collection, options, persistTo, replicateTo, diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveRemoveByIdOperation.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveRemoveByIdOperation.java index 561be70e..a9abaa17 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveRemoveByIdOperation.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveRemoveByIdOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors + * Copyright 2012-2022 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,10 +112,10 @@ public interface ReactiveRemoveByIdOperation { interface RemoveByIdWithDurability extends RemoveByIdInScope, WithDurability { @Override - RemoveByIdInCollection withDurability(DurabilityLevel durabilityLevel); + RemoveByIdInScope withDurability(DurabilityLevel durabilityLevel); @Override - RemoveByIdInCollection withDurability(PersistTo persistTo, ReplicateTo replicateTo); + RemoveByIdInScope withDurability(PersistTo persistTo, ReplicateTo replicateTo); } diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveRemoveByIdOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveRemoveByIdOperationSupport.java index b4f64ed7..547c561e 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveRemoveByIdOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveRemoveByIdOperationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors + * Copyright 2012-2022 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,14 +105,14 @@ public class ReactiveRemoveByIdOperationSupport implements ReactiveRemoveByIdOpe } @Override - public RemoveByIdInCollection withDurability(final DurabilityLevel durabilityLevel) { + public RemoveByIdInScope withDurability(final DurabilityLevel durabilityLevel) { Assert.notNull(durabilityLevel, "Durability Level must not be null."); return new ReactiveRemoveByIdSupport(template, domainType, scope, collection, options, persistTo, replicateTo, durabilityLevel, cas); } @Override - public RemoveByIdInCollection withDurability(final PersistTo persistTo, final ReplicateTo replicateTo) { + public RemoveByIdInScope withDurability(final PersistTo persistTo, final ReplicateTo replicateTo) { Assert.notNull(persistTo, "PersistTo must not be null."); Assert.notNull(replicateTo, "ReplicateTo must not be null."); return new ReactiveRemoveByIdSupport(template, domainType, scope, collection, options, persistTo, replicateTo, diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperation.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperation.java index 1f206772..0341096c 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperation.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors + * Copyright 2012-2022 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -116,9 +116,9 @@ public interface ReactiveReplaceByIdOperation { interface ReplaceByIdWithDurability extends ReplaceByIdInScope, WithDurability { - ReplaceByIdInCollection withDurability(DurabilityLevel durabilityLevel); + ReplaceByIdInScope withDurability(DurabilityLevel durabilityLevel); - ReplaceByIdInCollection withDurability(PersistTo persistTo, ReplicateTo replicateTo); + ReplaceByIdInScope withDurability(PersistTo persistTo, ReplicateTo replicateTo); } diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperationSupport.java index 55aebd4d..ba96de24 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors + * Copyright 2012-2022 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -126,14 +126,14 @@ public class ReactiveReplaceByIdOperationSupport implements ReactiveReplaceByIdO } @Override - public ReplaceByIdInCollection withDurability(final DurabilityLevel durabilityLevel) { + public ReplaceByIdInScope withDurability(final DurabilityLevel durabilityLevel) { Assert.notNull(durabilityLevel, "Durability Level must not be null."); return new ReactiveReplaceByIdSupport<>(template, domainType, scope, collection, options, persistTo, replicateTo, durabilityLevel, expiry, support); } @Override - public ReplaceByIdInCollection withDurability(final PersistTo persistTo, final ReplicateTo replicateTo) { + public ReplaceByIdInScope withDurability(final PersistTo persistTo, final ReplicateTo replicateTo) { Assert.notNull(persistTo, "PersistTo must not be null."); Assert.notNull(replicateTo, "ReplicateTo must not be null."); return new ReactiveReplaceByIdSupport<>(template, domainType, scope, collection, options, persistTo, replicateTo, diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveUpsertByIdOperation.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveUpsertByIdOperation.java index 5ec888d1..05249e19 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveUpsertByIdOperation.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveUpsertByIdOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors + * Copyright 2012-2022 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -118,10 +118,10 @@ public interface ReactiveUpsertByIdOperation { interface UpsertByIdWithDurability extends UpsertByIdInScope, WithDurability { @Override - UpsertByIdInCollection withDurability(DurabilityLevel durabilityLevel); + UpsertByIdInScope withDurability(DurabilityLevel durabilityLevel); @Override - UpsertByIdInCollection withDurability(PersistTo persistTo, ReplicateTo replicateTo); + UpsertByIdInScope withDurability(PersistTo persistTo, ReplicateTo replicateTo); } diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveUpsertByIdOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveUpsertByIdOperationSupport.java index b2433e10..e84fe1fc 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveUpsertByIdOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveUpsertByIdOperationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors + * Copyright 2012-2022 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -125,14 +125,14 @@ public class ReactiveUpsertByIdOperationSupport implements ReactiveUpsertByIdOpe } @Override - public UpsertByIdInCollection withDurability(final DurabilityLevel durabilityLevel) { + public UpsertByIdInScope withDurability(final DurabilityLevel durabilityLevel) { Assert.notNull(durabilityLevel, "Durability Level must not be null."); return new ReactiveUpsertByIdSupport<>(template, domainType, scope, collection, options, persistTo, replicateTo, durabilityLevel, expiry, support); } @Override - public UpsertByIdInCollection withDurability(final PersistTo persistTo, final ReplicateTo replicateTo) { + public UpsertByIdInScope withDurability(final PersistTo persistTo, final ReplicateTo replicateTo) { Assert.notNull(persistTo, "PersistTo must not be null."); Assert.notNull(replicateTo, "ReplicateTo must not be null."); return new ReactiveUpsertByIdSupport<>(template, domainType, scope, collection, options, persistTo, replicateTo, diff --git a/src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryCollectionIntegrationTests.java b/src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryCollectionIntegrationTests.java index 1307cabb..dcd13b5a 100644 --- a/src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryCollectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryCollectionIntegrationTests.java @@ -30,6 +30,7 @@ import java.util.List; import java.util.UUID; import java.util.stream.Collectors; +import com.couchbase.client.core.msg.kv.DurabilityLevel; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; @@ -800,4 +801,38 @@ class CouchbaseTemplateQueryCollectionIntegrationTests extends CollectionAwareIn } catch (DataRetrievalFailureException drfe) {} } } + + @Test + void testFluentApi() { + User user1 = new User(UUID.randomUUID().toString(), "user1", "user1"); + DurabilityLevel dl = DurabilityLevel.NONE; + User result; + RemoveResult rr; + result = couchbaseTemplate.insertById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName) + .one(user1); + assertEquals(user1,result); + result = couchbaseTemplate.upsertById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName) + .one(user1); + assertEquals(user1,result); + result = couchbaseTemplate.replaceById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName) + .one(user1); + assertEquals(user1,result); + rr = couchbaseTemplate.removeById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName) + .one(user1.getId()); + assertEquals(rr.getId(), user1.getId()); + assertEquals(user1,result); + result = reactiveCouchbaseTemplate.insertById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName) + .one(user1).block(); + assertEquals(user1,result); + result = reactiveCouchbaseTemplate.upsertById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName) + .one(user1).block(); + assertEquals(user1,result); + result = reactiveCouchbaseTemplate.replaceById(User.class).withDurability(dl).inScope(scopeName) + .inCollection(collectionName).one(user1).block(); + assertEquals(user1,result); + rr = reactiveCouchbaseTemplate.removeById(User.class).withDurability(dl).inScope(scopeName).inCollection(collectionName) + .one(user1.getId()).block(); + assertEquals(rr.getId(), user1.getId()); + } + }