### Question:
CollectionObject extends ContentContainerObject { @Override public ContentContainerObject addMember(ContentObject member) throws ObjectTypeMismatchException { if (!(member instanceof FolderObject || member instanceof WorkObject)) { throw new ObjectTypeMismatchException("Cannot add object of type " + member.getClass().getName() + " as a member of CollectionObject " + pid.getQualifiedId()); } repoObjFactory.addMember(this, member); return this; } protected  CollectionObject(PID pid, RepositoryObjectDriver driver,
            RepositoryObjectFactory repoObjFactory); @Override CollectionObject validateType(); @Override ContentContainerObject addMember(ContentObject member);  }### Answer:
@Test public void addWorkMemberTest() { collection.addMember(workChildObj); ArgumentCaptor<ContentObject> captor = ArgumentCaptor.forClass(ContentObject.class); verify(repoObjFactory).addMember(eq(collection), captor.capture()); ContentObject child = captor.getValue(); assertTrue("Incorrect type of child added", child instanceof WorkObject); assertEquals("Child did not have the expected pid", workChildPid, child.getPid()); }
@Test public void addFolderMemberTest() { collection.addMember(folderChildObj); ArgumentCaptor<ContentObject> captor = ArgumentCaptor.forClass(ContentObject.class); verify(repoObjFactory).addMember(eq(collection), captor.capture()); ContentObject child = captor.getValue(); assertTrue("Incorrect type of child added", child instanceof FolderObject); assertEquals("Child did not have the expected pid", folderChildPid, child.getPid()); }
@Test(expected = ObjectTypeMismatchException.class) public void addCollectionObjectMemberTest() { collection.addMember(collectionChildObj); }