Search in sources :

Example 1 with ObserveContext

use of com.couchbase.client.core.service.kv.ObserveContext 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();
}
Also used : InsertResponse(com.couchbase.client.core.msg.kv.InsertResponse) ObserveContext(com.couchbase.client.core.service.kv.ObserveContext) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest)

Example 2 with ObserveContext

use of com.couchbase.client.core.service.kv.ObserveContext in project couchbase-jvm-clients by couchbase.

the class ObserveIntegrationTest method failsFastIfTooManyReplicasRequested.

@Test
@IgnoreWhen(replicasGreaterThan = 1)
void failsFastIfTooManyReplicasRequested() {
    String id = UUID.randomUUID().toString();
    InsertResponse insertResponse = performInsert(id);
    assertTrue(insertResponse.mutationToken().isPresent());
    final ObserveContext ctx = new ObserveContext(core.context(), Observe.ObservePersistTo.THREE, Observe.ObserveReplicateTo.NONE, insertResponse.mutationToken(), 0, cid, id, false, env.timeoutConfig().kvTimeout(), null);
    assertThrows(ReplicaNotConfiguredException.class, () -> Observe.poll(ctx).timeout(MAX_WAIT).block());
    final ObserveContext ctx2 = new ObserveContext(core.context(), Observe.ObservePersistTo.NONE, Observe.ObserveReplicateTo.TWO, insertResponse.mutationToken(), 0, cid, id, false, env.timeoutConfig().kvTimeout(), null);
    assertThrows(ReplicaNotConfiguredException.class, () -> Observe.poll(ctx2).timeout(MAX_WAIT).block());
    final ObserveContext ctx3 = new ObserveContext(core.context(), Observe.ObservePersistTo.FOUR, Observe.ObserveReplicateTo.THREE, insertResponse.mutationToken(), 0, cid, id, false, env.timeoutConfig().kvTimeout(), null);
    assertThrows(ReplicaNotConfiguredException.class, () -> Observe.poll(ctx3).timeout(MAX_WAIT).block());
}
Also used : InsertResponse(com.couchbase.client.core.msg.kv.InsertResponse) ObserveContext(com.couchbase.client.core.service.kv.ObserveContext) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest)

Example 3 with ObserveContext

use of com.couchbase.client.core.service.kv.ObserveContext 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)

Example 4 with ObserveContext

use of com.couchbase.client.core.service.kv.ObserveContext in project couchbase-jvm-clients by couchbase.

the class ObserveIntegrationTest method persistToActive.

@Test
void persistToActive() {
    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();
}
Also used : InsertResponse(com.couchbase.client.core.msg.kv.InsertResponse) ObserveContext(com.couchbase.client.core.service.kv.ObserveContext) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest)

Aggregations

InsertResponse (com.couchbase.client.core.msg.kv.InsertResponse)4 ObserveContext (com.couchbase.client.core.service.kv.ObserveContext)4 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)4 RemoveResponse (com.couchbase.client.core.msg.kv.RemoveResponse)1 IgnoreWhen (com.couchbase.client.test.IgnoreWhen)1