Package org.springframework.data.neo4j.aspects

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


    }

    @Test(expected = InvalidDataAccessApiUsageException.class)
    @Transactional
    public void testRelationshipSetEntitiesShouldThrowException() {
        Person p = persistedPerson("Michael", 35);
        p.setFriendships(new HashSet<Friendship>());
    }
View Full Code Here


    }

    @Test
    @Transactional
    public void testOneToManyReadOnly() {
        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);
        assertEquals(persons, IteratorUtil.addToCollection(group.getReadOnlyPersons().iterator(), new HashSet<Person>()));
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void multipleRelationshipsOfSameTypeBetweenTwoEntities() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Friendship friendship1 = neo4jTemplate.createRelationshipBetween(michael, david, Friendship.class, "knows", true);
        friendship1.setYears(1);
        Friendship friendship2 = neo4jTemplate.createRelationshipBetween(michael, david, Friendship.class, "knows", true);
        friendship2.setYears(2);
        assertTrue("two different relationships", friendship1 != friendship2);
View Full Code Here

    @Test
    @Transactional
    public void testSingleRelatedToViaField() {
        Group group = persist(new Group());
        Person mentor = persist(new Person());
        group.setMentorship(new Mentorship(mentor,group));
        persist(group);
        final Node node = neo4jTemplate.getPersistentState(group);
        assertEquals(1,IteratorUtil.count(node.getRelationships(Direction.INCOMING,DynamicRelationshipType.withName("mentors"))));
        final Group loaded = neo4jTemplate.load(node, Group.class);
View Full Code Here

   
    @Test
    @Transactional
    public void testRemoveSingleRelatedToViaField() {
        Group group = persist(new Group());
        Person mentor = persist(new Person());
        group.setMentorship(new Mentorship(mentor,group));
        persist(group);
        group.setMentorship(null);
        persist(group);
        final Node node = neo4jTemplate.getPersistentState(group);
View Full Code Here

    }
    @Test
    @Transactional
    public void testUpdateSingleRelatedToViaField() {
        Group group = persist(new Group());
        group.setMentorship(new Mentorship(persist(new Person()),group));
        persist(group);
        final Long firstMentorshipId = group.getMentorship().getId();
        final Person mentor2 = new Person();
        group.setMentorship(new Mentorship(persist(mentor2),group));
        persist(group);
        final Node node = neo4jTemplate.getPersistentState(group);
        assertEquals(1,IteratorUtil.count(node.getRelationships(Direction.INCOMING,DynamicRelationshipType.withName("mentors"))));
        final Group loaded = neo4jTemplate.load(node, Group.class);
View Full Code Here

    }

    @Test
    @Transactional
    public void testCanIndexIntFieldsOnRelationshipEntities() {
        Person p = persistedPerson(NAME_VALUE, 35);
        Person p2 = persistedPerson(NAME_VALUE2, 25);
        Friendship friendship = p.knows(p2);
        friendship.setYears(1);
        GraphRepository<Friendship> friendshipFinder = neo4jTemplate.repositoryFor(Friendship.class);
        assertEquals(friendship, friendshipFinder.findByPropertyValue("Friendship.years", 1));
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testFindPersonWithQueryAnnotation() {
        Person boss = personRepository.findBoss(testTeam.michael);
        assertThat(boss, is(testTeam.emil));
    }
View Full Code Here

public class TraversalTests extends EntityTestBase {

    @Test
    @Transactional
    public void testTraverseFromGroupToPeople() {
        Person p = persistedPerson("Michael", 35);
        Group group = persist(new Group());
        group.setName("dev");
        group.addPerson(p);
        final TraversalDescription traversalDescription = Traversal.description().relationships(DynamicRelationshipType.withName("persons")).evaluator(Evaluators.excludeStartPosition());
        Iterable<Person> people = neo4jTemplate.<Person>traverse(group, Person.class, traversalDescription);
View Full Code Here

    }
    @SuppressWarnings("unchecked")
    @Test
    @Transactional
    public void testTraverseFromGroupToPeoplePaths() {
        Person p = persistedPerson("Michael", 35);
        Group group = persist(new Group());
        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 = (Iterable<EntityPath<Group, Person>>) neo4jTemplate.<EntityPath<Group,Person>>traverse(group, EntityPath.class, traversalDescription);
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.