@Test
public void testFindAllWithPublic() {
assertTrue("Users are there", securityDAO.findUsers(null, null, null, 0, 100).size() == 3);
userManager.setName("mary");
OwnedEntity e = dao.find(OwnedEntity.class, fiveID);
e.setPublicView(true);
dao.update(e);
assertTrue("Users have not been deleted", securityDAO.findUsers(null, null, null, 0, 100).size() == 3);
assertTrue("No viewers for public entities", CollectionUtils.isEmpty(dao.find(OwnedEntity.class, fiveID).getViewers()));
assertTrue("mary see hers", dao.find(OwnedEntity.class, 0, 100).size() == 3);
userManager.setName("john");
assertTrue("mary is filtered from a findAll except public viewing", dao.find(OwnedEntity.class, 0, 100).size() == 3);
userManager.setName("viewer");
assertTrue("the viewer is allowed once plus the public entity", dao.find(OwnedEntity.class, 0, 100).size() == 2);
userManager.setName("mary");
e = dao.find(OwnedEntity.class, fiveID);
e.setPublicView(false);
assertTrue("Users have not been deleted", securityDAO.findUsers(null, null, null, 0, 100).size() == 3);
dao.update(e);
e = dao.find(OwnedEntity.class, fiveID);
assertTrue("Viewers are just owners", e.getViewers().size() == e.getOwners().size());
assertTrue("mary see hers", dao.find(OwnedEntity.class, 0, 100).size() == 3);
userManager.setName("john");
assertTrue("mary is filtered from a findAll except public viewing", dao.find(OwnedEntity.class, 0, 100).size() == 2);
userManager.setName("viewer");
assertTrue("the viewer is allowed once plus the public entity", dao.find(OwnedEntity.class, 0, 100).size() == 1);