Package org.springframework.data.neo4j

Examples of org.springframework.data.neo4j.Person


    @Test
    @Transactional
    public void testTraverseFromGroupToPeopleWithFinder() {
        final GraphRepository<Person> finder = graphRepositoryFactory.createGraphRepository(Person.class);
        Person p = persistedPerson("Michael", 35);
        Group group = new Group().persist();
        group.setName("dev");
        group.addPerson(p);
        final TraversalDescription traversalDescription = new TraversalDescriptionImpl().relationships(DynamicRelationshipType.withName("persons")).filter(Traversal.returnAllButStartNode());
        Iterable<Person> people = finder.findAllByTraversal(group, traversalDescription);
View Full Code Here


        Neo4jHelper.cleanDb(graphDatabaseContext);
    }

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

    @Test
  @Transactional
  public void testInstantiateConcreteClass() {
    log.debug("testInstantiateConcreteClass");
        Person p = persistedPerson("Michael", 35);
    Car c = new Volvo().persist();
    p.setCar(c);
    assertEquals("Wrong concrete class.", Volvo.class, p.getCar().getClass());
  }
View Full Code Here

    }

    @Test
    @Transactional
    public void testCreateRelationshipWithoutAnnotationOnSet() {
        Person p = persistedPerson("Michael", 35);
        Person spouse = persistedPerson("Tina", 36);
        p.setSpouse(spouse);
        Node spouseNode=p.getPersistentState().getSingleRelationship(DynamicRelationshipType.withName("spouse"), Direction.OUTGOING).getEndNode();
        assertEquals(spouse.getPersistentState(), spouseNode);
        assertEquals(spouse, p.getSpouse());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testCreateRelationshipWithAnnotationOnSet() {
        Person p = persistedPerson("Michael", 35);
        Person mother = persistedPerson("Gabi", 60);
        p.setMother(mother);
        Node motherNode = p.getPersistentState().getSingleRelationship(DynamicRelationshipType.withName("mother"), Direction.OUTGOING).getEndNode();
        assertEquals(mother.getPersistentState(), motherNode);
        assertEquals(mother, p.getMother());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testDeleteRelationship() {
        Person p = persistedPerson("Michael", 35);
        Person spouse = persistedPerson("Tina", 36);
        p.setSpouse(spouse);
        p.setSpouse(null);
        Assert.assertNull(p.getPersistentState().getSingleRelationship(DynamicRelationshipType.withName("spouse"), Direction.OUTGOING));
        Assert.assertNull(p.getSpouse());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testDeletePreviousRelationshipOnNewRelationship() {
        Person p = persistedPerson("Michael", 35);
        Person spouse = persistedPerson("Tina", 36);
        Person friend = persistedPerson("Helga", 34);
        p.setSpouse(spouse);
        p.setSpouse(friend);
        assertEquals(friend.getPersistentState(), p.getPersistentState().getSingleRelationship(DynamicRelationshipType.withName("spouse"), Direction.OUTGOING).getEndNode());
        assertEquals(friend, p.getSpouse());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testCreateIncomingRelationshipWithAnnotationOnSet() {
        Person p = persistedPerson("David", 25);
        Person boss = persistedPerson("Emil", 32);
        p.setBoss(boss);
        assertEquals(boss.getPersistentState(), p.getPersistentState().getSingleRelationship(DynamicRelationshipType.withName("boss"), Direction.INCOMING).getStartNode());
        assertEquals(boss, p.getBoss());
    }
View Full Code Here

        assertEquals(boss, p.getBoss());
    }

    @Transactional
    public void testAllowsCircularRelationship() {
        Person p = persistedPerson("Michael", 35);
        p.setBoss(p);

        assertEquals("created self-referencing relationship",p,p.getBoss());
    }
View Full Code Here

    private GraphDatabaseContext ctx;

    @Test
    @Transactional
    public void entityMapperShouldForwardEntityPath() throws Exception {
        Person michael = new Person("Michael", 36).persist();
        EntityMapper<Person, Person, String> mapper = new EntityMapper<Person, Person, String>(ctx) {
            @Override
            public String mapPath(EntityPath<Person, Person> entityPath) {
                return entityPath.<Person>startEntity().getName();
            }
        };
        String name = mapper.mapPath(new NodePath(michael.getPersistentState()));
        Assert.assertEquals(michael.getName(), name);
    }
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.