Search in sources :

Example 16 with JsopBuilder

use of org.apache.jackrabbit.oak.commons.json.JsopBuilder in project jackrabbit-oak by apache.

the class NodeStateJsonUtils method toJson.

public static String toJson(NodeState state, boolean includeHiddenContent) {
    JsopWriter json = new JsopBuilder();
    copyAsJson(json, state, includeHiddenContent);
    return json.toString();
}
Also used : JsopBuilder(org.apache.jackrabbit.oak.commons.json.JsopBuilder) JsopWriter(org.apache.jackrabbit.oak.commons.json.JsopWriter)

Example 17 with JsopBuilder

use of org.apache.jackrabbit.oak.commons.json.JsopBuilder in project jackrabbit-oak by apache.

the class BundledDocumentDifferTest method diffWithSecondary.

@Test
public void diffWithSecondary() throws Exception {
    configureSecondary();
    NodeBuilder builder = createContentStructure();
    NodeState r1 = merge(store, builder);
    NodeState rs1 = DelegatingDocumentNodeState.wrap(secondary.getRoot(), store);
    builder = store.getRoot().builder();
    childBuilder(builder, "/test/book.jpg/jcr:content").setProperty("foo", "bar");
    NodeState r2 = merge(store, builder);
    JsopWriter w = new JsopBuilder();
    String path = "/test/book.jpg";
    assertFalse(differ.diff(adns(rs1, path), adns(r2, path), w));
    assertEquals("^\"jcr:content\":{}", w.toString());
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) DelegatingDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.secondary.DelegatingDocumentNodeState) DocumentNodeState(org.apache.jackrabbit.oak.plugins.document.DocumentNodeState) JsopBuilder(org.apache.jackrabbit.oak.commons.json.JsopBuilder) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) JsopWriter(org.apache.jackrabbit.oak.commons.json.JsopWriter) Test(org.junit.Test)

Example 18 with JsopBuilder

use of org.apache.jackrabbit.oak.commons.json.JsopBuilder in project jackrabbit-oak by apache.

the class BundledDocumentDifferTest method jsopDiff.

@Test
public void jsopDiff() throws Exception {
    JsopWriter w = new JsopBuilder();
    differ.diffChildren(of("a", "b"), of("b", "c"), w);
    //removed a
    //changed b
    //added b
    assertEquals("-\"a\"^\"b\":{}+\"c\":{}", w.toString());
}
Also used : JsopBuilder(org.apache.jackrabbit.oak.commons.json.JsopBuilder) JsopWriter(org.apache.jackrabbit.oak.commons.json.JsopWriter) Test(org.junit.Test)

Aggregations

JsopBuilder (org.apache.jackrabbit.oak.commons.json.JsopBuilder)18 JsopWriter (org.apache.jackrabbit.oak.commons.json.JsopWriter)9 Test (org.junit.Test)5 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 AbstractDocumentNodeState (org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState)2 DocumentNodeState (org.apache.jackrabbit.oak.plugins.document.DocumentNodeState)2 DelegatingDocumentNodeState (org.apache.jackrabbit.oak.plugins.document.secondary.DelegatingDocumentNodeState)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Random (java.util.Random)1 Node (javax.jcr.Node)1 NodeIterator (javax.jcr.NodeIterator)1 Value (javax.jcr.Value)1