use of com.couchbase.client.java.kv.MutationResult in project couchbase-jvm-clients by couchbase.
the class KeyValueIntegrationTest method insertAndGet.
@Test
void insertAndGet() {
String id = UUID.randomUUID().toString();
MutationResult insertResult = collection.insert(id, "Hello, World");
assertTrue(insertResult.cas() != 0);
assertTrue(insertResult.mutationToken().isPresent());
GetResult getResult = collection.get(id);
assertEquals("Hello, World", getResult.contentAs(String.class));
assertEquals("\"Hello, World\"", new String(getResult.contentAsBytes(), UTF_8));
assertTrue(getResult.cas() != 0);
assertFalse(getResult.expiryTime().isPresent());
}
use of com.couchbase.client.java.kv.MutationResult in project couchbase-jvm-clients by couchbase.
the class KeyValueIntegrationTest method exists.
/**
* Mock does not support Get Meta, so we need to ignore it there.
*/
@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void exists() {
String id = UUID.randomUUID().toString();
assertFalse(collection.exists(id).exists());
MutationResult insertResult = collection.insert(id, "Hello, World");
assertTrue(insertResult.cas() != 0);
ExistsResult existsResult = collection.exists(id);
assertEquals(insertResult.cas(), existsResult.cas());
assertTrue(existsResult.exists());
assertFalse(collection.exists("some_id").exists());
}
Aggregations