Package org.springframework.data.neo4j

Examples of org.springframework.data.neo4j.Person


    }

    @Test
    @Transactional
    public void testRelationshipSetProperty() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Friendship f = p.knows(p2);
        f.setYears(1);
        assertEquals(1, f.getPersistentState().getProperty("Friendship.years"));
    }
View Full Code Here


    }

    @Test
    @Transactional
    public void testRelationshipGetProperty() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Friendship f = p.knows(p2);
        f.getPersistentState().setProperty("Friendship.years", 1);
        assertEquals(1, f.getYears());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testRelationshipGetStartNodeAndEndNode() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Friendship f = p.knows(p2);
        assertEquals(p, f.getPerson1());
        assertEquals(p2, f.getPerson2());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testGetRelationshipToReturnsRelationship() {
        Person p = persistedPerson("Michael", 35);
        Person p2 = persistedPerson("David", 25);
        Friendship f = p.knows(p2);
        assertEquals(f,p.getRelationshipTo(p2, Friendship.class, "knows"));
    }
View Full Code Here

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

    }

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

    }

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

        Node node = graphDatabaseContext.getNodeById(nodeId);
        Person person1 = (Person) graphDatabaseContext.createEntityFromStoredType(node);
        assertEquals("Rod", person1.getName());
        Person person2 = graphDatabaseContext.createEntityFromState(node,Person.class);
        assertEquals("Rod", person2.getName());

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

    }

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

        Node node = graphDatabaseContext.getNodeById(nodeId);
        Person person1 = (Person) graphDatabaseContext.createEntityFromStoredType(node);
        assertEquals("Rod", person1.getName());
        Person person2 = graphDatabaseContext.createEntityFromState(node,Person.class);
        assertEquals("Rod", person2.getName());

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

    assertEquals(36, nodeFor(p).getProperty("age"));
  }

  @Test
  public void testCreateSubgraphOutsideOfTransactionPersistInDirectionOfRel() {
    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

  }

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

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

    assertEquals(emil, michael.getBoss());
    assertEquals(michael, emil.getBoss());
    assertFalse(hasPersistentState(michael));
    assertFalse(hasPersistentState(emil));
    michael.persist();
    assertThat(nodeFor(michael), hasRelationship("boss", nodeFor(emil)));
    assertThat(nodeFor(emil), hasRelationship("boss", nodeFor(michael)));
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.