Search in sources :

Example 11 with JsonNode

use of com.couchbase.client.core.deps.com.fasterxml.jackson.databind.JsonNode in project couchbase-jvm-clients by couchbase.

the class BucketSettings method create.

/**
 * Helper method to create {@link BucketSettings} from a Jackson JsonNode.
 *
 * @param tree the node tree to evaluate.
 * @return the decoded {@link BucketSettings}.
 */
static BucketSettings create(final JsonNode tree) {
    BucketSettings settings = Mapper.convertValue(tree, BucketSettings.class);
    JsonNode nodes = tree.get("nodes");
    if (nodes.isArray() && !nodes.isEmpty()) {
        for (final JsonNode node : nodes) {
            String status = node.get("status").asText();
            if (!status.equals("healthy")) {
                settings.healthy = false;
            }
        }
    } else {
        settings.healthy = false;
    }
    return settings;
}
Also used : JsonNode(com.couchbase.client.core.deps.com.fasterxml.jackson.databind.JsonNode)

Example 12 with JsonNode

use of com.couchbase.client.core.deps.com.fasterxml.jackson.databind.JsonNode in project kafka-connect-couchbase by couchbase.

the class DocumentPathExtractorTest method assertJsonEquals.

private static void assertJsonEquals(String expected, String actual) throws IOException {
    JsonNode parsedExpected = objectMapper.readTree(expected);
    JsonNode parsedActual = objectMapper.readTree(actual);
    assertEquals(parsedExpected, parsedActual);
}
Also used : JsonNode(com.couchbase.client.core.deps.com.fasterxml.jackson.databind.JsonNode)

Aggregations

JsonNode (com.couchbase.client.core.deps.com.fasterxml.jackson.databind.JsonNode)12 ArrayList (java.util.ArrayList)5 CoreHttpClient (com.couchbase.client.core.endpoint.http.CoreHttpClient)2 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)2 InvalidArgumentException (com.couchbase.client.core.error.InvalidArgumentException)2 Map (java.util.Map)2 Core (com.couchbase.client.core.Core)1 CbTracing (com.couchbase.client.core.cnc.CbTracing)1 RequestSpan (com.couchbase.client.core.cnc.RequestSpan)1 TracingIdentifiers (com.couchbase.client.core.cnc.TracingIdentifiers)1 TypeReference (com.couchbase.client.core.deps.com.fasterxml.jackson.core.type.TypeReference)1 ObjectNode (com.couchbase.client.core.deps.com.fasterxml.jackson.databind.node.ObjectNode)1 HttpHeaderNames (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpHeaderNames)1 CoreHttpPath.path (com.couchbase.client.core.endpoint.http.CoreHttpPath.path)1 CoreHttpResponse (com.couchbase.client.core.endpoint.http.CoreHttpResponse)1 AuthenticationFailureException (com.couchbase.client.core.error.AuthenticationFailureException)1 FeatureNotAvailableException (com.couchbase.client.core.error.FeatureNotAvailableException)1 IndexNotFoundException (com.couchbase.client.core.error.IndexNotFoundException)1 Mapper (com.couchbase.client.core.json.Mapper)1 RequestTarget (com.couchbase.client.core.msg.RequestTarget)1