### Question:
GraphMutation implements BatchMutation { @Override public BatchMutation createRelationship(NewRelationship newRelationship) { Preconditions.argumentNotNull(newRelationship, "newRelationship"); CreateRelationship createRelationships = new CreateRelationship( newRelationship); pipeline.add(createRelationships); return this; } @Inject  GraphMutation(MutationExecutorFactory factory); @Override BatchMutation createEntity(NewEntity newEntity); @Override BatchMutation createRelationship(NewRelationship newRelationship); @Override OperationResult<Result> execute(); @Override Entity.Mutation withEntity(Entity entity); @Override Relationship.Mutation withRelationship(Relationship relationship);  }### Answer:
@Test public void testCreateRelationshipWithNullRelationship(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); try{ graphMutation.createRelationship(null); fail("Should have thrown an exception with null relationship"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Parameter \"newRelationship\" cannot be null"); } }
@Test public void testCreateRelationshipWithValidRelationship(){ TartanImplTestUtil util = new TartanImplTestUtil(); NewEntity sourceEntity = util.createNewEntity(TartanImplTestConstants.ATTR_CHILD_KEY); NewEntity targetEntity = util.createNewEntity(TartanImplTestConstants.ATTR_PARENT_KEY); NewRelationship newRelationship = NewRelationship .between(sourceEntity.getEntityID(), targetEntity.getEntityID()).withLabel(TartanImplTestConstants.ATTR_PARENT_CHILD_KEY).build(); MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); BatchMutation createRelationship = graphMutation.createRelationship(newRelationship); assertNotNull(createRelationship); }