Package org.jboss.dna.graph

Examples of org.jboss.dna.graph.Node


                }
            }

            RepositorySource source = repositoryLibrary.getSource(repositorySourceName);
            Graph graph = Graph.create(source, context);
            Node node = null;
            if (!sequencers.isEmpty()) {

                // Find the changed node ...
                node = graph.getNodeAt(nodePath);
View Full Code Here


                Subgraph sourcesGraph = graph.getSubgraphOfDepth(3).at(pathToSourcesNode);

                // Iterate over each of the children, and create the RepositorySource ...
                for (Location location : sourcesGraph.getRoot().getChildren()) {
                    Node sourceNode = sourcesGraph.getNode(location);
                    sources.addSource(createRepositorySource(location.getPath(), sourceNode.getPropertiesByName(), problems));
                }
            } catch (PathNotFoundException e) {
                // No sources were found, and this is okay!
            } catch (Throwable err) {
                throw new DnaConfigurationException(RepositoryI18n.errorStartingRepositoryService.text(), err);
View Full Code Here

        // Don't shut down the repository
    }

    @Test
    public void shouldAlwaysBeAbleToReadRootNode() {
        Node root = graph.getNodeAt("/");
        assertThat("Connector must always have a root node", root, is(notNullValue()));
        assertThat("Root node must always have a path", root.getLocation().hasPath(), is(true));
        assertThat("Root node must never have a null path", root.getLocation().getPath(), is(notNullValue()));
        assertThat("Root node's path must be the root path", root.getLocation().getPath().isRoot(), is(true));
        List<Property> idProperties = root.getLocation().getIdProperties();
        if (idProperties == null) {
            assertThat(root.getLocation().hasIdProperties(), is(false));
        } else {
            assertThat(root.getLocation().hasIdProperties(), is(true));
        }
    }
View Full Code Here

        }
    }

    @Test
    public void shouldReturnEquivalentLocationForRootUponRepeatedCalls() {
        Node root = graph.getNodeAt("/");
        for (int i = 0; i != 10; ++i) {
            Node anotherRoot = graph.getNodeAt("/");
            assertThat(anotherRoot.getLocation().equals(root.getLocation()), is(true));
            assertThat(anotherRoot.getLocation().getPath(), is(root.getLocation().getPath()));
            assertThat(anotherRoot.getLocation().getIdProperties(), is(root.getLocation().getIdProperties()));
        }
    }
View Full Code Here

        }
    }

    @Test
    public void shouldFindRootByIdentificationProperties() {
        Node root = graph.getNodeAt("/");
        Location rootLocation = root.getLocation();
        if (rootLocation.hasIdProperties()) {
            List<Property> idProperties = rootLocation.getIdProperties();
            assertThat("Root node's ID properties was null when there were supposed to be properties",
                       idProperties,
                       is(notNullValue()));
            Property firstProperty = idProperties.get(0);
            Property[] additionalProperties = new Property[] {};
            if (idProperties.size() > 1) {
                List<Property> morePropertiesList = idProperties.subList(1, idProperties.size());
                assertThat(morePropertiesList.isEmpty(), is(false));
                additionalProperties = morePropertiesList.toArray(new Property[morePropertiesList.size()]);
            }
            // Find the root node using the identification properties ...
            Node anotherRoot = graph.getNodeAt(firstProperty, additionalProperties);
            assertThat(anotherRoot.getLocation().equals(root.getLocation()), is(true));
            assertThat(anotherRoot.getLocation().getPath(), is(root.getLocation().getPath()));
            assertThat(anotherRoot.getLocation().getIdProperties(), is(root.getLocation().getIdProperties()));
        }
    }
View Full Code Here

        }
    }

    @Test
    public void shouldFindRootByUUID() {
        Node root = graph.getNodeAt("/");
        Location rootLocation = root.getLocation();
        UUID uuid = rootLocation.getUuid();
        if (uuid != null) {
            // Find the root node using the identification properties ...
            Node anotherRoot = graph.getNodeAt(uuid);
            assertThat(anotherRoot.getLocation().equals(root.getLocation()), is(true));
            assertThat(anotherRoot.getLocation().getPath(), is(root.getLocation().getPath()));
            assertThat(anotherRoot.getLocation().getIdProperties(), is(root.getLocation().getIdProperties()));
            assertThat(anotherRoot.getLocation().getUuid(), is(root.getLocation().getUuid()));
        }
    }
View Full Code Here

    public void shouldReadSubgraphStartingAtRootAndWithMaximumDepthOfThree() {
        Subgraph subgraph = graph.getSubgraphOfDepth(3).at("/");
        assertThat(subgraph, is(notNullValue()));

        // Verify that the root node is the same as getting it directly ...
        Node root = subgraph.getRoot();
        assertSameNode(root, graph.getNodeAt("/"));

        // Verify the first-level children ...
        List<Location> children = graph.getChildren().of("/");
        assertThat(children, is(notNullValue()));
        for (Location childLocation : children) {
            // Verify the child in the subgraph matches the same node obtained directly from the graph ...
            Node child = subgraph.getNode(childLocation);
            assertSameNode(child, graph.getNodeAt(childLocation));

            // Now get the second-level children ...
            List<Location> grandChildren = graph.getChildren().of(childLocation);
            assertThat(grandChildren, is(notNullValue()));
            for (Location grandchildLocation : grandChildren) {
                // Verify the grandchild in the subgraph matches the same node obtained directly from the graph ...
                Node grandchild = subgraph.getNode(grandchildLocation);
                assertSameNode(grandchild, graph.getNodeAt(grandchildLocation));

                // The subgraph should contain the children locations and properties for the grandchildren.
                // However, the subgraph should not a node for the children of the grandchildren ...
                for (Location greatGrandchild : grandchild.getChildren()) {
                    assertThat(subgraph.getNode(greatGrandchild), is(nullValue()));
                }
            }
        }
    }
View Full Code Here

    @Test
    public void shouldReadIndividualPropertiesOfNodes() {
        // Read each node that is a child of the root...
        for (Location childLocation : graph.getChildren().of("/")) {
            // For each node ...
            Node child = graph.getNodeAt(childLocation);
            for (Property property : child.getProperties()) {
                Name name = property.getName();
                // Re-read the property and verify the value(s) match the value(s) in 'property'
                Property singleProperty = graph.getProperty(name).on(childLocation);
                assertThat(singleProperty, is(notNullValue()));
                assertThat(singleProperty, is(property));
View Full Code Here

    @Test
    public void shouldIncludeTimeLoadedInReadPropertyRequests() {
        // Get each of the properties on the first child ...
        String workspaceName = graph.getCurrentWorkspaceName();
        Location firstChildLocation = graph.getChildren().of("/").get(0);
        Node firstChild = graph.getNodeAt(firstChildLocation);
        // Don't use the graph so that we can obtain and interrogate the request ...
        for (Property property : firstChild.getProperties()) {
            CacheableRequest request = new ReadPropertyRequest(firstChildLocation, workspaceName, property.getName());
            execute(request);
            assertThat(request.getTimeLoaded(), is(notNullValue()));
        }
    }
View Full Code Here

                                   String pathInSource,
                                   String sourceName,
                                   String workspaceName,
                                   String... extraChildren ) {
        FEDERATED_TIMER.start();
        Node fedNode = federated.getNodeAt(pathInFederated);
        FEDERATED_TIMER.stop();
        SOURCE_TIMER.start();
        Node sourceNode = graphFor(sourceName, workspaceName).getNodeAt(pathInSource);
        SOURCE_TIMER.stop();
        // The name should match ...
        Path fedPath = fedNode.getLocation().getPath();
        Path sourcePath = sourceNode.getLocation().getPath();
        if (!fedPath.isRoot() && !sourcePath.isRoot()) {
            assertThat(fedNode.getLocation().getPath().getLastSegment().getName(), is(sourceNode.getLocation()
                                                                                                .getPath()
                                                                                                .getLastSegment()
                                                                                                .getName()));
        }

        // The UUID should match ...
        UUID fedUuid = fedNode.getLocation().getUuid();
        UUID sourceUuid = sourceNode.getLocation().getUuid();
        assertThat(fedUuid, is(sourceUuid));

        // The children should match ...
        List<Path.Segment> fedChildren = new ArrayList<Path.Segment>();
        List<Path.Segment> sourceChildren = new ArrayList<Path.Segment>();
        for (Location child : fedNode.getChildren()) {
            fedChildren.add(child.getPath().getLastSegment());
        }
        for (Location child : sourceNode.getChildren()) {
            sourceChildren.add(child.getPath().getLastSegment());
        }
        // Add any extra children to the 'sourceChildren' ...
        for (String extraChild : extraChildren) {
            sourceChildren.add(context.getValueFactories().getPathFactory().createSegment(extraChild));
        }
        assertThat(fedChildren, is(sourceChildren));
        // The properties should match ...
        Map<Name, Property> fedProps = fedNode.getPropertiesByName();
        Map<Name, Property> sourceProps = sourceNode.getPropertiesByName();
        assertThat(fedProps, is(sourceProps));

        // Now, try to get the children only ...
        FEDERATED_TIMER.start();
        List<Location> children = federated.getChildren().of(pathInFederated);
View Full Code Here

TOP

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

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.