Search in sources :

Example 16 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class SubdocMutateIntegrationTest method removeXattr.

@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void removeXattr() {
    JsonObject updatedContent = checkSingleOpSuccessXattr(JsonObject.create().put("foo", "bar"), Arrays.asList(MutateInSpec.remove("x.foo").xattr()));
    assertFalse(updatedContent.containsKey("foo"));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 17 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class SubdocMutateIntegrationTest method arrayInsertUniqueDoesNotExist.

@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED })
void arrayInsertUniqueDoesNotExist() {
    JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create().put("foo", JsonArray.from("hello", "world")), Arrays.asList(MutateInSpec.arrayAddUnique("foo", "cruel")));
    assertEquals(JsonArray.from("hello", "world", "cruel"), updatedContent.getArray("foo"));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 18 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class KeyValueErrorIntegrationTest method verifyTouchingLocked.

/**
 * The mock still returns tmpfail but we want to check that the rerty reason is actually locked as it should
 * be post 5.0.
 */
@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void verifyTouchingLocked() {
    String validId = UUID.randomUUID().toString();
    collection.upsert(validId, JsonObject.create());
    collection.getAndLock(validId, Duration.ofSeconds(5));
    TimeoutException exception = assertThrows(TimeoutException.class, () -> collection.getAndTouch(validId, Duration.ofSeconds(2), getAndTouchOptions().timeout(Duration.ofSeconds(1))));
    assertTrue(exception.context().requestContext().retryReasons().contains(RetryReason.KV_LOCKED));
}
Also used : TimeoutException(com.couchbase.client.core.error.TimeoutException) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 19 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class SubdocMutateIntegrationTest method createAsDeletedCanInsertOnTop.

@Test
@IgnoreWhen(missesCapabilities = Capabilities.CREATE_AS_DELETED, clusterTypes = ClusterType.CAVES)
void createAsDeletedCanInsertOnTop() {
    String docId = docId();
    try {
        coll.mutateIn(docId, Collections.singletonList(MutateInSpec.insert("foo", "bar").xattr()), MutateInOptions.mutateInOptions().createAsDeleted(true).storeSemantics(StoreSemantics.INSERT));
        coll.mutateIn(docId, Collections.singletonList(MutateInSpec.insert("foo", "bar").xattr()), MutateInOptions.mutateInOptions().storeSemantics(StoreSemantics.INSERT));
        LookupInResult result = coll.lookupIn(docId, Collections.singletonList(LookupInSpec.get("foo").xattr()));
        assertEquals("bar", result.contentAs(0, String.class));
    } catch (CouchbaseException err) {
        // createAsDeleted flag only supported in 6.5.1+
        assertEquals(ResponseStatus.INVALID_REQUEST, err.context().responseStatus());
    }
}
Also used : LookupInResult(com.couchbase.client.java.kv.LookupInResult) CouchbaseException(com.couchbase.client.core.error.CouchbaseException) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 20 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class SubdocMutateIntegrationTest method removeFullDocAndSetSystemXattr.

@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
@Test
void removeFullDocAndSetSystemXattr() {
    JsonObject content = JsonObject.create().put("foo", "bar");
    String docId = prepare(content);
    // leading underscore lets it survive document deletion
    String systemXattrName = "_x";
    coll.mutateIn(docId, listOf(MutateInSpec.remove(""), MutateInSpec.insert(systemXattrName, "y").xattr()));
    LookupInResult result = coll.lookupIn(docId, listOf(LookupInSpec.get(systemXattrName).xattr()), LookupInOptions.lookupInOptions().accessDeleted(true));
    assertEquals("y", result.contentAs(0, String.class));
    assertTrue(result.isDeleted());
}
Also used : LookupInResult(com.couchbase.client.java.kv.LookupInResult) JsonObject(com.couchbase.client.java.json.JsonObject) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

IgnoreWhen (com.couchbase.client.test.IgnoreWhen)79 Test (org.junit.jupiter.api.Test)78 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)70 JsonObject (com.couchbase.client.java.json.JsonObject)41 GetResult (com.couchbase.client.java.kv.GetResult)15 MutationResult (com.couchbase.client.java.kv.MutationResult)13 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)9 RateLimitedException (com.couchbase.client.core.error.RateLimitedException)8 TimeoutException (com.couchbase.client.core.error.TimeoutException)7 LookupInResult (com.couchbase.client.java.kv.LookupInResult)7 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)6 ReplaceBodyWithXattr (com.couchbase.client.java.kv.ReplaceBodyWithXattr)6 SearchIndex (com.couchbase.client.java.manager.search.SearchIndex)5 CasMismatchException (com.couchbase.client.core.error.CasMismatchException)4 MutateInResult (com.couchbase.client.java.kv.MutateInResult)4 TestNodeConfig (com.couchbase.client.test.TestNodeConfig)4 DocumentNotFoundException (com.couchbase.client.core.error.DocumentNotFoundException)3 FeatureNotAvailableException (com.couchbase.client.core.error.FeatureNotAvailableException)3 UnambiguousTimeoutException (com.couchbase.client.core.error.UnambiguousTimeoutException)3 Core (com.couchbase.client.core.Core)2