Reject withDurability(durabilityLevel) in transactions.

Closes #1492.
This commit is contained in:
Michael Reiche
2022-07-13 13:55:22 -07:00
parent 751643d4c4
commit 8285b2f62a
4 changed files with 35 additions and 0 deletions

View File

@@ -127,6 +127,9 @@ public class ReactiveInsertByIdOperationSupport implements ReactiveInsertByIdOpe
if (this.expiry != null) {
throw new IllegalArgumentException("withExpiry is not supported in a transaction");
}
if (this.durabilityLevel != null && this.durabilityLevel != DurabilityLevel.NONE) {
throw new IllegalArgumentException("withDurability is not supported in a transaction");
}
if (this.options != null) {
throw new IllegalArgumentException("withOptions is not supported in a transaction");
}

View File

@@ -134,6 +134,9 @@ public class ReactiveRemoveByIdOperationSupport implements ReactiveRemoveByIdOpe
throw new IllegalArgumentException(
"withDurability PersistTo and ReplicateTo overload is not supported in a transaction");
}
if (this.durabilityLevel != null && this.durabilityLevel != DurabilityLevel.NONE) {
throw new IllegalArgumentException("withDurability is not supported in a transaction");
}
if (this.options != null) {
throw new IllegalArgumentException("withOptions is not supported in a transaction");
}

View File

@@ -146,6 +146,9 @@ public class ReactiveReplaceByIdOperationSupport implements ReactiveReplaceByIdO
if (this.expiry != null) {
throw new IllegalArgumentException("withExpiry is not supported in a transaction");
}
if (this.durabilityLevel != null && this.durabilityLevel != DurabilityLevel.NONE) {
throw new IllegalArgumentException("withDurability is not supported in a transaction");
}
if (this.options != null) {
throw new IllegalArgumentException("withOptions is not supported in a transaction");
}

View File

@@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Function;
import com.couchbase.client.core.msg.kv.DurabilityLevel;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
@@ -53,6 +54,7 @@ import com.couchbase.client.java.kv.ReplicateTo;
* will be rejected at runtime.
*
* @author Graham Pople
* @author Michael Reiche
*/
@IgnoreWhen(missesCapabilities = Capabilities.QUERY, clusterTypes = ClusterType.MOCKED)
@SpringJUnitConfig(classes = { TransactionsConfig.class,
@@ -103,6 +105,14 @@ public class CouchbaseTransactionalUnsettableParametersIntegrationTests extends
});
}
@DisplayName("Using insertById().withDurability(durabilityLevel) in a transaction is rejected at runtime")
@Test
public void insertWithDurability2() {
test((ops) -> {
ops.insertById(Person.class).withDurability(DurabilityLevel.MAJORITY).one(WalterWhite);
});
}
@DisplayName("Using insertById().withOptions in a transaction is rejected at runtime")
@Test
public void insertWithOptions() {
@@ -127,6 +137,14 @@ public class CouchbaseTransactionalUnsettableParametersIntegrationTests extends
});
}
@DisplayName("Using replaceById().withDurability(durabilityLevel) in a transaction is rejected at runtime")
@Test
public void replaceWithDurability2() {
test((ops) -> {
ops.replaceById(Person.class).withDurability(DurabilityLevel.MAJORITY).one(WalterWhite);
});
}
@DisplayName("Using replaceById().withOptions in a transaction is rejected at runtime")
@Test
public void replaceWithOptions() {
@@ -143,6 +161,14 @@ public class CouchbaseTransactionalUnsettableParametersIntegrationTests extends
});
}
@DisplayName("Using removeById().withDurability(durabilityLevel) in a transaction is rejected at runtime")
@Test
public void removeWithDurability2() {
test((ops) -> {
ops.removeById(Person.class).withDurability(DurabilityLevel.MAJORITY).oneEntity(WalterWhite);
});
}
@DisplayName("Using removeById().withOptions in a transaction is rejected at runtime")
@Test
public void removeWithOptions() {