Package org.springframework.data.neo4j.aspects

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


        assertEquals("created self-referencing relationship",p,p.getBoss());
    }
    @Test
    @Transactional
    public void testSetOneToManyRelationship() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Group group = persist(new Group());
        Set<Person> persons = new HashSet<Person>(Arrays.asList(michael, david));
        group.setPersons(persons);
        Relationship michaelRel = getNodeState(michael).getSingleRelationship(DynamicRelationshipType.withName("persons"), Direction.INCOMING);
        Relationship davidRel = getNodeState(david).getSingleRelationship(DynamicRelationshipType.withName("persons"), Direction.INCOMING);
View Full Code Here


    }

    @Test
    @Transactional
    public void testGetOneToManyRelationship() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Group group = persist(new Group());
        Set<Person> persons = new HashSet<Person>(Arrays.asList(michael, david));
        group.setPersons(persons);
        Collection<Person> personsFromGet = group.getPersons();
        assertEquals(persons, personsFromGet);
View Full Code Here

    }

    @Test
    @Transactional
    public void testAddToOneToManyRelationship() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Group group = persist(new Group());
        group.setPersons(new HashSet<Person>());
        group.getPersons().add(michael);
        group.getPersons().add(david);
        Collection<Person> personsFromGet = group.getPersons();
View Full Code Here

        assertTrue(Set.class.isAssignableFrom(personsFromGet.getClass()));
    }

    @Test
    public void testAddToOneToManyRelationshipOutsideOfTransaction() {
        Person michael = persistedPerson("Michael", 35);
        Group group = persist(new Group());
        group.getPersons().add(michael);
        group = persist(group);
        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            Collection<Person> personsFromGet = group.getPersons();
View Full Code Here

    }

    @Test
    @Transactional
    public void testRemoveFromOneToManyRelationship() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Group group = persist(new Group());
        group.setPersons(new HashSet<Person>(Arrays.asList(michael, david)));
        group.getPersons().remove(david);
        assertEquals(Collections.singleton(michael), group.getPersons());
    }
View Full Code Here

public class EntityPathTests extends EntityTestBase {

    @Test
    @Transactional
    public void shouldConvertNodePathToEntityPath() throws Exception {
        Person michael = persist(new Person("Michael", 36));
        Node node = getNodeState(michael);
        NodePath path = new NodePath(node);
        EntityPath<Person, Person> entityPath = new ConvertingEntityPath<Person, Person>(path, neo4jTemplate);

        Assert.assertEquals("start entity",michael, entityPath.startEntity());
View Full Code Here

        assertEquals(Collections.singleton(michael), group.getPersons());
    }
    @Test
    @Transactional
    public void testRemoveAllFromOneToManyRelationship() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Group group = persist(new Group());
        group.setPersons(new HashSet<Person>(Arrays.asList(michael, david)));
        group.getPersons().removeAll(Collections.singleton(david));
        assertEquals(Collections.singleton(michael), group.getPersons());
    }
View Full Code Here

        assertEquals(Collections.singleton(michael), group.getPersons());
    }
    @Test
    @Transactional
    public void testRetainAllFromOneToManyRelationship() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Group group = persist(new Group());
        group.setPersons(new HashSet<Person>(Arrays.asList(michael, david)));
        group.getPersons().retainAll(Collections.singleton(david));
        assertEquals(Collections.singleton(david), group.getPersons());
    }
View Full Code Here

        assertEquals(Collections.singleton(david), group.getPersons());
    }
    @Test
    @Transactional
    public void testClearFromOneToManyRelationship() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Group group = persist(new Group());
        group.setPersons(new HashSet<Person>(Arrays.asList(michael, david)));
        group.getPersons().clear();
        assertEquals(Collections.<Person>emptySet(), group.getPersons());
    }
View Full Code Here


    @Test
    @Transactional
    public void testRelationshipGetEntities() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Person p3 = persistedPerson("Emil", 32);
        Friendship f2 = p.knows(p2);
        Friendship f3 = p.knows(p3);
        assertEquals(new HashSet<Friendship>(Arrays.asList(f2, f3)), IteratorUtil.addToCollection(p.getFriendships().iterator(), new HashSet<Friendship>()));
    }
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.