Package org.jboss.dna.graph

Examples of org.jboss.dna.graph.Subgraph


        assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));

        graph.addValue("foo").andValue("bar").to("newProperty").on("node1");

        assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));
        Subgraph subgraph = graph.getSubgraphOfDepth(2).at("/");
        assertThat(subgraph, is(notNullValue()));

        assertThat(subgraph.getNode("node1"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node1"), hasProperty("newProperty", "foo", "bar"));

    }
View Full Code Here


        assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));

        graph.removeValue("The quick brown fox jumped over the moon. What? ").andValue("bar").from("property1").on("node1");

        assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));
        Subgraph subgraph = graph.getSubgraphOfDepth(2).at("/");
        assertThat(subgraph, is(notNullValue()));

        assertThat(subgraph.getNode("node1"), hasProperty("property1"));
    }
View Full Code Here

        assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));

        graph.removeValue("The quick brown fox jumped over the moon. What? ").from("noSuchProperty").on("node1");

        assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));
        Subgraph subgraph = graph.getSubgraphOfDepth(2).at("/");
        assertThat(subgraph, is(notNullValue()));

        assertThat(subgraph.getNode("node1"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
    }
View Full Code Here

                // Clone 'workspace1' into 'workspace2'
                String workspaceName = workspace1.getName();
                Workspace workspace2 = graph.createWorkspace().clonedFrom(workspaceName).named(newWorkspaceName);

                // Verify that the content of 'workspace1' matches that of 'workspace2'
                Subgraph subgraph1 = graph.getSubgraphOfDepth(100000).at(workspace1.getRoot());
                Subgraph subgraph2 = graph.getSubgraphOfDepth(100000).at(workspace2.getRoot());
                assertEquivalentSubgraphs(subgraph1, subgraph2, true, true);
            } catch (InvalidRequestException error) {
                // Updates may not be supported, but if they are then this is a failure ...
                if (source.getCapabilities().supportsUpdates()) throw error;
            }
View Full Code Here

        assertThat(graph.getChildren().of("/node3"), hasChildren(segment("node2"), segment("node3")));
        assertThat(graph.getChildren().of("/node3/node2"), hasChildren(segment("node1"), segment("node2"), segment("node3")));
        assertThat(graph.getChildren().of("/node3/node3"), hasChildren(segment("node1"), segment("node2"), segment("node3")));
        assertThat(graph.getChildren().of("/node3/node3/node1"), hasChildren());

        Subgraph subgraph = graph.getSubgraphOfDepth(3).at("/");
        assertThat(subgraph, is(notNullValue()));
        assertThat(subgraph.getNode(".").getChildren(), hasChildren(segment("node1"), segment("node3")));
        assertThat(subgraph.getNode("node1").getChildren(), hasChildren(segment("node1"), segment("node2"), segment("node3")));
        assertThat(subgraph.getNode("node1"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node1"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node1"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2").getChildren(), hasChildren(segment("node1"), segment("node3")));
        assertThat(subgraph.getNode("node2"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node3").getChildren(), hasChildren(segment("node2"), segment("node3")));
        assertThat(subgraph.getNode("node3"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node3"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node3"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));

        subgraph = graph.getSubgraphOfDepth(2).at("/node3");
        assertThat(subgraph, is(notNullValue()));
        assertThat(subgraph.getNode(".").getChildren(), hasChildren(segment("node2"), segment("node3")));
        assertThat(subgraph.getNode("."), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("."), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("."), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2").getChildren(), isEmpty());
        assertThat(subgraph.getNode("node2"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node3").getChildren(), isEmpty());
        assertThat(subgraph.getNode("node3"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node3"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node3"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
    }
View Full Code Here

        assertThat(graph.getChildren().of("/node3/node2[2]/node3"), hasChildren(segment("node1"),
                                                                                segment("node2"),
                                                                                segment("node3")));
        assertThat(graph.getChildren().of("/node3/node2[2]/node1/node1"), hasChildren());

        Subgraph subgraph = graph.getSubgraphOfDepth(4).at("/node3");
        assertThat(subgraph, is(notNullValue()));
        assertThat(subgraph.getNode(".").getChildren(), hasChildren(segment("node2"), segment("node3")));
        assertThat(subgraph.getNode("."), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("."), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("."), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[1]").getChildren(), hasChildren(segment("node1"), segment("node2"), segment("node3")));
        assertThat(subgraph.getNode("node2[1]"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[1]"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[1]"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node3").getChildren(), isEmpty());
        assertThat(subgraph.getNode("node3"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node3"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node3"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]").getChildren(), hasChildren(segment("node1"), segment("node2"), segment("node3")));
        assertThat(subgraph.getNode("node2[2]"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]"), hasProperty("property2", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]"), hasProperty("property3", "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node1").getChildren(), hasChildren(segment("node1"),
                                                                                 segment("node2"),
                                                                                 segment("node3")));
        assertThat(subgraph.getNode("node2[2]/node1"), hasProperty("property1",
                                                                   "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node1"), hasProperty("property2",
                                                                   "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node1"), hasProperty("property3",
                                                                   "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node1/node1").getChildren(), isEmpty());
        assertThat(subgraph.getNode("node2[2]/node1/node1"), hasProperty("property1",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node1/node1"), hasProperty("property2",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node1/node1"), hasProperty("property3",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node1/node2").getChildren(), isEmpty());
        assertThat(subgraph.getNode("node2[2]/node1/node2"), hasProperty("property1",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node1/node2"), hasProperty("property2",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node1/node2"), hasProperty("property3",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node1/node3").getChildren(), isEmpty());
        assertThat(subgraph.getNode("node2[2]/node1/node3"), hasProperty("property1",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node1/node3"), hasProperty("property2",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node1/node3"), hasProperty("property3",
                                                                         "The quick brown fox jumped over the moon. What? "));
        if (source.getCapabilities().supportsReferences()) {
            assertThat(subgraph.getNode("node2[2]/node2").getChildren(), hasChildren(segment("node1"),
                                                                                     segment("node2"),
                                                                                     segment("node3")));
        }
        assertThat(subgraph.getNode("node2[2]/node2"), hasProperty("property1",
                                                                   "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node2"), hasProperty("property2",
                                                                   "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node2"), hasProperty("property3",
                                                                   "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node2/node1").getChildren(), isEmpty());
        assertThat(subgraph.getNode("node2[2]/node2/node1"), hasProperty("property1",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node2/node1"), hasProperty("property2",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node2/node1"), hasProperty("property3",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node2/node2").getChildren(), isEmpty());
        assertThat(subgraph.getNode("node2[2]/node2/node2"), hasProperty("property1",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node2/node2"), hasProperty("property2",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node2/node2"), hasProperty("property3",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node2/node3").getChildren(), isEmpty());
        assertThat(subgraph.getNode("node2[2]/node2/node3"), hasProperty("property1",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node2/node3"), hasProperty("property2",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node2/node3"), hasProperty("property3",
                                                                         "The quick brown fox jumped over the moon. What? "));
        if (source.getCapabilities().supportsReferences()) {
            assertThat(subgraph.getNode("node2[2]/node3").getChildren(), hasChildren(segment("node1"),
                                                                                     segment("node2"),
                                                                                     segment("node3")));
        }
        assertThat(subgraph.getNode("node2[2]/node3"), hasProperty("property1",
                                                                   "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node3"), hasProperty("property2",
                                                                   "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node3"), hasProperty("property3",
                                                                   "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node3/node1").getChildren(), isEmpty());
        assertThat(subgraph.getNode("node2[2]/node3/node1"), hasProperty("property1",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node3/node1"), hasProperty("property2",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node3/node1"), hasProperty("property3",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node3/node2").getChildren(), isEmpty());
        assertThat(subgraph.getNode("node2[2]/node3/node2"), hasProperty("property1",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node3/node2"), hasProperty("property2",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node3/node2"), hasProperty("property3",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node3/node3").getChildren(), isEmpty());
        assertThat(subgraph.getNode("node2[2]/node3/node3"), hasProperty("property1",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node3/node3"), hasProperty("property2",
                                                                         "The quick brown fox jumped over the moon. What? "));
        assertThat(subgraph.getNode("node2[2]/node3/node3"), hasProperty("property3",
                                                                         "The quick brown fox jumped over the moon. What? "));
    }
View Full Code Here

        int numPropertiesPerNode = 3;
        Stopwatch sw = new Stopwatch();
        boolean batch = true;
        createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null);

        Subgraph source = graph.getSubgraphOfDepth(3).at("/node1");

        graph.useWorkspace(defaultWorkspaceName);

        graph.create("/newUuids").and();
        graph.copy("/node1").fromWorkspace(workspaceName).to("/newUuids/node1");

        /*
         * Focus on testing node structure, since shouldCopyNodeWithChildren tests that properties get copied
         */
        Subgraph target = graph.getSubgraphOfDepth(3).at("/newUuids/node1");
        assertThat(target, is(notNullValue()));
        assertThat(target.getNode(".").getChildren(), hasChildren(segment("node1"), segment("node2"), segment("node3")));
        assertThat(uuidFor(target.getNode(".")), not(uuidFor(source.getNode("."))));
        assertThat(target.getNode("node1").getChildren(), hasChildren(segment("node1"), segment("node2"), segment("node3")));
        assertThat(uuidFor(target.getNode("node1")), not(uuidFor(source.getNode("node1"))));
        assertThat(target.getNode("node2").getChildren(), hasChildren(segment("node1"), segment("node2"), segment("node3")));
        assertThat(uuidFor(target.getNode("node2")), not(uuidFor(source.getNode("node2"))));
        assertThat(target.getNode("node3").getChildren(), hasChildren(segment("node1"), segment("node2"), segment("node3")));
        assertThat(uuidFor(target.getNode("node3")), not(uuidFor(source.getNode("node3"))));

    }
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.Subgraph

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.