Search in sources :

Example 1 with RemoveResponse

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

the class ObserveIntegrationTest method performRemove.

/**
 * Helper method to perform a remove operation that can then be observed.
 *
 * @param id the document id.
 * @return returns the response to use for observe.
 */
private RemoveResponse performRemove(final String id) {
    RemoveRequest removeRequest = new RemoveRequest(id, 0, env.timeoutConfig().kvTimeout(), core.context(), cid, env.retryStrategy(), Optional.empty(), null);
    core.send(removeRequest);
    RemoveResponse removeResponse;
    try {
        removeResponse = removeRequest.response().get();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    assertTrue(removeResponse.status().success());
    assertTrue(removeResponse.cas() != 0);
    return removeResponse;
}
Also used : RemoveResponse(com.couchbase.client.core.msg.kv.RemoveResponse) RemoveRequest(com.couchbase.client.core.msg.kv.RemoveRequest) ReplicaNotConfiguredException(com.couchbase.client.core.error.ReplicaNotConfiguredException)

Example 2 with RemoveResponse

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

the class MutationTokenIntegrationTest method tokenOnRemove.

@Test
void tokenOnRemove() throws Exception {
    String id = UUID.randomUUID().toString();
    byte[] content = "hello, world".getBytes(UTF_8);
    UpsertRequest upsertRequest = new UpsertRequest(id, content, 0, false, 0, kvTimeout, core.context(), collectionIdentifier, env.retryStrategy(), Optional.empty(), null);
    core.send(upsertRequest);
    UpsertResponse upsertResponse = upsertRequest.response().get();
    assertTrue(upsertResponse.status().success());
    assertMutationToken(upsertResponse.mutationToken());
    RemoveRequest removeRequest = new RemoveRequest(id, upsertResponse.cas(), kvTimeout, core.context(), collectionIdentifier, env.retryStrategy(), Optional.empty(), null);
    core.send(removeRequest);
    RemoveResponse removeResponse = removeRequest.response().get();
    assertTrue(removeResponse.status().success());
    assertMutationToken(removeResponse.mutationToken());
}
Also used : RemoveResponse(com.couchbase.client.core.msg.kv.RemoveResponse) RemoveRequest(com.couchbase.client.core.msg.kv.RemoveRequest) UpsertResponse(com.couchbase.client.core.msg.kv.UpsertResponse) UpsertRequest(com.couchbase.client.core.msg.kv.UpsertRequest) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with RemoveResponse

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

the class ObserveIntegrationTest method observesRemove.

@Test
void observesRemove() {
    String id = UUID.randomUUID().toString();
    InsertResponse insertResponse = performInsert(id);
    assertTrue(insertResponse.mutationToken().isPresent());
    ObserveContext ctx = new ObserveContext(core.context(), Observe.ObservePersistTo.ACTIVE, Observe.ObserveReplicateTo.NONE, insertResponse.mutationToken(), 0, cid, id, false, env.timeoutConfig().kvTimeout(), null);
    Observe.poll(ctx).timeout(MAX_WAIT).block();
    RemoveResponse removeResponse = performRemove(id);
    assertTrue(insertResponse.mutationToken().isPresent());
    ObserveContext ctx2 = new ObserveContext(core.context(), Observe.ObservePersistTo.ACTIVE, Observe.ObserveReplicateTo.NONE, removeResponse.mutationToken(), 0, cid, id, true, env.timeoutConfig().kvTimeout(), null);
    Observe.poll(ctx2).timeout(MAX_WAIT).block();
}
Also used : InsertResponse(com.couchbase.client.core.msg.kv.InsertResponse) RemoveResponse(com.couchbase.client.core.msg.kv.RemoveResponse) ObserveContext(com.couchbase.client.core.service.kv.ObserveContext) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest)

Aggregations

RemoveResponse (com.couchbase.client.core.msg.kv.RemoveResponse)3 RemoveRequest (com.couchbase.client.core.msg.kv.RemoveRequest)2 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)2 ReplicaNotConfiguredException (com.couchbase.client.core.error.ReplicaNotConfiguredException)1 InsertResponse (com.couchbase.client.core.msg.kv.InsertResponse)1 UpsertRequest (com.couchbase.client.core.msg.kv.UpsertRequest)1 UpsertResponse (com.couchbase.client.core.msg.kv.UpsertResponse)1 ObserveContext (com.couchbase.client.core.service.kv.ObserveContext)1 Test (org.junit.jupiter.api.Test)1