Examples of BestFriend


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

    @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);
        assertEquals(bestFriend2Rel.getEndNode(), template.getPersistentState(andres));
View Full Code Here

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

    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);
        assertEquals(bestFriend2Rel, bestFriendRel);
        assertEquals(bestFriend2Rel.getEndNode(), template.getPersistentState(andres));
        assertEquals(bestFriendRel, getBestFriend());

        p1.setBestFriend(null,null);
        template.save(p1);
        assertEquals(null, ((Node) template.getPersistentState(michael)).getSingleRelationship(DynamicRelationshipType.withName("BEST_FRIEND"), Direction.OUTGOING));
        p1.setBestFriend(p3, "cypher");
        template.save(p1);
        final BestFriend bestFriend3 = p1.getBestFriend();

        final Relationship bestFriend3Rel = template.getPersistentState(bestFriend3);
        assertNotSame(bestFriend3Rel, bestFriendRel);
        assertEquals(bestFriend3Rel.getEndNode(), template.getPersistentState(emil));
        assertEquals(bestFriend3Rel, getBestFriend());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.