@After public void tearDown() throws Exception { if (policy.getId() != null) repository.deleteById(policy.getId()); for (ComponentPolicy cpuPolicy : cpuPolicies) { if (cpuPolicy.getId() != null) repository.deleteComponentPolicy(cpuPolicy); } }
@Test public void testCreateComponentPolicy() throws Exception { repository.create(policy); for (ComponentPolicy cpuPolicy : cpuPolicies) { cpuPolicy.setResourcePolicyId(policy.getId()); repository.createComponentPolicy(cpuPolicy); } ResourcePolicy newPolicy = repository.findById(policy.getId()); assertNotNull(newPolicy.getComponents()); assertEquals(1, newPolicy.getComponents().length); }
@Test public void testUpdateComponentPolicy() throws Exception { repository.create(policy); for (ComponentPolicy cpuPolicy : cpuPolicies) { cpuPolicy.setResourcePolicyId(policy.getId()); repository.createComponentPolicy(cpuPolicy); } cpuPolicies[0].setCriteria("new-criteria"); repository.updateComponentPolicy(cpuPolicies[0]); ResourcePolicy newPolicy = repository.findById(policy.getId()); assertNotNull(newPolicy.getComponents()); assertEquals(1, newPolicy.getComponents().length); assertEquals("new-criteria", newPolicy.getComponents()[0].getCriteria()); }
@Test public void testUpdate() throws Exception { repository.create(policy); policy.setLabel("new-policy"); repository.update(policy); ResourcePolicy anotherInstance = repository.findById(policy.getId()); assertEquals("new-policy", anotherInstance.getLabel()); }
@Test public void testDeleteById() throws Exception { repository.create(policy); repository.deleteById(policy.getId()); policy.setId(null); }
@Test public void testCreate() throws Exception { repository.create(policy); assertNotNull(policy.getId()); }