use of com.couchbase.client.core.error.DocumentNotFoundException in project couchbase-jvm-clients by couchbase.
the class KeyValueErrorIntegrationTest method verifyGetExceptions.
@Test
void verifyGetExceptions() {
DocumentNotFoundException thrown = assertThrows(DocumentNotFoundException.class, () -> collection.get(UUID.randomUUID().toString()));
assertNotNull(thrown.context());
assertThrows(InvalidArgumentException.class, () -> collection.get("foo", null));
assertThrows(InvalidArgumentException.class, () -> collection.get(""));
assertThrows(InvalidArgumentException.class, () -> collection.get(null));
assertThrows(InvalidArgumentException.class, () -> collection.get("", getOptions().withExpiry(true)));
List<String> tooManyFields = IntStream.rangeClosed(1, 17).boxed().map(Object::toString).collect(Collectors.toList());
assertThrows(InvalidArgumentException.class, () -> collection.get("foo", getOptions().project(tooManyFields)));
}
use of com.couchbase.client.core.error.DocumentNotFoundException in project couchbase-jvm-clients by couchbase.
the class KeyValueErrorIntegrationTest method verifyGetAndTouchExceptions.
@Test
void verifyGetAndTouchExceptions() {
DocumentNotFoundException thrown = assertThrows(DocumentNotFoundException.class, () -> collection.getAndTouch(UUID.randomUUID().toString(), Duration.ofSeconds(1)));
assertNotNull(thrown.context());
assertThrows(InvalidArgumentException.class, () -> collection.getAndTouch("foo", Duration.ofSeconds(1), null));
assertThrows(InvalidArgumentException.class, () -> collection.getAndTouch("", Duration.ofSeconds(1)));
assertThrows(InvalidArgumentException.class, () -> collection.getAndTouch(null, Duration.ofSeconds(1)));
assertThrows(InvalidArgumentException.class, () -> collection.getAndTouch("foo", null));
}
use of com.couchbase.client.core.error.DocumentNotFoundException in project couchbase-jvm-clients by couchbase.
the class KeyValueErrorIntegrationTest method verifyTouchExceptions.
@Test
void verifyTouchExceptions() {
assertThrows(InvalidArgumentException.class, () -> collection.touch("foo", null));
assertThrows(InvalidArgumentException.class, () -> collection.touch(null, Duration.ofSeconds(1), null));
assertThrows(InvalidArgumentException.class, () -> collection.touch("foo", null, touchOptions()));
DocumentNotFoundException thrown = assertThrows(DocumentNotFoundException.class, () -> collection.touch(UUID.randomUUID().toString(), Duration.ofSeconds(1)));
assertNotNull(thrown.context());
}
use of com.couchbase.client.core.error.DocumentNotFoundException in project couchbase-jvm-clients by couchbase.
the class KeyValueErrorIntegrationTest method verifyGetAndLockExceptions.
@Test
void verifyGetAndLockExceptions() {
DocumentNotFoundException thrown = assertThrows(DocumentNotFoundException.class, () -> collection.getAndLock(UUID.randomUUID().toString(), Duration.ofSeconds(1)));
assertNotNull(thrown.context());
assertThrows(InvalidArgumentException.class, () -> collection.getAndLock("foo", Duration.ofSeconds(1), null));
assertThrows(InvalidArgumentException.class, () -> collection.getAndLock("", Duration.ofSeconds(1)));
assertThrows(InvalidArgumentException.class, () -> collection.getAndLock(null, Duration.ofSeconds(1)));
assertThrows(InvalidArgumentException.class, () -> collection.getAndLock("foo", null));
}
use of com.couchbase.client.core.error.DocumentNotFoundException in project couchbase-jvm-clients by couchbase.
the class KeyValueIntegrationTest method touch.
/**
* Right now the mock does not change the cas on touch, so we need to ignore the test
* until https://github.com/couchbase/CouchbaseMock/issues/50 is resolved.
*/
@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED })
void touch() throws Exception {
String id = UUID.randomUUID().toString();
JsonObject expected = JsonObject.create().put("foo", true);
MutationResult upsert = collection.upsert(id, expected, upsertOptions().expiry(Duration.ofSeconds(10)));
assertTrue(upsert.cas() != 0);
MutationResult touched = collection.touch(id, Duration.ofSeconds(1));
assertNotEquals(touched.cas(), upsert.cas());
Thread.sleep(300);
GetResult r = collection.get(id);
assertEquals(expected, r.contentAsObject());
assertEquals(r.cas(), touched.cas());
waitUntilCondition(() -> {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignored.
}
try {
collection.get(id);
return false;
} catch (DocumentNotFoundException knf) {
return true;
}
});
}
Aggregations