Package org.springframework.data.neo4j

Examples of org.springframework.data.neo4j.Group


    }

    @Test
    public void testAddToOneToManyRelationshipOutsideOfTransaction() {
        Person michael = persistedPerson("Michael", 35);
        Group group = new Group().persist();
        group.getPersons().add(michael);
        group = group.persist();
        Collection<Person> personsFromGet = group.getPersons();
        assertEquals(new HashSet<Person>(Arrays.asList(michael)), personsFromGet);
    }
View Full Code Here


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

    @Test
    @Transactional
    public void testRemoveAllFromOneToManyRelationship() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Group group = new Group().persist();
        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

    @Test
    @Transactional
    public void testRetainAllFromOneToManyRelationship() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Group group = new Group().persist();
        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

    @Test
    @Transactional
    public void testClearFromOneToManyRelationship() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Group group = new Group().persist();
        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 testOneToManyReadOnly() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Group group = new Group().persist();
        Set<Person> persons = new HashSet<Person>(Arrays.asList(michael, david));
        group.setPersons(persons);
        assertEquals(persons, IteratorUtil.addToCollection(group.getReadOnlyPersons().iterator(), new HashSet<Person>()));
    }
View Full Code Here

    }

    @Test(expected = InvalidDataAccessApiUsageException.class)
    @Transactional
    public void testOneToManyReadOnlyShouldThrowExceptionOnSet() {
        Group group = new Group().persist();
        group.setReadOnlyPersons(new HashSet<Person>());
    }
View Full Code Here

    @Test
    @Transactional
    public void testTraverseFromGroupToPeople() {
        Person p = persistedPerson("Michael", 35);
        Group group = new Group().persist();
        group.setName("dev");
        group.addPerson(p);
        final TraversalDescription traversalDescription = Traversal.description().relationships(DynamicRelationshipType.withName("persons")).evaluator(Evaluators.excludeStartPosition());
        Iterable<Person> people = (Iterable<Person>) group.findAllByTraversal(Person.class, traversalDescription);
        final HashSet<Person> found = new HashSet<Person>();
        for (Person person : people) {
            found.add(person);
        }
        assertEquals(Collections.singleton(p),found);
View Full Code Here

    }
    @Test
    @Transactional
    public void testTraverseFromGroupToPeoplePaths() {
        Person p = persistedPerson("Michael", 35);
        Group group = new Group().persist();
        group.setName("dev");
        group.addPerson(p);
        final TraversalDescription traversalDescription = Traversal.description().relationships(DynamicRelationshipType.withName("persons"), Direction.OUTGOING).evaluator(Evaluators.excludeStartPosition());
        Iterable<EntityPath<Group,Person>> paths = group.<Group,Person>findAllPathsByTraversal(traversalDescription);
        for (EntityPath<Group, Person> path : paths) {
            assertEquals(group, path.startEntity());
            assertEquals(p, path.endEntity());
            assertEquals(1,path.length());
        }
View Full Code Here

    @Test
    @Transactional
    @Rollback(false)
    public void testTraverseFieldFromGroupToPeople() {
        Person p = persistedPerson("Michael", 35);
        Group group = new Group().persist();
        group.setName("dev");
        group.addPerson(p);
        Iterable<Person> people = group.getPeople();
        final HashSet<Person> found = new HashSet<Person>();
        for (Person person : people) {
            found.add(person);
        }
        assertEquals(Collections.singleton(p),found);
View Full Code Here

TOP

Related Classes of org.springframework.data.neo4j.Group

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.