Package org.springframework.data.neo4j

Examples of org.springframework.data.neo4j.Person


    assertThat(nodeFor(emil), hasRelationship("boss", nodeFor(michael)));
  }

  @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);

    assertEquals(emil, michael.getBoss());
    assertEquals(michael, david.getBoss());
    assertEquals(david, emil.getBoss());
    assertFalse(hasPersistentState(michael));
    assertFalse(hasPersistentState(david));
    assertFalse(hasPersistentState(emil));
    michael.persist();
    assertThat(nodeFor(michael), hasRelationship("boss", nodeFor(emil)));
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));
    assertFalse(hasPersistentState(emil));
    emil.persist();
    assertThat(nodeFor(michael), hasRelationship("boss", nodeFor(emil)));
    assertThat(nodeFor(emil), hasRelationship("boss", nodeFor(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());
        assertEquals( 35, nodeFor( p ).getProperty("age") );
    }
View Full Code Here

    {
        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() );
       
        group.persist();
    assertThat(group.getPersistentState(), hasRelationship("persons", p.getPersistentState()));
    assertThat(p.getPersistentState(), hasRelationship("persons", group.getPersistentState()));
    }
View Full Code Here

        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() );
       
        group.persist();
    assertThat(group.getPersistentState(), hasRelationship("persons", p.getPersistentState()));
    assertThat(p.getPersistentState(), hasRelationship("persons", group.getPersistentState()));
    }
View Full Code Here

    }

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

        p.setSpouse( spouse );

        assertEquals( spouse, p.getSpouse() );
        assertThat( nodeFor( p ), hasNoRelationship( "spouse",spouse.getPersistentState() ) );


        Person spouse2 = persistedPerson( "Rana", 5 );
        p.setSpouse( spouse2 );
        assertEquals( spouse2, p.getSpouse() );
    }
View Full Code Here

    }

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

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

        assertEquals( spouse, p.getSpouse() );
        assertThat( nodeFor( p ), hasRelationship( "spouse" ) );


        Person spouse2 = persistedPerson( "Rana", 5 );
        p.setSpouse( spouse2 );
        assertEquals( spouse2, p.getSpouse() );
    }
View Full Code Here

    }

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

    }

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

TOP

Related Classes of org.springframework.data.neo4j.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.