Package mock

Examples of mock.OwnedEntity


        viewer.setPassword("viewer");
        viewer.setName("viewer");
        viewer.addRole((RoleImpl) securityDAO.findAuthority("registered_user"));
        securityDAO.createUser(viewer);
        assertNotNull(securityDAO.findUser("viewer"));
        OwnedEntity one = new OwnedEntity();
        one.setName("one");
        dao.create(one);
        oneID = one.getId();
        OwnedEntity two = new OwnedEntity();
        two.setName("two");
        two.addOwner(mary);
        two.addViewer(viewer);
        dao.create(two);
        twoID = two.getId();
        OwnedEntity three = new OwnedEntity();
        three.setName("three");
        three.addOwner(mary);
        dao.create(three);
        OwnedEntity four = new OwnedEntity();
        four.setName("four");
        dao.create(four);
        OwnedEntity five = new OwnedEntity();
        five.setName("five");
        five.addOwner(mary);
        dao.create(five);
        fiveID = five.getId();
    }
View Full Code Here


        fiveID = five.getId();
    }

    @Test
    public void testIsAllowed() {
        OwnedEntity entity = new OwnedEntity();
        entity.setId(new UUID("00aa00aa00aa00aa00aa00aa00aa00aa"));
        entity.addOwner((UserImpl) securityDAO.findUser("mary"));
        assertNull("john is disallowed on entities created by mary", dao.update(entity));
        assertNotNull("john is allowed on his entities", dao.update(dao.first(OwnedEntity.class)));
        userManager.setName("viewer");
        assertNull("viewers can't update anything", dao.update(dao.first(OwnedEntity.class)));
    }
View Full Code Here

        assertTrue("Owner is automatically injected in entities", CollectionUtils.isNotEmpty(dao.first(OwnedEntity.class).getOwners()));
    }

    @Test
    public void testMerge() {
        OwnedEntity e = dao.first(OwnedEntity.class);
        e.addOwner((UserImpl) securityDAO.findUser("mary"));
        OwnedEntity both = (OwnedEntity) dao.update(e);
        assertTrue("Owner collection is merged correctly", both.getOwners().size() == 2);
        assertTrue("Viewers collection is merged correctly", both.getViewers().size() == 2);
    }
View Full Code Here

    @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);
View Full Code Here

TOP

Related Classes of mock.OwnedEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.