### Question:
GraphMutation implements BatchMutation { @Override public Entity.Mutation withEntity(Entity entity) { Preconditions.argumentNotNull(entity, "entity"); return new GraphEntityMutation(entity, 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 testWithEntityWhenEntityIsNull(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); try{ graphMutation.withEntity(null); fail("Should have thrown an exception with null entity"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Parameter \"entity\" cannot be null"); } }
@Test public void testWithEntityWhenEntityIsNotNull(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); Mutation withEntity = graphMutation.withEntity(buildEntity()); assertNotNull(withEntity); }