Package org.springframework.data.neo4j.aspects

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


    public void testRemoveRelationshipEntity() {
        cleanDb();
        Friendship f;
        try (Transaction tx = graphDatabaseService.beginTx())
        {
            Person p = persistedPerson("Michael", 35);
            Person p2 = persistedPerson("David", 25);
            f = p.knows(p2);
            tx.success();
        }
        try (Transaction tx = graphDatabaseService.beginTx())
        {
View Full Code Here


    }

    @Test
    public void testRemoveRelationshipEntityIfNodeEntityIsRemoved() {
        cleanDb();
        Person p;
        try (Transaction tx = graphDatabaseService.beginTx())
        {
            p = persistedPerson("Michael", 35);
            Person p2 = persistedPerson("David", 25);
            p.knows(p2);
            tx.success();
        }
        try (Transaction tx = graphDatabaseService.beginTx())
        {
View Full Code Here

    }

    @Test
    public void testQuerySingleOfTypePerson() throws Exception {
        final String queryString = "start person=node:`name-index`(name={name}) match (person) <-[:boss]- (boss) return boss";
        final Person result = queryEngine.query(queryString, michaelsName()).to(Person.class, new EntityResultConverter<Map<String,Object>,Person>(conversionService,template)).single();

        assertEquals(testTeam.emil,result);
    }
View Full Code Here

    @Test
    public void testQueryWithSpaceInParameter() throws Exception {
        michael.setName("Michael Hunger");
        personRepository.save(michael);
        final String queryString = "start person=node:`name-index`({name}) return person";
        final Person result = (Person)queryEngine.query(queryString, map("name","name:\"Michael Hunger\"")).to(Person.class,entityResultConverter).singleOrNull();

        assertEquals(michael,result);
    }
View Full Code Here

public class NodeEntityTests extends EntityTestBase {

    @Test
    @Transactional
    public void testUserConstructor() {
        Person p = persistedPerson("Rod", 39);
        assertEquals(p.getName(), getNodeState(p).getProperty("name"));
        assertEquals(p.getAge(), getNodeState(p).getProperty("age"));
        Person found = neo4jTemplate.createEntityFromState(neo4jTemplate.getNode(getNodeId(p)), Person.class, neo4jTemplate.getMappingPolicy(p));
        assertEquals("Rod", getNodeState(found).getProperty("name"));
        assertEquals(39, getNodeState(found).getProperty("age"));
    }
View Full Code Here

    public void testSetSimpleProperties() {
        String name = "Michael";
        int age = 35;
        short height = 182;

        Person p = persistedPerson("Foo", 2);
        p.setName( name );
        p.setAge( age );
        p.setHeight( height );
        assertEquals( name, getNodeState(p).getProperty("name") );
        assertEquals( age, getNodeState(p).getProperty("age"));
        assertEquals((Short)height, p.getHeight());
    }
View Full Code Here

        assertEquals((Short)height, p.getHeight());
    }

    @Test
    public void testEntityIsStillDetachedAfterValidationException() {
        Person p = new Person("Foo", 2);
        try {
            p.setName("A");
            p.persist();
            fail("should fail to validate");
        } catch(ValidationException ve) {
            System.out.println(ve.getClass());
        }
        assertEquals("A",p.getName());
    }
View Full Code Here

    @Test
    @Transactional
    public void testLabels() {
        String[] labelNames = {"Person", "Developer", "Father","_Person"};
        Person p = new Person("Michael",39).persist();
//        assertThat(p.getLabels(), hasItems(labelNames[0],labelNames[3]));
        p = neo4jTemplate.findOne(p.getId(), Person.class);
        assertThat(p.getLabels(), hasItems(labelNames[0],labelNames[3]));
        p.addLabel(labelNames[1]);
        p.addLabel(labelNames[2]);
        neo4jTemplate.save(p);
        System.out.println("p.getLabels() = " + p.getLabels());
        assertEquals(4, IteratorUtil.count(getNodeState(p).getLabels()));
        for (Label l : getNodeState(p).getLabels()) {
            assertEquals("Wrong label "+l.name(),true, asList(labelNames).contains(l.name()));
        }
        assertThat(p.getLabels(), hasItems(labelNames));
        Person loaded = neo4jTemplate.findOne(p.getId(), Person.class);
        assertThat(loaded.getLabels(), hasItems(labelNames));
        loaded.removeLabel(labelNames[2]);
        assertThat(p.getLabels(), hasItems(labelNames[0], labelNames[1]));
        assertThat(loaded.getLabels(), hasItems(labelNames[0], labelNames[1]));
        loaded = neo4jTemplate.findOne(p.getId(), Person.class);
        assertThat(loaded.getLabels(), hasItems(labelNames[0],labelNames[1]));
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testSetShortProperty() {
        Person p = persistedPerson("Foo", 2);
        p.setHeight((short)182);
        assertEquals((Short)(short)182, p.getHeight());
        assertEquals((short)182, getNodeState(p).getProperty("height"));
    }
View Full Code Here

        assertEquals("developers", getNodeState(group).getProperty("name"));
    }
    // own transaction handling because of http://wiki.neo4j.org/content/Delete_Semantics
    @Test(expected = DataRetrievalFailureException.class)
    public void testDeleteEntityFromGDC() {
        Person p;
        AtomicLong id = new AtomicLong();
        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            p = persistedPerson("Michael", 35);
            Person spouse = persistedPerson("Tina", 36);
            p.setSpouse(spouse);
            id.set(spouse.getId());
            neo4jTemplate.delete(spouse);
            tx.success();
        }
        try (Transaction tx = graphDatabaseService.beginTx()) {
            assertNull("spouse removed " + p.getSpouse(), p.getSpouse());
            Person spouseFromIndex = personRepository.findByPropertyValue(Person.NAME_INDEX, "name", "Tina");
            assertNull("spouse not found in index", spouseFromIndex);
            assertNull("node deleted " + id, neo4jTemplate.getNode(id.get()));
            tx.success();
        }
    }
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.