### Question:
AbstractGraphPersistence implements Persistence { @Override public Entity.Mutation prepareMutation(Entity entity) { Preconditions.argumentNotNull(entity, "entity::"+Entity.class.getName()); GraphMutation GraphMutation = new GraphMutation(factory); return GraphMutation.withEntity(entity); } protected  AbstractGraphPersistence(GraphVisitor repository,
            MutationExecutorFactory factory); @Override ID allocateID(); @Override Queries.LookupQuery lookup(); @Override Queries.GraphQuery queryGraph(); @Override Entity.Mutation prepareMutation(Entity entity); @Override Relationship.Mutation prepareMutation(Relationship relationship); @Override Predicate predicates(); @Override BatchMutation prepareBatchMutation();  }### Answer:
@Test public void testPrepareMutationWithNullEntity(){ MockGraphPersistence graphPersistence = createGraphPersistence(); try{ Entity entity = null; graphPersistence.prepareMutation(entity); fail("Should have thrown with null entity"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Parameter \"entity::com.intuit.ugc.api.Entity\" cannot be null"); } }
@Test public void testPrepareMutationWithValidEntity(){ Entity entity = createGraphEntity(); MockGraphPersistence graphPersistence = createGraphPersistence(); Mutation mutation = graphPersistence.prepareMutation(entity); assertNotNull(mutation); }
@Test public void testPrepareMutationWithNullRelationship(){ MockGraphPersistence graphPersistence = createGraphPersistence(); try{ Relationship relationship = null; graphPersistence.prepareMutation(relationship); fail("Should have thrown with null relationship"); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Parameter \"relationship::com.intuit.ugc.api.Relationship\" cannot be null"); } }
@Test public void testPrepareMutationWithValidRelationship(){ 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); MockGraphPersistence graphPersistence = createGraphPersistence(); Relationship.Mutation mutation = graphPersistence.prepareMutation(graphRelationship); assertNotNull(mutation); }