use of com.couchbase.client.java.kv.GetResult in project couchbase-jvm-clients by couchbase.
the class ReplicaReadIntegrationTest method alwaysPassesWithAll.
/**
* As a simple litmus test, when ALL is used there should be at least one record coming back,
* namely from the active.
*
* <p>Depending on the topology, it might be more than that.</p>
*/
@Test
void alwaysPassesWithAll() {
String id = UUID.randomUUID().toString();
collection.upsert(id, "Hello, World!");
List<GetResult> results = collection.getAllReplicas(id).collect(Collectors.toList());
assertFalse(results.isEmpty());
for (GetResult result : results) {
assertEquals("Hello, World!", result.contentAs(String.class));
assertFalse(result.expiry().isPresent());
}
}
use of com.couchbase.client.java.kv.GetResult in project couchbase-jvm-clients by couchbase.
the class RetryStrategyIntegrationTest method retryStrategyCanTriggerCustomException.
@Test
void retryStrategyCanTriggerCustomException() {
String docId = UUID.randomUUID().toString();
collection.upsert(docId, "foo");
GetResult r = collection.getAndLock(docId, Duration.ofSeconds(15));
assertThrows(CustomDocumentLockedException.class, () -> collection.remove(docId, removeOptions().retryStrategy(failFastIfLocked)));
collection.unlock(docId, r.cas());
collection.remove(docId);
}
use of com.couchbase.client.java.kv.GetResult in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method expiration.
@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED, ClusterType.CAVES })
void expiration() {
JsonObject content = JsonObject.create().put("hello", "world");
String docId = prepare(content);
coll.mutateIn(docId, Arrays.asList(MutateInSpec.insert("foo2", "bar2")), MutateInOptions.mutateInOptions().expiry(Duration.ofSeconds(10)));
GetResult result = coll.get(docId, GetOptions.getOptions().withExpiry(true));
assertTrue(result.expiry().isPresent());
assertTrue(result.expiry().get().getSeconds() != 0);
}
use of com.couchbase.client.java.kv.GetResult in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method replaceBodyWithXattrSimulatingTransactionalInsert.
@IgnoreWhen(missesCapabilities = { Capabilities.SUBDOC_REVIVE_DOCUMENT })
@Test
void replaceBodyWithXattrSimulatingTransactionalInsert() {
String docId = docId();
JsonObject body = JsonObject.create().put("foo", "bar");
coll.mutateIn(docId, Collections.singletonList(upsert("txn", JsonObject.create().put("stgd", body).put("baz", "qux")).xattr().createPath()), MutateInOptions.mutateInOptions().createAsDeleted(true).accessDeleted(true).storeSemantics(StoreSemantics.INSERT));
coll.mutateIn(docId, Arrays.asList(new ReplaceBodyWithXattr("txn.stgd"), MutateInSpec.remove("txn").xattr()), MutateInOptions.mutateInOptions().accessDeleted(true).storeSemantics(StoreSemantics.REVIVE));
GetResult gr = coll.get(docId);
assertEquals(gr.contentAsObject(), body);
}
use of com.couchbase.client.java.kv.GetResult in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method replaceBodyWithXattrSimulatingTransactionalReplace.
@IgnoreWhen(missesCapabilities = { Capabilities.SUBDOC_REPLACE_BODY_WITH_XATTR })
@Test
void replaceBodyWithXattrSimulatingTransactionalReplace() {
String docId = docId();
JsonObject body = JsonObject.create().put("foo", "bar");
coll.upsert(docId, JsonObject.create());
MutateInResult mr = coll.mutateIn(docId, Collections.singletonList(upsert("txn", JsonObject.create().put("stgd", body).put("baz", "qux")).xattr().createPath()), MutateInOptions.mutateInOptions().accessDeleted(true));
coll.mutateIn(docId, Arrays.asList(new ReplaceBodyWithXattr("txn.stgd"), MutateInSpec.remove("txn").xattr()), MutateInOptions.mutateInOptions().cas(mr.cas()));
GetResult gr = coll.get(docId);
assertEquals(gr.contentAsObject(), body);
}
Aggregations