Search in sources :

Example 6 with SubdocGetResponse

use of com.couchbase.client.core.msg.kv.SubdocGetResponse in project couchbase-jvm-clients by couchbase.

the class SubDocumentGetIntegrationTest method checkExpectedSuccess.

/**
 * Perform subdoc operations and check the overall result was success
 */
private SubdocGetResponse checkExpectedSuccess(String input, List<SubdocGetRequest.Command> commands) {
    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);
    }
    assertTrue(response.status().success());
    assertFalse(response.error().isPresent());
    return response;
}
Also used : SubdocGetResponse(com.couchbase.client.core.msg.kv.SubdocGetResponse) ExecutionException(java.util.concurrent.ExecutionException) SubdocGetRequest(com.couchbase.client.core.msg.kv.SubdocGetRequest)

Example 7 with SubdocGetResponse

use of com.couchbase.client.core.msg.kv.SubdocGetResponse in project couchbase-jvm-clients by couchbase.

the class SubDocumentGetIntegrationTest method existsDoesNotExistMulti.

@Test
void existsDoesNotExistMulti() {
    List<SubdocGetRequest.Command> commands = Arrays.asList(new SubdocGetRequest.Command(SubdocCommandType.EXISTS, "cat", false, 0), new SubdocGetRequest.Command(SubdocCommandType.GET, "foo", false, 1));
    SubdocGetResponse response = checkExpectedSuccess("{\"foo\":\"bar\"}", commands);
    assertFalse(response.values()[0].status().success());
    assertEquals(SubdocCommandType.EXISTS, response.values()[0].type());
}
Also used : SubdocGetResponse(com.couchbase.client.core.msg.kv.SubdocGetResponse) SubdocGetRequest(com.couchbase.client.core.msg.kv.SubdocGetRequest) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

SubdocGetRequest (com.couchbase.client.core.msg.kv.SubdocGetRequest)7 SubdocGetResponse (com.couchbase.client.core.msg.kv.SubdocGetResponse)7 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)5 Test (org.junit.jupiter.api.Test)5 ExecutionException (java.util.concurrent.ExecutionException)2 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)1 PathMismatchException (com.couchbase.client.core.error.subdoc.PathMismatchException)1 PathNotFoundException (com.couchbase.client.core.error.subdoc.PathNotFoundException)1