@Test
public void testRemovePrincipalFromAllRolesExceptions() {

    ObjectStoreConnection conn = Mockito.mock(ObjectStoreConnection.class);
    Mockito.when(conn.listPrincipalRoles(null, "user.joe"))
            .thenThrow(new ResourceException(404))
            .thenThrow(new ResourceException(501));
    // no exception if store returns 404
    zms.dbService.removePrincipalFromAllRoles(conn, "user.joe", adminUser, "unittest");
    // with next we should throw the exception so we should catch it
    try {
        zms.dbService.removePrincipalFromAllRoles(conn, "user.joe", adminUser, "unittest");
        fail();
    } catch (ResourceException ex) {
        assertEquals(501, ex.getCode());
    }
}