@Test public void testCreatePolicy() throws BusinessException { Integer origSize = policyRepository.findAll().size(); Policy p = new Policy(Policies.FORBIDDEN); policyRepository.create(p); showContent(); Assert.assertEquals(origSize + 1, policyRepository.findAll().size()); }
@Test public void testDeletePolicy() throws BusinessException { Policy p = new Policy(Policies.FORBIDDEN); policyRepository.create(p); Assert.assertNotNull(p.getId()); Integer origSize = policyRepository.findAll().size(); showContent(); policyRepository.delete(policyRepository.findById(p.getId())); Assert.assertEquals(origSize - 1, policyRepository.findAll().size()); }
private void showContent() { if (logger.isDebugEnabled()) { List<Policy> list = policyRepository.findAll(); logger.debug("Size=" + list.size()); for (Policy policy : list) { logger.debug(policy.toString()); } } }
@Test public void testPolicyBehave() throws BusinessException { Policy p = new Policy(Policies.FORBIDDEN); p.applyConsistency(); policyRepository.create(p); Policy p2 = new Policy(Policies.ALLOWED); p2.applyConsistency(); policyRepository.create(p2); Policy p3 = new Policy(Policies.MANDATORY); p3.applyConsistency(); policyRepository.create(p3); showContent(); Assert.assertTrue(policyRepository.findAll().size() >= 3); Assert.assertEquals(false, policyRepository.findById(p.getId()).getStatus()); Assert.assertEquals(p2.getDefaultStatus(), policyRepository.findById(p2.getId()).getStatus()); Assert.assertEquals(true, policyRepository.findById(p3.getId()).getStatus()); }