@Test @Transactional public void shouldCreateRelationshipWithProperty() throws Exception { Relationship relationship = neo4jTemplate.createRelationshipBetween(referenceNode, node1, "has", map("name", "rel2")); assertNotNull(relationship); assertEquals(referenceNode, relationship.getStartNode()); assertEquals(node1, relationship.getEndNode()); assertEquals(HAS.name(), relationship.getType().name()); assertEquals("rel2", relationship.getProperty("name", "not set")); }
@Test public void listing3_9_add_properties_to_relationships() { usersAndMovies.addPropertiesToRelationships(); try (Transaction tx = graphDb.beginTx()) { Relationship hasSeen = usersAndMovies.user1.getSingleRelationship( MyRelationshipTypes.HAS_SEEN, Direction.OUTGOING); assertEquals(5, hasSeen.getProperty("stars")); tx.success(); } }
@Override public String convert(Relationship value, Class<String> type) { return (String) value.getProperty("name"); }