Package org.springframework.data.neo4j.aspects

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


    }

    @Test
    @Transactional
    public void testEntityIdField() {
        Person p = persistedPerson("Michael", 35);
        assertEquals("Wrong ID.", getNodeState(p).getId(), p.getId());
    }
View Full Code Here


    }

    @Test
    @Transactional
    public void testRelationshipIdField() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Friendship f = p.knows(p2);
    assertEquals("Wrong ID.", (Long) getRelationshipState(f).getId(), getRelationshipId(f));
    }
View Full Code Here

        Friendship f = p.knows(p2);
    assertEquals("Wrong ID.", (Long) getRelationshipState(f).getId(), getRelationshipId(f));
    }

    public void testGetDefaultValues() {
        final Person p = persistedPerson("Michael", 35);
        assertEquals(Personality.EXTROVERT,p.getDefaultedPersonality());
        assertEquals("defaultValue",p.getDefaultedName());
        assertEquals(0,(short)p.getHeight());
        assertEquals(null, p.getBirthdate());

    }
View Full Code Here

public class EntityMapperTests extends EntityTestBase {

    @Test
    @Transactional
    public void entityMapperShouldForwardEntityPath() throws Exception {
        Person michael = persist(new Person("Michael", 36));
        EntityMapper<Person, Person, String> mapper = new EntityMapper<Person, Person, String>(neo4jTemplate) {
            @Override
            public String mapPath(EntityPath<Person, Person> entityPath) {
                return entityPath.<Person>startEntity().getName();
            }
        };
        String name = mapper.mapPath(new NodePath(getNodeState(michael)));
        Assert.assertEquals(michael.getName(), name);
    }
View Full Code Here

public class NodeEntityRelationshipTests extends EntityTestBase {

    @Test
    @Transactional
    public void testCreateRelationshipWithoutAnnotationOnSet() {
        Person p = persistedPerson("Michael", 35);
        Person spouse = persistedPerson("Tina", 36);
        p.setSpouse(spouse);
        Node spouseNode= getNodeState(p).getSingleRelationship(DynamicRelationshipType.withName("spouse"), Direction.OUTGOING).getEndNode();
        assertEquals(getNodeState(spouse), spouseNode);
        assertEquals(spouse, p.getSpouse());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testCreateRelationshipWithAnnotationOnSet() {
        Person p = persistedPerson("Michael", 35);
        Person mother = persistedPerson("Gabi", 60);
        p.setMother(mother);
        Node motherNode = getNodeState(p).getSingleRelationship(DynamicRelationshipType.withName("mother"), Direction.OUTGOING).getEndNode();
        assertEquals(getNodeState(mother), motherNode);
        assertEquals(mother, p.getMother());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testDeleteRelationship() {
        Person p = persistedPerson("Michael", 35);
        Person spouse = persistedPerson("Tina", 36);
        p.setSpouse(spouse);
        p.setSpouse(null);
        Assert.assertNull(getNodeState(p).getSingleRelationship(DynamicRelationshipType.withName("spouse"), Direction.OUTGOING));
        Assert.assertNull(p.getSpouse());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testDeletePreviousRelationshipOnNewRelationship() {
        Person p = persistedPerson("Michael", 35);
        Person spouse = persistedPerson("Tina", 36);
        Person friend = persistedPerson("Helga", 34);
        p.setSpouse(spouse);
        p.setSpouse(friend);
        assertEquals(getNodeState(friend), getNodeState(p).getSingleRelationship(DynamicRelationshipType.withName("spouse"), Direction.OUTGOING).getEndNode());
        assertEquals(friend, p.getSpouse());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testCreateIncomingRelationshipWithAnnotationOnSet() {
        Person p = persistedPerson("David", 25);
        Person boss = persistedPerson("Emil", 32);
        p.setBoss(boss);
        assertEquals(getNodeState(boss), getNodeState(p).getSingleRelationship(DynamicRelationshipType.withName("boss"), Direction.INCOMING).getStartNode());
        assertEquals(boss, p.getBoss());
    }
View Full Code Here

        assertEquals(boss, p.getBoss());
    }

    @Transactional
    public void testAllowsCircularRelationship() {
        Person p = persistedPerson("Michael", 35);
        p.setBoss(p);

        assertEquals("created self-referencing relationship",p,p.getBoss());
    }
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.