### Question:
CollectionObject extends ContentContainerObject { @Override public CollectionObject validateType() throws FedoraException { if (!isType(Cdr.Collection.getURI())) { throw new ObjectTypeMismatchException("Object " + pid + " is not a Collection."); } if (!isType(PcdmModels.Object.getURI())) { throw new ObjectTypeMismatchException("Object " + pid + " is not a PCDM Object."); } return this; } protected  CollectionObject(PID pid, RepositoryObjectDriver driver,
            RepositoryObjectFactory repoObjFactory); @Override CollectionObject validateType(); @Override ContentContainerObject addMember(ContentObject member);  }### Answer:
@Test public void isValidTypeTest() { List<String> types = Arrays.asList(PcdmModels.Object.getURI(), Cdr.Collection.getURI()); when(driver.loadTypes(eq(collection))).thenAnswer(new Answer<RepositoryObjectDriver>() { @Override public RepositoryObjectDriver answer(InvocationOnMock invocation) throws Throwable { collection.setTypes(types); return driver; } }); collection.validateType(); }
@Test(expected = ObjectTypeMismatchException.class) public void invalidTypeTest() { List<String> types = Arrays.asList(PcdmModels.Object.getURI(), Cdr.Folder.getURI()); when(driver.loadTypes(eq(collection))).thenAnswer(new Answer<RepositoryObjectDriver>() { @Override public RepositoryObjectDriver answer(InvocationOnMock invocation) throws Throwable { collection.setTypes(types); return driver; } }); collection.validateType(); }