Search in sources :

Example 46 with JsonArray

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

the class GetProjectionIntegrationTest method attributes_hobbies_1_type.

@Test
void attributes_hobbies_1_type() {
    JsonObject decoded = collection.get(DOC_ID, getOptions().project("attributes.hobbies[1].type")).contentAsObject();
    JsonArray arr = decoded.getObject("attributes").getArray("hobbies");
    assertEquals(1, arr.size());
    assertEquals("summer sports", arr.getObject(0).getString("type"));
    assertEquals(1, decoded.size());
}
Also used : JsonArray(com.couchbase.client.java.json.JsonArray) JsonObject(com.couchbase.client.java.json.JsonObject) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 47 with JsonArray

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

the class GetProjectionIntegrationTest method animals_1.

@Test
void animals_1() {
    JsonObject decoded = collection.get(DOC_ID, getOptions().project("animals[1]")).contentAsObject();
    JsonArray arr = decoded.getArray("animals");
    assertEquals(1, arr.size());
    assertEquals("dog", arr.get(0));
    assertEquals(1, decoded.size());
}
Also used : JsonArray(com.couchbase.client.java.json.JsonArray) JsonObject(com.couchbase.client.java.json.JsonObject) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 48 with JsonArray

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

the class GetProjectionIntegrationTest method animals_2.

@Test
void animals_2() {
    JsonObject decoded = collection.get(DOC_ID, getOptions().project("animals[2]")).contentAsObject();
    JsonArray arr = decoded.getArray("animals");
    assertEquals(1, arr.size());
    assertEquals("parrot", arr.get(0));
    assertEquals(1, decoded.size());
}
Also used : JsonArray(com.couchbase.client.java.json.JsonArray) JsonObject(com.couchbase.client.java.json.JsonObject) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

JsonArray (com.couchbase.client.java.json.JsonArray)48 Test (org.junit.jupiter.api.Test)26 JsonObject (com.couchbase.client.java.json.JsonObject)24 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)8 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)3 IndexFailureException (com.couchbase.client.core.error.IndexFailureException)3 List (java.util.List)3 Airport (org.springframework.data.couchbase.domain.Airport)3 DocumentNotFoundException (com.couchbase.client.core.error.DocumentNotFoundException)2 InvalidArgumentException (com.couchbase.client.core.error.InvalidArgumentException)2 RetryExhaustedException (com.couchbase.client.core.retry.reactor.RetryExhaustedException)2 JsonValue (com.couchbase.client.java.json.JsonValue)2 GetResult (com.couchbase.client.java.kv.GetResult)2 QueryOptions (com.couchbase.client.java.query.QueryOptions)2 SearchQuery (com.couchbase.client.java.search.SearchQuery)2 IgnoreWhen (com.couchbase.client.test.IgnoreWhen)2 Duration (java.time.Duration)2 ArrayList (java.util.ArrayList)2 Query (org.springframework.data.couchbase.core.query.Query)2 AirportRepositoryScanConsistencyTest (org.springframework.data.couchbase.domain.AirportRepositoryScanConsistencyTest)2