@Test
public void testRemovePrincipalFromDomainRolesExceptions() {

    ObjectStoreConnection conn = Mockito.mock(ObjectStoreConnection.class);
    Mockito.when(conn.listPrincipalRoles("dom1", "user.joe"))
            .thenThrow(new ResourceException(404))
            .thenThrow(new ResourceException(501));
    // handle exceptions accordingly
    try {
        zms.dbService.removePrincipalFromDomainRoles(conn, "dom1", "user.joe", adminUser, "unittest");
        fail();
    } catch (ResourceException ex) {
        assertEquals(404, ex.getCode());
    }
    try {
        zms.dbService.removePrincipalFromDomainRoles(conn, "dom1", "user.joe", adminUser, "unittest");
        fail();
    } catch (ResourceException ex) {
        assertEquals(501, ex.getCode());
    }
}