use of com.couchbase.client.core.msg.kv.SubdocGetResponse in project couchbase-jvm-clients by couchbase.
the class SubDocumentGetIntegrationTest method existsDoesExistSingle.
@Test
void existsDoesExistSingle() {
List<SubdocGetRequest.Command> commands = Collections.singletonList(new SubdocGetRequest.Command(SubdocCommandType.EXISTS, "foo", false, 0));
SubdocGetResponse response = checkExpectedSuccess("{\"foo\":\"bar\"}", commands);
assertTrue(response.values()[0].status().success());
}
use of com.couchbase.client.core.msg.kv.SubdocGetResponse in project couchbase-jvm-clients by couchbase.
the class SubDocumentGetIntegrationTest method pathNotFoundMulti.
@Test
void pathNotFoundMulti() {
List<SubdocGetRequest.Command> commands = Arrays.asList(new SubdocGetRequest.Command(SubdocCommandType.GET, "foo", false, 0), new SubdocGetRequest.Command(SubdocCommandType.GET, "no_exist", false, 1));
SubdocGetResponse response = checkExpectedSuccess("{\"foo\":\"bar\"}", commands);
assertTrue(response.values()[0].status().success());
assertEquals(SubDocumentOpResponseStatus.PATH_NOT_FOUND, response.values()[1].status());
assertTrue(response.values()[1].error().get() instanceof PathNotFoundException);
assertEquals(SubdocCommandType.GET, response.values()[0].type());
assertEquals(SubdocCommandType.GET, response.values()[1].type());
}
use of com.couchbase.client.core.msg.kv.SubdocGetResponse in project couchbase-jvm-clients by couchbase.
the class SubDocumentGetIntegrationTest method checkExpectedFailure.
/**
* Perform subdoc operations and assert the result is the expected exception
*/
private void checkExpectedFailure(String input, List<SubdocGetRequest.Command> commands, Class<?> expected) {
String id = UUID.randomUUID().toString();
insertContent(id, input);
SubdocGetRequest request = new SubdocGetRequest(kvTimeout, core.context(), CollectionIdentifier.fromDefault(config().bucketname()), env.retryStrategy(), id, (byte) 0, commands, null);
core.send(request);
SubdocGetResponse response = null;
try {
response = request.response().get();
} catch (InterruptedException | ExecutionException e) {
fail("Failed with " + e);
}
assertFalse(response.status().success());
assertEquals(ResponseStatus.SUBDOC_FAILURE, response.status());
assertTrue(response.error().isPresent());
CouchbaseException err = response.error().get();
assertTrue(expected.isInstance(err));
}
use of com.couchbase.client.core.msg.kv.SubdocGetResponse in project couchbase-jvm-clients by couchbase.
the class SubDocumentGetIntegrationTest method existsDoesNotExistSingle.
@Test
void existsDoesNotExistSingle() {
List<SubdocGetRequest.Command> commands = Collections.singletonList(new SubdocGetRequest.Command(SubdocCommandType.EXISTS, "cat", false, 0));
SubdocGetResponse response = checkExpectedSuccess("{\"foo\":\"bar\"}", commands);
assertFalse(response.values()[0].status().success());
assertEquals(SubdocCommandType.EXISTS, response.values()[0].type());
}
use of com.couchbase.client.core.msg.kv.SubdocGetResponse in project couchbase-jvm-clients by couchbase.
the class SubDocumentGetIntegrationTest method pathMismatchMulti.
@Test
void pathMismatchMulti() {
List<SubdocGetRequest.Command> commands = Arrays.asList(new SubdocGetRequest.Command(SubdocCommandType.GET, "foo", false, 0), new SubdocGetRequest.Command(SubdocCommandType.GET, "foo.bar[0].baz", false, 1));
SubdocGetResponse response = checkExpectedSuccess("{\"foo\":\"bar\"}", commands);
assertTrue(response.values()[0].status().success());
assertEquals(SubDocumentOpResponseStatus.PATH_MISMATCH, response.values()[1].status());
assertTrue(response.values()[1].error().get() instanceof PathMismatchException);
}
Aggregations