Package org.springframework.data.neo4j.aspects

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


* @since 25.03.11
*/
public class PersonCreator implements StateBackedCreator<Person,Node> {
    @Override
    public Person create(Node n, Class<Person> c) throws Exception {
        return new Person(n);
    }
View Full Code Here


        manualCleanDb();
    }

    @Test
  public void testCreateOutsideTransaction() {
    Person p = new Person("Michael", 35);
    assertEquals(35, p.getAge());
    p.setAge(36);
    assertEquals(36, p.getAge());
    assertFalse(hasPersistentState(p));
        persist(p);
        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            assertEquals(36, nodeFor(p).getProperty("age"));
            tx.success();
View Full Code Here

        }
  }

  @Test
  public void testCreateSubgraphOutsideOfTransactionPersistInDirectionOfRel() {
    Person michael = new Person("Michael", 35);
    Person emil = new Person("Emil", 31);

    michael.setBoss(emil);

        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            assertEquals(emil, michael.getBoss());
View Full Code Here

        }
    }

  @Test
  public void testCreateSubgraphOutsideOfTransactionPersistWithImmediateCycle() {
    Person michael = new Person("Michael", 35);
    Person emil = new Person("Emil", 31);

    michael.setBoss(emil);
    emil.setBoss(michael);

        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            assertEquals(emil, michael.getBoss());
            assertEquals(michael, emil.getBoss());
            assertFalse(hasPersistentState(michael));
            assertFalse(hasPersistentState(emil));
            tx.success();
        }
        persist(michael);
View Full Code Here

        }
    }

  @Test
  public void testCreateSubgraphOutsideOfTransactionPersistWithCycle() {
    Person michael = new Person("Michael", 35);
    Person david = new Person("David", 27);
    Person emil = new Person("Emil", 31);

    michael.setBoss(emil);
    david.setBoss(michael);
    emil.setBoss(david);
        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            assertEquals(emil, michael.getBoss());
            assertEquals(michael, david.getBoss());
            assertEquals(david, emil.getBoss());
            assertFalse(hasPersistentState(michael));
            assertFalse(hasPersistentState(david));
            assertFalse(hasPersistentState(emil));
            tx.success();
        }
View Full Code Here

  }

  @Ignore("ignored until subgraph persisting is added")
  @Test
  public void testCreateSubgraphOutsideOfTransactionPersistInReverseDirectionOfRel() {
    Person michael = new Person("Michael", 35);
    Person emil = new Person("Emil", 31);

    michael.setBoss(emil);

    assertEquals(emil, michael.getBoss());
    assertFalse(hasPersistentState(michael));
View Full Code Here

  }

    // TODO: Would be nice if this worked outside of a tx
    @Test(expected = NotInTransactionException.class)
    public void foo() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 26);
        Friendship f = p.knows(p2);
    }
View Full Code Here

    }

  @Test
    public void testSetPropertyOutsideTransaction()
    {
        Person p = persistedPerson( "Michael", 35 );
        p.setAge( 25 );
        assertEquals(25, p.getAge());

        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            assertEquals( 35, nodeFor( p ).getProperty("age") );
            tx.success();
        }
View Full Code Here

    }

    @Test
    public void testSetPropertyOutsideTransactionCanBePersistedThereafter()
    {
        Person p = persistedPerson( "Michael", 35 );
        p.setAge( 25 );
        assertEquals(25, p.getAge());

        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            assertEquals( 35, nodeFor( p ).getProperty("age") );
            tx.success();
        }

        p.persist();

        try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) {
            assertEquals( 25, nodeFor( p ).getProperty("age") );
            tx.success();
        }
View Full Code Here

    public void shouldWorkWithUninitializedCollectionFieldWithoutUnderlyingState() {
        Group group = new Group();
        Collection<Person> people = group.getPersons();
        assertNotNull(people);

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

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

        persist(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.