@Test
 public void shouldAllowCreateRelationshipWithSameStartAsEndNode() throws Exception {
   long nodeId = graphdbHelper.createNode();
   Map<String, Object> properties = Collections.<String, Object>emptyMap();
   RelationshipRepresentation rel =
       actions.createRelationship(nodeId, nodeId, "Loves", properties);
   assertNotNull(rel);
 }
 @Test
 public void shouldNotCreateRelationshipBetweenNonExistentNodes() throws Exception {
   long nodeId = graphdbHelper.createNode();
   Map<String, Object> properties = Collections.<String, Object>emptyMap();
   try {
     actions.createRelationship(nodeId, nodeId * 1000, "Loves", properties);
     fail();
   } catch (EndNodeNotFoundException e) {
     // ok
   }
   try {
     actions.createRelationship(nodeId * 1000, nodeId, "Loves", properties);
     fail();
   } catch (StartNodeNotFoundException e) {
     // ok
   }
 }
 @Test
 public void shouldStoreRelationshipsBetweenTwoExistingNodes() throws Exception {
   int relationshipCount = graphdbHelper.getNumberOfRelationships();
   actions.createRelationship(
       graphdbHelper.createNode(),
       graphdbHelper.createNode(),
       "LOVES",
       Collections.<String, Object>emptyMap());
   assertEquals(relationshipCount + 1, graphdbHelper.getNumberOfRelationships());
 }
  @Test
  public void shouldStoreSuppliedPropertiesWhenCreatingRelationship() throws Exception {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("string", "value");
    properties.put("integer", 17);
    long relId =
        actions
            .createRelationship(
                graphdbHelper.createNode(), graphdbHelper.createNode(), "LOVES", properties)
            .getId();

    Transaction tx = database.getGraph().beginTx();
    try {
      Relationship rel = database.getGraph().getRelationshipById(relId);
      for (String key : rel.getPropertyKeys()) {
        assertTrue("extra property stored", properties.containsKey(key));
      }
      for (Map.Entry<String, Object> entry : properties.entrySet()) {
        assertEquals(entry.getValue(), rel.getProperty(entry.getKey()));
      }
    } finally {
      tx.finish();
    }
  }