### Question:
GraphMutation implements BatchMutation { @Override public Relationship.Mutation withRelationship(Relationship relationship) { Preconditions.argumentNotNull(relationship, "relationship"); return new GraphRelationshipMutation(relationship, pipeline, 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 testWithRelationshipWhenRelationshipIsNull(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); try{ graphMutation.withRelationship(null); fail("Should have thrown an exception with null entity"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Parameter \"relationship\" cannot be null"); } }
@Test public void testWithRelationshipWhenRelationshipIsNotNull(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); TartanImplTestUtil util = new TartanImplTestUtil(); Entity.ID sourceEntityID = Entity.ID.valueOf("urn:entity:" + TartanImplTestConstants.ATTR_PARENT_ID.getName() + "." + TartanImplTestConstants.ATTR_PARENT_ID.getName() + "/" + UUID.randomUUID()); Entity.ID targetEntityID = Entity.ID.valueOf("urn:entity:" + TartanImplTestConstants.ATTR_CHILD_ID.getName() + "." + TartanImplTestConstants.ATTR_PARENT_ID.getName() + "/" + UUID.randomUUID()); Name attributeName = TartanImplTestConstants.ATTR_DUMMY_ATTRIBUTE_NAME; String attributeValue = "Dummy Attribute"; Metadata metadata = new MockMetadata(); GraphAttribute graphAttribute = new GraphAttribute(attributeName, attributeValue, metadata); GraphRelationship graphRelationship = util.buildGraphRelationship( TartanImplTestConstants.ATTR_DUMMY_RELATIONSHIP_NAME, sourceEntityID, targetEntityID, graphAttribute); assertNotNull(graphMutation.withRelationship(graphRelationship)); }