Package org.apache.jackrabbit.oak.plugins.document.MongoDiffCache

Examples of org.apache.jackrabbit.oak.plugins.document.MongoDiffCache.Diff


    @Test
    public void diff() {
        Revision from = Revision.fromString("r1-0-1");
        Revision to = Revision.fromString("r2-0-1");
        Diff diff = new Diff(from, to);
        diff.append("/", "^\"foo\":{}");
        diff.append("/foo", "^\"bar\":{}");
        diff.append("/foo/bar", "-\"qux\"");

        assertEquals("^\"foo\":{}", diff.getChanges("/"));
        assertEquals("^\"bar\":{}", diff.getChanges("/foo"));
        assertEquals("-\"qux\"", diff.getChanges("/foo/bar"));
        assertEquals("", diff.getChanges("/baz"));
    }
View Full Code Here


        assertEquals("^", doMerge("^", "-", "+", "^"));
    }

    private String doMerge(String... ops) {
        List<String> opsList = Arrays.asList(ops);
        Diff diff = null;
        for (int i = opsList.size() - 1; i >= 0; i--) {
            String op = opsList.get(i);
            if (diff == null) {
                diff = diffFromOp(op);
            } else {
                diff.mergeBeforeDiff(diffFromOp(op));
            }
        }
        if (diff == null) {
            return null;
        }
        String changes = diff.getChanges("/test");
        if (changes == null) {
            return null;
        } else if (changes.length() == 0) {
            return "";
        } else {
View Full Code Here

    }

    private static Diff diffFromOp(String op) {
        Revision from = Revision.fromString("r1-0-1");
        Revision to = Revision.fromString("r2-0-1");
        Diff d = new Diff(from, to);
        d.append("/test", changeFromOp(op));
        return d;
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.document.MongoDiffCache.Diff

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.