Package org.springframework.data.neo4j.aspects

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


public class RelationshipEntityTests extends EntityTestBase {

    @Test
    @Transactional
    public void testRelationshipCreate() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Friendship f = p.knows(p2);
        Relationship rel = getNodeState(p).getSingleRelationship(DynamicRelationshipType.withName("knows"), Direction.OUTGOING);
        assertEquals(getRelationshipState(f), rel);
        assertEquals(getNodeState(p2), rel.getEndNode());
    }
View Full Code Here


    }

    @Test
    @Transactional
    public void shouldNotCreateSameRelationshipTwice() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Friendship f = p.knows(p2);
        Friendship f2 = p.knows(p2);
        assertEquals(f, f2);
        assertEquals(1, IteratorUtil.count(p.getFriendships()));
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void shouldSupportSetOfRelationshipEntities() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        final Friendship friendship = p.knows(p2);
        final Set<Friendship> result = p.getFriendshipsSet();
        assertEquals(1, IteratorUtil.count(result));
        assertEquals(friendship,IteratorUtil.first(result));
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void shouldSupportManagedSetAddOfRelationshipEntities() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        final Set<Friendship> friends = p.getFriendshipsSet();
        assertEquals(0, IteratorUtil.count(friends));
        final Friendship friendship = new Friendship(p, p2, 10);
        friends.add(friendship);
        assertEquals(1, IteratorUtil.count(friends));
View Full Code Here

    }

    @Test
    @Transactional
    public void shouldSupportManagedSetRemoveOfRelationshipEntities() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        final Friendship friendship = p.knows(p2);
        final Set<Friendship> friends = p.getFriendshipsSet();
        assertEquals(1, friends.size());
        assertEquals(friendship,IteratorUtil.first(friends));
        friends.remove(friendship);
View Full Code Here

    }

    @Test
    @Transactional
    public void testRelationshipSetProperty() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Friendship f = p.knows(p2);
        f.setYears(1);
        assertEquals(1, getRelationshipState(f).getProperty("Friendship.years"));
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testRelationshipGetProperty() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Friendship f = p.knows(p2);
        getRelationshipState(f).setProperty("Friendship.years", 1);
        assertEquals(1, f.getYears());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testRelationshipGetStartNodeAndEndNode() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Friendship f = p.knows(p2);
        assertEquals(p, f.getPerson1());
        assertEquals(p2, f.getPerson2());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testGetRelationshipToReturnsRelationship() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Friendship f = p.knows(p2);
        assertEquals(f, neo4jTemplate.getRelationshipBetween(p, p2, Friendship.class, "knows"));
    }
View Full Code Here

   
    //@Ignore("The NodeBacking.getRelationshipTo() method is broken at the moment")
    @Test
    @Transactional
    public void testGetRelationshipTo() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Friendship f = p.knows(p2);
        assertNotNull(p.getRelationshipTo(p2, "knows"));
    }
View Full Code Here

TOP

Related Classes of org.springframework.data.neo4j.aspects.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.