@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()); }