Package org.neo4j.rest.graphdb.entity

Examples of org.neo4j.rest.graphdb.entity.RestNode


    }

    @Override
    public GraphInfo create(GraphInfo info) {
        if (isEmpty(info)) info = info.withId(Util.randomId());
        final RestNode node = restAPI.getOrCreateNode(index, "id", info.getId(), info.toMap());
        return new GraphInfo(node);
    }
View Full Code Here


  }

    @Test
    public void testCreateNodeUniquely() {
        final RestIndex<Node> index = restAPI.createIndex(Node.class, "unique-node", LuceneIndexImplementation.EXACT_CONFIG);
        final RestNode node1 = restAPI.getOrCreateNode(index, "uid", "42", map("name", "Michael"), NO_LABELS);
        final RestNode node2 = restAPI.getOrCreateNode(index, "uid", "42", map("name", "Michael2"), NO_LABELS);
        assertEquals(node1,node2);
        assertEquals("Michael",node1.getProperty("name"));
        assertEquals("Michael",node2.getProperty("name"));
        final RestNode node3 = restAPI.getOrCreateNode(index, "uid", "41", map("name", "Emil"), NO_LABELS);
        assertEquals(false, node1.equals(node3));
    }
View Full Code Here

        assertEquals(false, node1.equals(node3));
    }
    @Test
    public void testCreateRelationshipUniquely() {
        final RestIndex<Relationship> index = restAPI.createIndex(Relationship.class, "unique-rel", LuceneIndexImplementation.EXACT_CONFIG);
        final RestNode michael = restAPI.createNode(map("name", "Michael"));
        final RestNode david = restAPI.createNode(map("name","David"));
        final RestNode peter = restAPI.createNode(map("name","Peter"));


        final RestRelationship rel1 = restAPI.getOrCreateRelationship(index, "uid", "42", michael, david, "KNOWS", map("at", "Neo4j"));
        final RestRelationship rel2 = restAPI.getOrCreateRelationship(index, "uid", "42", michael, david, "KNOWS", map("at", "Neo4j"));
        assertEquals(rel1,rel2);
View Full Code Here

        assertEquals(false, rel3.equals(rel1));
    }

    @Test
    public void testGetNodeLabel() {
        RestNode node = restAPI.createNode(map());
        node.addLabel(LABEL_FOO);
        int count=0;
        for (Label label1 : node.getLabels()) {
            assertEquals(LABEL_FOO.name(),label1.name());
            count++;
        }
        assertEquals("one label",1,count);
    }
View Full Code Here

        }
        assertEquals("one label",1,count);
    }
    @Test
    public void testRemoveNodeLabel() {
        RestNode node = restAPI.createNode(map());
        node.addLabel(LABEL_FOO);
        node.removeLabel(LABEL_FOO);
        assertFalse(node.getLabels().iterator().hasNext());
    }
View Full Code Here

        assertFalse(node.getLabels().iterator().hasNext());
    }

    @Test
    public void testGetNodeByLabel() throws Exception {
        RestNode node = restAPI.createNode(map());
        node.addLabel(LABEL_FOO);
        int count=0;
        for (RestNode restNode : restAPI.getNodesByLabel(LABEL_FOO.name())) {
            assertEquals(node,restNode);
            count++;
        }
View Full Code Here

        assertEquals("one node with label",1,count);
    }

    @Test
    public void testSetNodeLabel() throws Exception {
        RestNode n1 = restAPI.createNode(map("name", "node1"));
        n1.addLabel(LABEL_FOO);
        n1.addLabel(LABEL_BAR);
        Collection<String> labels = IteratorUtil.asCollection(new IterableWrapper<String, Label>(n1.getLabels()) {
            protected String underlyingObjectToObject(Label label) {
                return label.name();
            }
        });
        assertThat(labels, hasItems(LABEL_FOO.name(), LABEL_BAR.name()));
View Full Code Here

        assertThat(labels, hasItems(LABEL_FOO.name(), LABEL_BAR.name()));
    }

    @Test
    public void testRemoveNodeLabel2() throws Exception {
        RestNode n1 = restAPI.createNode(map("name", "node1"));
        n1.addLabel(LABEL_FOO);
        n1.addLabel(LABEL_BAR);

        n1.removeLabel(LABEL_BAR);
        Collection<String> labels = IteratorUtil.asCollection(new IterableWrapper<String, Label>(n1.getLabels()) {
            protected String underlyingObjectToObject(Label label) {
                return label.name();
            }
        });
        assertThat(labels, hasItems(LABEL_FOO.name()));
View Full Code Here

        assertThat(labels, hasItems(LABEL_FOO.name()));
    }

    @Test
    public void testGetNodeByLabelAndProperty() throws Exception {
        RestNode node = restAPI.createNode(map("name","foo bar"));
        node.addLabel(LABEL_FOO);
        int count=0;
        for (RestNode restNode : restAPI.getNodesByLabelAndProperty(LABEL_FOO.name(),"name","foo bar")) {
            assertEquals(node,restNode);
            count++;
        }
View Full Code Here

        assertEquals("one node with label",1,count);
    }

    @Test
    public void testGetAllLabelNames() throws Exception {
        RestNode node = restAPI.createNode(map("name","foo bar"));
        node.addLabel(LABEL_FOO);
        node.addLabel(LABEL_BAR);
        assertThat(restAPI.getAllLabelNames(), hasItems(LABEL_FOO.name(),LABEL_BAR.name()));
    }
View Full Code Here

TOP

Related Classes of org.neo4j.rest.graphdb.entity.RestNode

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.