### Question:
GraphMutation implements BatchMutation { @Override public BatchMutation createEntity(NewEntity newEntity) { Preconditions.argumentNotNull(newEntity, "newEntity"); CreateEntity createEntity = new CreateEntity(newEntity); pipeline.add(createEntity); 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 testCreateEntityWithNullEntity(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); try{ graphMutation.createEntity(null); fail("Should have thrown an exception with null entity"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Parameter \"newEntity\" cannot be null"); } }
@Test public void testCreateEntityWithValidEntity(){ MockMutationExecuterFactory mutationExecutionFactory = new MockMutationExecuterFactory(); GraphMutation graphMutation = new GraphMutation(mutationExecutionFactory); TartanImplTestUtil util = new TartanImplTestUtil(); NewEntity newEntity = util.createNewEntity(TartanImplTestConstants.ATTR_PARENT_ID); BatchMutation createEntity = graphMutation.createEntity(newEntity); assertNotNull(createEntity); }