Search in sources :

Example 66 with JsonObject

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

the class GetProjectionIntegrationTest method attributes_hobbies_1_details_location_lat.

@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
@Test
void attributes_hobbies_1_details_location_lat() {
    JsonObject decoded = collection.get(DOC_ID, getOptions().project("attributes.hobbies[1].details.location.lat")).contentAsObject();
    JsonArray arr = decoded.getObject("attributes").getArray("hobbies");
    JsonObject obj = arr.getObject(0).getObject("details").getObject("location");
    assertEquals(1, arr.size());
    assertEquals(1, obj.size());
    assertEquals(49.282730, obj.getNumber("lat").doubleValue(), 0.1);
    assertEquals(1, decoded.size());
}
Also used : JsonArray(com.couchbase.client.java.json.JsonArray) 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 67 with JsonObject

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

the class GetProjectionIntegrationTest method attributes_dimensions_height.

@Test
void attributes_dimensions_height() {
    JsonObject decoded = collection.get(DOC_ID, getOptions().project("attributes.dimensions.height")).contentAsObject();
    JsonObject obj = decoded.getObject("attributes").getObject("dimensions");
    assertEquals(1, obj.size());
    assertEquals(67, obj.getInt("height").intValue());
    assertEquals(1, decoded.size());
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 68 with JsonObject

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

the class GetProjectionIntegrationTest method attributes_hobbies_1_details_location.

@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
@Test
void attributes_hobbies_1_details_location() {
    JsonObject decoded = collection.get(DOC_ID, getOptions().project("attributes.hobbies[1].details.location")).contentAsObject();
    JsonArray arr = decoded.getObject("attributes").getArray("hobbies");
    JsonObject obj = arr.getObject(0).getObject("details").getObject("location");
    assertEquals(1, arr.size());
    assertEquals(2, obj.size());
    assertEquals(1, decoded.size());
}
Also used : JsonArray(com.couchbase.client.java.json.JsonArray) 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 69 with JsonObject

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

the class GetProjectionIntegrationTest method attributes.

@Test
void attributes() {
    JsonObject decoded = collection.get(DOC_ID, getOptions().project("attributes")).contentAsObject();
    JsonObject obj = decoded.getObject("attributes");
    assertEquals(3, obj.size());
    assertEquals(1, decoded.size());
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 70 with JsonObject

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

the class GetProjectionIntegrationTest method age.

@Test
void age() {
    JsonObject decoded = collection.get(DOC_ID, getOptions().project("age")).contentAsObject();
    assertEquals(26, decoded.getInt("age").intValue());
    assertEquals(1, decoded.size());
}
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