@Test
public void testCreateRelationship(){
TestBatchResult r = this.restAPI.executeBatch(new BatchCallback<TestBatchResult>() {
@Override
public TestBatchResult recordBatch(RestAPI batchRestApi) {
TestBatchResult result=new TestBatchResult();
result.n1 = batchRestApi.createNode(map("name", "newnode1"));
result.n2 = batchRestApi.createNode(map("name", "newnode2"));
result.rel = batchRestApi.createRelationship(result.n1, result.n2, Type.TEST, map("name", "rel") );
result.allRelationships = result.n1.getRelationships();
return result;
}
});
Relationship foundRelationship = TestHelper.firstRelationshipBetween( r.n1.getRelationships(Type.TEST, Direction.OUTGOING), r.n1, r.n2);
Assert.assertNotNull("found relationship", foundRelationship);
assertEquals("same relationship", r.rel, foundRelationship);
assertEquals("rel", r.rel.getProperty("name"));
assertThat(r.n1.getRelationships(Type.TEST, Direction.OUTGOING), new IsRelationshipToNodeMatcher(r.n1, r.n2));
assertThat(r.n1.getRelationships(Direction.OUTGOING), new IsRelationshipToNodeMatcher(r.n1, r.n2));
assertThat(r.n1.getRelationships(Direction.BOTH), new IsRelationshipToNodeMatcher(r.n1, r.n2));
assertThat(r.n1.getRelationships(Type.TEST), new IsRelationshipToNodeMatcher(r.n1, r.n2));
assertThat(r.allRelationships, new IsRelationshipToNodeMatcher(r.n1, r.n2));
}