Package org.springframework.data.neo4j.aspects

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


        Group group = new Group();
      group.setPersons(new HashSet<Person>());
      Collection<Person> people = group.getPersons();
      assertNotNull(people);

      Person p = new Person( "David", 27 );
      people.add(p);

        assertEquals( Collections.singleton(p), group.getPersons() );

View Full Code Here


    }

    @Test
    public void shouldNotCreateGraphRelationshipOutsideTransaction()
    {
        Person p = persistedPerson( "Michael", 35 );
        Person spouse = persistedPerson( "Tina", 36 );

        p.setSpouse( spouse );

        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            assertEquals( spouse, p.getSpouse() );
            assertThat( nodeFor( p ), hasNoRelationship("spouse", getNodeState(spouse)) );
            tx.success();
        }


        Person spouse2 = persistedPerson( "Rana", 5 );
        p.setSpouse( spouse2 );
        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            assertEquals( spouse2, p.getSpouse() );
            tx.success();
        }
View Full Code Here

    }

    @Test
    public void testCreateRelationshipOutsideTransactionAndPersist()
    {
        Person p = persistedPerson( "Michael", 35 );
        Person spouse = persistedPerson( "Tina", 36 );

        p.setSpouse( spouse );
        persist(p);

        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            assertEquals( spouse, p.getSpouse() );
            assertThat( nodeFor( p ), hasRelationship( "spouse" ) );
            tx.success();
        }

        Person spouse2 = persistedPerson( "Rana", 5 );
        p.setSpouse( spouse2 );

        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            assertEquals( spouse2, p.getSpouse() );
            tx.success();
View Full Code Here

    @Test
    @Transactional
    public void testGetPropertyInsideTransaction()
    {
        Person p = persistedPerson( "Michael", 35 );
        assertEquals( "Wrong age.", 35, p.getAge() );
    }
View Full Code Here

import static org.junit.Assert.assertTrue;

public class EntityWithoutAspectSetupTests {
    @Test
    public void testEquals() throws Exception {
        final Person p1 = new Person();
        final Person p2 = new Person();
        assertEquals(p1, p1);
        assertEquals(false, p1.equals(p2));
    }
View Full Code Here

        assertEquals(p1, p1);
        assertEquals(false, p1.equals(p2));
    }
    @Test
    public void testHashCode() throws Exception {
        final Person p1 = new Person();
        final Person p2 = new Person();
        assertTrue(p1.hashCode() > 0);
        assertEquals(false, p1.hashCode() == p2.hashCode());
    }
View Full Code Here

public class NodeEntityInstantiationTests extends EntityTestBase {

    @Test
    @Transactional
    public void testCreatePersonWithCreator() {
        Person p = persistedPerson("Rod", 39);
        long nodeId = getNodeId(p);

        Node node = neo4jTemplate.getNode(nodeId);
        final MappingPolicy mappingPolicy = neo4jTemplate.getMappingPolicy(Person.class);
        Person person1 = (Person) neo4jTemplate.createEntityFromStoredType(node, mappingPolicy);
        assertEquals("Rod", person1.getName());
        Person person2 = neo4jTemplate.createEntityFromState(node,Person.class, mappingPolicy);
        assertEquals("Rod", person2.getName());

        GraphRepository<Person> finder = neo4jTemplate.repositoryFor(Person.class);
        Person found = finder.findOne(nodeId);
        assertEquals("Rod", found.getName());
    }
View Full Code Here

        new ProvidedClassPathXmlApplicationContext(db, "Plugin-context.xml");
    }

    @Test
    public void testGetFriends() throws IOException {
        Person person = persistedPerson("Michael", 35);
        final RequestResult requestResult = RequestResult.extractFrom(createRequest("ext/TestServerPlugin/graphdb/person").post(ClientResponse.class, "{\"name\":\"" + person.getName() + "\"}"));
        assertEquals(200, requestResult.getStatus());
        final String result = requestResult.getText();
        final Map data = (Map) new ObjectMapper().readValue(result, Object.class);
        assertEquals(person.getName(),((Map)data.get("data")).get("name"));

    }
View Full Code Here

    }


    @Test
    public void testRangeQueryPersonByIndexOnAnnotatedField() {
        Person person = persistedPerson(NAME_VALUE, 35);
        final Person found = this.personRepository.findAllByRange("age", 10, 40).iterator().next();
        assertEquals("person found inside range", person, found);
    }
View Full Code Here

    @Test
    @Transactional
    public void testUpdateSingleRelatedToViaField() {
        Group group;
        final Long firstMentorshipId;
        final Person mentor2;
        try (Transaction tx = neo4jTemplate.getGraphDatabaseService().beginTx()) {
            group = persist(new Group());
            group.setMentorship(new Mentorship(persist(new Person()), group));
            persist(group);
            firstMentorshipId = group.getMentorship().getId();
            mentor2 = new Person();
            group.setMentorship(new Mentorship(persist(mentor2), group));
            persist(group);
            tx.success();
        }
        final Node node = neo4jTemplate.getPersistentState(group);
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.