Package org.springframework.data.neo4j.model

Examples of org.springframework.data.neo4j.model.Person


    @Test
    @Transactional
    public void testFetchSingleEntity() {
        final Node node = template.createNode();
        node.setProperty("name","Fetch");
        final Person p = new Person(node.getId());
        template.fetch(p);
        assertEquals("Fetch",p.getName());
    }
View Full Code Here


    @Test
    @Transactional
    public void testFetchEntityCollection() {
        final Node node = template.createNode();
        node.setProperty("name","Fetch");
        final Person p = new Person(node.getId());
        template.fetch(asList(p));
        assertEquals("Fetch",p.getName());
    }
View Full Code Here

        super.setBasePackage(mappingContext,Person.class.getPackage().getName());
    }

    @Test
    public void testCreateUniqueRelationship() {
        final Person p1 = storeInGraph(michael);
        final Person p2 = storeInGraph(andres);
        final BestFriend bestFriend = new BestFriend(p1, p2, "cypher");
        template.save(bestFriend);

        final Relationship bestFriendRel = template.getPersistentState(bestFriend);
        assertEquals(bestFriendRel,((Node)template.getPersistentState(michael)).getSingleRelationship(DynamicRelationshipType.withName("BEST_FRIEND"), Direction.OUTGOING));
        assertEquals(bestFriendRel.getEndNode(), template.getPersistentState(andres));
        assertEquals("cypher",bestFriendRel.getProperty("secretName"));
        assertEquals(bestFriendRel, getBestFriend());

        final Person p3 = storeInGraph(emil);
        final BestFriend bestFriend2 = new BestFriend(p1, p3, "cypher");
        template.save(bestFriend2);

        final Relationship bestFriend2Rel = template.getPersistentState(bestFriend2);
        assertEquals(bestFriend2Rel, bestFriendRel);
View Full Code Here

        assertEquals(bestFriendRel, getBestFriend());
    }

    @Test
    public void testCreateUniqueRelationshipRelatedToVia() {
        final Person p1 = storeInGraph(michael);
        final Person p2 = storeInGraph(andres);
        p1.setBestFriend(p2,"cypher");
        template.save(p1);
        final BestFriend bestFriend = p1.getBestFriend();

        final Relationship bestFriendRel = template.getPersistentState(bestFriend);
        assertEquals(bestFriendRel,((Node)template.getPersistentState(michael)).getSingleRelationship(DynamicRelationshipType.withName("BEST_FRIEND"), Direction.OUTGOING));
        assertEquals(bestFriendRel.getEndNode(), template.getPersistentState(andres));
        assertEquals("cypher",bestFriendRel.getProperty("secretName"));
        assertEquals(bestFriendRel, getBestFriend());

        final Person p3 = storeInGraph(emil);
        p1.setBestFriend(p3,"cypher");
        final BestFriend bestFriend2 = p1.getBestFriend();
        template.save(bestFriend2);

        final Relationship bestFriend2Rel = template.getPersistentState(bestFriend2);
View Full Code Here

    @Test
    public void testInstantiateEntity() throws Exception {
        Neo4jTemplate template = new Neo4jTemplate(graphDatabase,transactionManager);
        Transaction tx = template.getGraphDatabase().beginTx();
        try {
            Person michael = template.save(new Person("Michael", 37));
            assertNotNull(michael.getId());
        } finally {
            tx.success();tx.close();
        }
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testCreateEntityWithProperties() throws Exception {
        Person person = neo4jTemplate.createNodeAs(Person.class, map("name", "name"));
        assertNotNull("created node", person);
        assertEquals("property created", "name", person.getName());
    }
View Full Code Here

TOP

Related Classes of org.springframework.data.neo4j.model.Person

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.