Ejemplo n.º 1
0
 @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);
   }
 }
Ejemplo n.º 2
0
 @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());
 }
Ejemplo n.º 3
0
 @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);
 }
Ejemplo n.º 4
0
  @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());
  }
Ejemplo n.º 5
0
 @Test
 public void testDeleteById() throws Exception {
   repository.create(policy);
   repository.deleteById(policy.getId());
   policy.setId(null);
 }
Ejemplo n.º 6
0
 @Test
 public void testCreate() throws Exception {
   repository.create(policy);
   assertNotNull(policy.getId());
 }
Ejemplo n.º 7
0
 @Test
 public void testFindById() throws Exception {
   ResourcePolicy policy = repository.findById(1L);
   assertNotNull(policy);
 }
Ejemplo n.º 8
0
 @Test
 public void testFindAllByResourceType() throws Exception {
   assertEquals(3, repository.findAllByResourceType("/dev/host").size());
 }