@Test public void testMapping() throws Exception { NodeForGraphAssertions jugNode = node("jug", JUG.class.getSimpleName(), ENTITY.name()) .property("jug_id", jug.getId()) .property("name", jug.getName()); NodeForGraphAssertions emmanuelNode = node("emmanuel", Member.class.getSimpleName(), ENTITY.name()) .property("member_id", emmanuel.getId()) .property("name", emmanuel.getName()); NodeForGraphAssertions jeromeNode = node("jerome", Member.class.getSimpleName(), ENTITY.name()) .property("member_id", jerome.getId()) .property("name", jerome.getName()); RelationshipsChainForGraphAssertions relationship1 = emmanuelNode.relationshipTo(jugNode, "memberOf"); RelationshipsChainForGraphAssertions relationship2 = jeromeNode.relationshipTo(jugNode, "memberOf"); assertThatOnlyTheseNodesExist(jugNode, emmanuelNode, jeromeNode); assertThatOnlyTheseRelationshipsExist(relationship1, relationship2); }
@Before public void prepareDb() throws Exception { final EntityManager em = getFactory().createEntityManager(); em.getTransaction().begin(); jug = new JUG("summer_camp"); jug.setName("JUG Summer Camp"); em.persist(jug); emmanuel = new Member("emmanuel"); emmanuel.setName("Emmanuel Bernard"); emmanuel.setMemberOf(jug); jerome = new Member("jerome"); jerome.setName("Jerome"); jerome.setMemberOf(jug); em.persist(emmanuel); em.persist(jerome); em.getTransaction().commit(); em.close(); }