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;
}
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());
}
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();
}
Aggregations