Package org.springframework.data.neo4j

Examples of org.springframework.data.neo4j.Person


    }

    @Test(expected = InvalidDataAccessApiUsageException.class)
    @Transactional
    public void testRelationshipSetEntitiesShouldThrowException() {
        Person p = persistedPerson("Michael", 35);
        p.setFriendships(new HashSet<Friendship>());
    }
View Full Code Here


    }

    @Test
    @Transactional
    public void testOneToManyReadOnly() {
        Person michael = persistedPerson("Michael", 35);
        Person david = persistedPerson("David", 25);
        Group group = new Group().persist();
        Set<Person> persons = new HashSet<Person>(Arrays.asList(michael, david));
        group.setPersons(persons);
        assertEquals(persons, IteratorUtil.addToCollection(group.getReadOnlyPersons().iterator(), new HashSet<Person>()));
    }
View Full Code Here

    }

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

    public void testSetProperties() {
        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, p.getPersistentState().getProperty( "name" ) );
        assertEquals( age, p.getPersistentState().getProperty("age"));
        assertEquals((Short)height, p.getHeight());
    }
View Full Code Here

    private GraphDatabaseContext ctx;

    @Test
    @Transactional
    public void shouldConvertNodePathToEntityPath() throws Exception {
        Person michael = new Person("Michael", 36).persist();
        Node node = michael.getPersistentState();
        NodePath path = new NodePath(node);
        EntityPath<Person, Person> entityPath = new ConvertingEntityPath<Person, Person>(ctx, path);

        Assert.assertEquals("start entity",michael, entityPath.startEntity());
        Assert.assertEquals("start node",node, path.startNode());
View Full Code Here

    private GraphDatabaseContext ctx;

    @Test
    @Transactional
    public void shouldConvertNodePathToEntityPath() throws Exception {
        Person michael = new Person("Michael", 36).persist();
        Node node = michael.getPersistentState();
        NodePath path = new NodePath(node);
        EntityPath<Person, Person> entityPath = new ConvertingEntityPath<Person, Person>(ctx, path);

        Assert.assertEquals("start entity",michael, entityPath.startEntity());
        Assert.assertEquals("start node",node, path.startNode());
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, p.getPersistentState().getProperty("height"));
    }
View Full Code Here

    }
    // own transaction handling because of http://wiki.neo4j.org/content/Delete_Semantics
    @Test(expected = NotFoundException.class)
    public void testDeleteEntityFromGDC() {
        Transaction tx = graphDatabaseContext.beginTx();
        Person p = persistedPerson("Michael", 35);
        Person spouse = persistedPerson("Tina", 36);
        p.setSpouse(spouse);
        long id = spouse.getId();
        graphDatabaseContext.removeNodeEntity(spouse);
        tx.success();
        tx.finish();
        Assert.assertNull("spouse removed " + p.getSpouse(), p.getSpouse());
        Person spouseFromIndex = personRepository.findByPropertyValue(Person.NAME_INDEX, "name", "Tina");
        Assert.assertNull("spouse not found in index",spouseFromIndex);
        Assert.assertNull("node deleted " + id, graphDatabaseContext.getNodeById(id));
    }
View Full Code Here

    }

    @Test(expected = NotFoundException.class)
    public void testDeleteEntity() {
        Transaction tx = graphDatabaseContext.beginTx();
        Person p = persistedPerson("Michael", 35);
        Person spouse = persistedPerson("Tina", 36);
        p.setSpouse(spouse);
        long id = spouse.getId();
        spouse.remove();
        tx.success();
        tx.finish();
        Assert.assertNull("spouse removed " + p.getSpouse(), p.getSpouse());
        Person spouseFromIndex = personRepository.findByPropertyValue(Person.NAME_INDEX, "name", "Tina");
        Assert.assertNull("spouse not found in index", spouseFromIndex);
        Assert.assertNull("node deleted " + id, graphDatabaseContext.getNodeById(id));
    }
View Full Code Here

    /**
     * The dynamic properties can only be used, after the entity has been persisted and has an entity state.
     */
    @Test
  public void testCreateOutsideTransaction() {
    Person p = new Person("James", 35);
      p.setProperty("s", "String");
      p.setProperty("x", 100);
      p.setProperty("pi", 3.1415);
    p.persist();
    assertEquals(3, IteratorUtil.count(p.getPersonalProperties().getPropertyKeys()));
    assertProperties(nodeFor(p));
    p.setProperty("s", "String two");
    p.persist();
    assertEquals("String two", nodeFor(p).getProperty("personalProperties-s"))
  }
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.