Search in sources :

Example 41 with JsonObject

use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.

the class SubdocMutateIntegrationTest method arrayAppendListString.

@Test
public void arrayAppendListString() {
    JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create().put("foo", JsonArray.from("hello")), Arrays.asList(MutateInSpec.arrayAppend("foo", Arrays.asList("world", Arrays.asList("mars", "jupiter")))));
    assertEquals(JsonArray.from("hello", "world", JsonArray.from("mars", "jupiter")), updatedContent.getArray("foo"));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 42 with JsonObject

use of com.couchbase.client.java.json.JsonObject 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 43 with JsonObject

use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.

the class SubdocMutateIntegrationTest method arrayAppendXattr.

@Test
void arrayAppendXattr() {
    JsonObject updatedContent = checkSingleOpSuccessXattr(JsonObject.create().put("foo", JsonArray.from("hello")), Arrays.asList(MutateInSpec.arrayAppend("x.foo", Arrays.asList("world")).xattr()));
    assertEquals(JsonArray.from("hello", "world"), updatedContent.getArray("foo"));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 44 with JsonObject

use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.

the class SubdocMutateIntegrationTest method moreThan16.

@Test
void moreThan16() {
    JsonObject content = JsonObject.create().put("hello", "world");
    String docId = prepare(content);
    assertThrows(InvalidArgumentException.class, () -> coll.mutateIn(docId, Arrays.asList(MutateInSpec.insert("foo0", "bar0"), MutateInSpec.insert("foo1", "bar1"), MutateInSpec.insert("foo2", "bar2"), MutateInSpec.insert("foo3", "bar3"), MutateInSpec.insert("foo4", "bar4"), MutateInSpec.insert("foo5", "bar5"), MutateInSpec.insert("foo6", "bar6"), MutateInSpec.insert("foo7", "bar7"), MutateInSpec.insert("foo8", "bar8"), MutateInSpec.insert("foo9", "bar9"), MutateInSpec.insert("foo10", "bar10"), MutateInSpec.insert("foo11", "bar11"), MutateInSpec.insert("foo12", "bar12"), MutateInSpec.insert("foo13", "bar13"), MutateInSpec.insert("foo14", "bar14"), MutateInSpec.insert("foo15", "bar15"), MutateInSpec.insert("foo16", "bar16"))));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 45 with JsonObject

use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.

the class SubdocMutateIntegrationTest method upsertString.

@Test
void upsertString() {
    JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create().put("foo", "bar"), Arrays.asList(upsert("foo", "bar2")));
    assertEquals("bar2", updatedContent.getString("foo"));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

JsonObject (com.couchbase.client.java.json.JsonObject)189 Test (org.junit.jupiter.api.Test)145 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)119 IgnoreWhen (com.couchbase.client.test.IgnoreWhen)39 JsonArray (com.couchbase.client.java.json.JsonArray)18 QueryResult (com.couchbase.client.java.query.QueryResult)16 GetResult (com.couchbase.client.java.kv.GetResult)15 MutationResult (com.couchbase.client.java.kv.MutationResult)15 QueryOptions (com.couchbase.client.java.query.QueryOptions)15 ReactiveQueryResult (com.couchbase.client.java.query.ReactiveQueryResult)15 RequestSpan (com.couchbase.client.core.cnc.RequestSpan)6 RetryStrategy (com.couchbase.client.core.retry.RetryStrategy)6 Collection (com.couchbase.client.java.Collection)6 ReplaceBodyWithXattr (com.couchbase.client.java.kv.ReplaceBodyWithXattr)6 Duration (java.time.Duration)6 DisplayName (org.junit.jupiter.api.DisplayName)6 CouchbaseUtilTest (org.talend.components.couchbase.CouchbaseUtilTest)6 ArrayList (java.util.ArrayList)5 TestData (org.talend.components.couchbase.TestData)5 MutateInResult (com.couchbase.client.java.kv.MutateInResult)4