@Override
@Test
public void testTypeCRUD() throws InstantiationException,
IllegalAccessException {
// C
ConsiderationType type = new ConsiderationType();
String name = "test type";
type.setName(name);
Scope scope1 = new Scope();
scope1.setQualifiedClassName(Matter.class.getCanonicalName());
type.getScope().add(scope1);
Scope scope2 = new Scope();
scope2.setQualifiedClassName(CourtCase.class.getCanonicalName());
type.getScope().add(scope2);
getBoSvc().save(type);
// R
type.refresh();
assertEquals("name does not match", name, type.getName());
assertNotNull("scope should not be null", type.getScope());
assertEquals("scope size differs", 2, type.getScope().size());
// U
type.setDescription("test description");
type.getScope().remove(0);
getBoSvc().save(type);
assertNotNull("description should not be null", type.getDescription());
assertEquals("scope size differs", 1, type.getScope().size());
// D
getBoSvc().delete(type);
assertNull(getBoSvc().findBySinglePrimaryKey(getDataObjectClass(), type.getId()));
Map<String, String> criteria = new HashMap<String, String>();
criteria.put("typeId", String.valueOf(type.getId()));
assertTrue("scopes should have been deleted", getBoSvc().findMatching(Scope.class, criteria).isEmpty());
}