Search in sources :

Example 11 with InsertRequest

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

the class MutationTokenIntegrationTest method tokenOnInsert.

@Test
void tokenOnInsert() 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, env.retryStrategy(), Optional.empty(), null);
    core.send(insertRequest);
    InsertResponse insertResponse = insertRequest.response().get();
    assertTrue(insertResponse.status().success());
    assertMutationToken(insertResponse.mutationToken());
}
Also used : InsertResponse(com.couchbase.client.core.msg.kv.InsertResponse) InsertRequest(com.couchbase.client.core.msg.kv.InsertRequest) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 12 with InsertRequest

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

the class MutationTokenIntegrationTest method tokenOnIncrement.

@Test
void tokenOnIncrement() throws Exception {
    String id = UUID.randomUUID().toString();
    byte[] content = "1".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());
    IncrementRequest incrementRequest = new IncrementRequest(kvTimeout, core.context(), collectionIdentifier, env.retryStrategy(), id, 1, Optional.empty(), 0, Optional.empty(), null);
    core.send(incrementRequest);
    IncrementResponse incrementResponse = incrementRequest.response().get();
    assertTrue(incrementResponse.status().success());
    assertMutationToken(incrementResponse.mutationToken());
}
Also used : InsertResponse(com.couchbase.client.core.msg.kv.InsertResponse) IncrementRequest(com.couchbase.client.core.msg.kv.IncrementRequest) InsertRequest(com.couchbase.client.core.msg.kv.InsertRequest) IncrementResponse(com.couchbase.client.core.msg.kv.IncrementResponse) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

InsertRequest (com.couchbase.client.core.msg.kv.InsertRequest)12 InsertResponse (com.couchbase.client.core.msg.kv.InsertResponse)8 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)6 Test (org.junit.jupiter.api.Test)6 ExecutionException (java.util.concurrent.ExecutionException)4 FeatureNotAvailableException (com.couchbase.client.core.error.FeatureNotAvailableException)2 GetRequest (com.couchbase.client.core.msg.kv.GetRequest)2 GetResponse (com.couchbase.client.core.msg.kv.GetResponse)2 IgnoreWhen (com.couchbase.client.test.IgnoreWhen)2 RequestSpan (com.couchbase.client.core.cnc.RequestSpan)1 ReplicaNotConfiguredException (com.couchbase.client.core.error.ReplicaNotConfiguredException)1 CollectionIdentifier (com.couchbase.client.core.io.CollectionIdentifier)1 DecrementRequest (com.couchbase.client.core.msg.kv.DecrementRequest)1 DecrementResponse (com.couchbase.client.core.msg.kv.DecrementResponse)1 IncrementRequest (com.couchbase.client.core.msg.kv.IncrementRequest)1 IncrementResponse (com.couchbase.client.core.msg.kv.IncrementResponse)1 RetryStrategy (com.couchbase.client.core.retry.RetryStrategy)1 Transcoder (com.couchbase.client.java.codec.Transcoder)1 InsertOptions (com.couchbase.client.java.kv.InsertOptions)1 Duration (java.time.Duration)1