use of com.couchbase.client.java.kv.CounterResult in project couchbase-jvm-clients by couchbase.
the class KeyValueIntegrationTest method increment.
@Test
void increment() {
String id = UUID.randomUUID().toString();
assertThrows(DocumentNotFoundException.class, () -> collection.binary().increment(id));
CounterResult result = collection.binary().increment(id, incrementOptions().initial(5L));
assertTrue(result.cas() != 0);
assertEquals(5L, result.content());
result = collection.binary().increment(id, incrementOptions().delta(2));
assertTrue(result.cas() != 0);
assertEquals(7L, result.content());
result = collection.binary().increment(id, incrementOptions());
assertTrue(result.cas() != 0);
assertEquals(8L, result.content());
}
use of com.couchbase.client.java.kv.CounterResult in project couchbase-jvm-clients by couchbase.
the class MutationTokenIntegrationTest method tokenOnDecrement.
@Test
void tokenOnDecrement() {
String id = UUID.randomUUID().toString();
CounterResult result = collection.binary().decrement(id, decrementOptions().initial(1L));
assertMutationToken(result.mutationToken());
}
use of com.couchbase.client.java.kv.CounterResult in project couchbase-jvm-clients by couchbase.
the class KeyValueIntegrationTest method decrement.
/**
* Right now the mock allows the value to be decremented below zero, which is against the server
* spec/protocol. Once https://github.com/couchbase/CouchbaseMock/issues/51 is fixed, this
* ignore annotation can be removed.
*/
@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED })
void decrement() {
String id = UUID.randomUUID().toString();
assertThrows(DocumentNotFoundException.class, () -> collection.binary().decrement(id));
CounterResult result = collection.binary().decrement(id, decrementOptions().initial(2L));
assertTrue(result.cas() != 0);
assertEquals(2L, result.content());
result = collection.binary().decrement(id);
assertTrue(result.cas() != 0);
assertEquals(1L, result.content());
result = collection.binary().decrement(id);
assertTrue(result.cas() != 0);
assertEquals(0L, result.content());
result = collection.binary().decrement(id);
assertTrue(result.cas() != 0);
assertEquals(0L, result.content());
}
use of com.couchbase.client.java.kv.CounterResult in project couchbase-jvm-clients by couchbase.
the class MutationTokenIntegrationTest method tokenOnIncrement.
@Test
void tokenOnIncrement() {
String id = UUID.randomUUID().toString();
CounterResult result = collection.binary().increment(id, incrementOptions().initial(1L));
assertMutationToken(result.mutationToken());
}
Aggregations