/**
* tests CRUD on annex type
*/
public void testStatusCRUD() {
// create
Status status = new Status();
status.setName("pending");
//test scopes
Scope scope1 = new Scope();
final String canonicalName1 = Matter.class.getCanonicalName();
scope1.setQualifiedClassName(canonicalName1);
status.getScope().add(scope1);
Scope scope2 = new Scope();
final String canonicalName2 = Contract.class.getCanonicalName();
scope2.setQualifiedClassName(canonicalName2);
status.getScope().add(scope2);
getBoSvc().save(status);
//refresh
status.refresh();
// retrieve
assertEquals("the Status does not match", "pending", status.getName());
assertFalse("scope should not be empty", status.getScope().isEmpty());
assertEquals("scope size differs", 2, status.getScope().size());
assertEquals("class name differs", canonicalName1, status.getScope().get(0).getQualifiedClassName());
assertEquals("class name differs", canonicalName2, status.getScope().get(1).getQualifiedClassName());
//update
status.setName("appealed");
status.getScope().remove(0);
getBoSvc().save(status);
//refresh
status.refresh();
assertEquals("the Status does not match", "appealed", status.getName());
assertEquals("scope size differs", 1, status.getScope().size());
assertEquals("class name differs", canonicalName2, status.getScope().get(0).getQualifiedClassName());
// delete
getBoSvc().delete(status);
assertNull("status should have been deleted", getBoSvc().findBySinglePrimaryKey(Status.class, status.getId()));
Map<String, String> criteria = new HashMap<String, String>();
criteria.put("typeId", String.valueOf(status.getId()));
assertTrue("scopes should have been deleted", getBoSvc().findMatching(Scope.class, criteria).isEmpty());
}