use of com.couchbase.client.core.msg.kv.InsertResponse in project couchbase-jvm-clients by couchbase.
the class ObserveIntegrationTest method returnsIfBothAreNone.
@Test
void returnsIfBothAreNone() {
String id = UUID.randomUUID().toString();
InsertResponse insertResponse = performInsert(id);
ObserveContext ctx = new ObserveContext(core.context(), Observe.ObservePersistTo.NONE, Observe.ObserveReplicateTo.NONE, Optional.empty(), insertResponse.cas(), cid, id, false, env.timeoutConfig().kvTimeout(), null);
Observe.poll(ctx).timeout(MAX_WAIT).block();
}
use of com.couchbase.client.core.msg.kv.InsertResponse in project couchbase-jvm-clients by couchbase.
the class ObserveIntegrationTest method performInsert.
/**
* Helper method to write a new document which can then be observed.
*
* @param id the document id.
* @return returns the response to use for observe.
*/
private InsertResponse performInsert(final String id) {
byte[] content = "hello, world".getBytes(UTF_8);
InsertRequest insertRequest = new InsertRequest(id, content, 0, 0, env.timeoutConfig().kvTimeout(), core.context(), cid, env.retryStrategy(), Optional.empty(), null);
core.send(insertRequest);
InsertResponse insertResponse;
try {
insertResponse = insertRequest.response().get();
} catch (Exception e) {
throw new RuntimeException(e);
}
assertTrue(insertResponse.status().success());
assertTrue(insertResponse.cas() != 0);
return insertResponse;
}
use of com.couchbase.client.core.msg.kv.InsertResponse in project couchbase-jvm-clients by couchbase.
the class TransportEncryptionIntegrationTest method runKeyValueOperation.
private void runKeyValueOperation(Core core, CoreEnvironment env) throws Exception {
String id = UUID.randomUUID().toString();
byte[] content = "hello, world".getBytes(UTF_8);
InsertRequest insertRequest = new InsertRequest(id, content, 0, 0, kvTimeout, core.context(), CollectionIdentifier.fromDefault(config().bucketname()), env.retryStrategy(), Optional.empty(), null);
core.send(insertRequest);
InsertResponse insertResponse = insertRequest.response().get();
assertTrue(insertResponse.status().success());
GetRequest getRequest = new GetRequest(id, kvTimeout, core.context(), CollectionIdentifier.fromDefault(config().bucketname()), env.retryStrategy(), null);
core.send(getRequest);
GetResponse getResponse = getRequest.response().get();
assertTrue(getResponse.status().success());
assertArrayEquals(content, getResponse.content());
assertTrue(getResponse.cas() != 0);
}
use of com.couchbase.client.core.msg.kv.InsertResponse in project couchbase-jvm-clients by couchbase.
the class MutationTokenIntegrationTest method tokenOnDecrement.
@Test
void tokenOnDecrement() throws Exception {
String id = UUID.randomUUID().toString();
byte[] content = "10".getBytes(UTF_8);
InsertRequest insertRequest = new InsertRequest(id, content, 0, 0, kvTimeout, core.context(), collectionIdentifier, env.retryStrategy(), Optional.empty(), null);
core.send(insertRequest);
InsertResponse insertResponse = insertRequest.response().get();
assertTrue(insertResponse.status().success());
assertMutationToken(insertResponse.mutationToken());
DecrementRequest decrementRequest = new DecrementRequest(kvTimeout, core.context(), collectionIdentifier, env.retryStrategy(), id, 1, Optional.empty(), 0, Optional.empty(), null);
core.send(decrementRequest);
DecrementResponse decrementResponse = decrementRequest.response().get();
assertTrue(decrementResponse.status().success());
assertMutationToken(decrementResponse.mutationToken());
}
use of com.couchbase.client.core.msg.kv.InsertResponse in project couchbase-jvm-clients by couchbase.
the class SubDocumentGetIntegrationTest method insertContent.
private byte[] insertContent(String id, String in) {
byte[] content = in.getBytes(UTF_8);
InsertRequest insertRequest = new InsertRequest(id, content, 0, 0, kvTimeout, core.context(), CollectionIdentifier.fromDefault(config().bucketname()), env.retryStrategy(), Optional.empty(), null);
core.send(insertRequest);
InsertResponse insertResponse = null;
try {
insertResponse = insertRequest.response().get();
} catch (InterruptedException | ExecutionException e) {
fail("Failed with " + e);
}
assertTrue(insertResponse.status().success());
return content;
}
Aggregations