use of com.couchbase.client.core.msg.kv.UpsertResponse in project couchbase-jvm-clients by couchbase.
the class MutationTokenIntegrationTest method tokenOnSubdocMutate.
@Test
void tokenOnSubdocMutate() throws Exception {
String id = UUID.randomUUID().toString();
byte[] content = "{}".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());
List<SubdocMutateRequest.Command> commands = new ArrayList<>();
commands.add(new SubdocMutateRequest.Command(SubdocCommandType.DICT_ADD, "foo", "\"bar\"".getBytes(UTF_8), true, false, false, 0));
SubdocMutateRequest subdocMutateRequest = new SubdocMutateRequest(kvTimeout, core.context(), collectionIdentifier, null, env.retryStrategy(), id, false, false, false, false, false, commands, 0, false, 0, Optional.empty(), null);
core.send(subdocMutateRequest);
SubdocMutateResponse subdocMutateResponse = subdocMutateRequest.response().get();
assertTrue(subdocMutateResponse.status().success());
assertMutationToken(subdocMutateResponse.mutationToken());
}
use of com.couchbase.client.core.msg.kv.UpsertResponse in project couchbase-jvm-clients by couchbase.
the class MutationTokenIntegrationTest method tokenOnPrepend.
@Test
void tokenOnPrepend() throws Exception {
String id = UUID.randomUUID().toString();
byte[] content = "hello".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());
PrependRequest prependRequest = new PrependRequest(kvTimeout, core.context(), collectionIdentifier, env.retryStrategy(), id, ", world".getBytes(UTF_8), upsertResponse.cas(), Optional.empty(), null);
core.send(prependRequest);
PrependResponse prependResponse = prependRequest.response().get();
assertTrue(prependResponse.status().success());
assertMutationToken(prependResponse.mutationToken());
}
use of com.couchbase.client.core.msg.kv.UpsertResponse 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.UpsertResponse in project couchbase-jvm-clients by couchbase.
the class SyncReplicationIntegrationTest method upsertSuccessfullyToMajority.
/**
* This test works if a cluster has two or more nodes and one replica configured.
*/
@Test
@IgnoreWhen(nodesLessThan = 2, replicasLessThan = 1, replicasGreaterThan = 1, missesCapabilities = { Capabilities.SYNC_REPLICATION }, clusterTypes = ClusterType.CAVES)
void upsertSuccessfullyToMajority() 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.fromDefault(config().bucketname()), env.retryStrategy(), Optional.of(DurabilityLevel.MAJORITY), null);
core.send(upsertRequest);
UpsertResponse upsertResponse = upsertRequest.response().get();
assertTrue(upsertResponse.status().success());
assertTrue(upsertResponse.cas() != 0);
}
use of com.couchbase.client.core.msg.kv.UpsertResponse in project couchbase-jvm-clients by couchbase.
the class MutationTokenIntegrationTest method tokenOnReplace.
@Test
void tokenOnReplace() 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());
ReplaceRequest replaceRequest = new ReplaceRequest(id, content, 0, false, 0, kvTimeout, upsertResponse.cas(), core.context(), collectionIdentifier, env.retryStrategy(), Optional.empty(), null);
core.send(replaceRequest);
ReplaceResponse replaceResponse = replaceRequest.response().get();
assertTrue(replaceResponse.status().success());
assertMutationToken(replaceResponse.mutationToken());
}
Aggregations