Search in sources :

Example 6 with EnrichedResource

use of cz.metacentrum.perun.core.api.EnrichedResource in project perun by CESNET.

the class ResourcesManagerEntryIntegrationTest method getAssignedResourcesForMemberWithStatus_twoGroupsToOneResource.

@Test
public void getAssignedResourcesForMemberWithStatus_twoGroupsToOneResource() throws Exception {
    System.out.println(CLASS_NAME + "getAssignedResourcesForMemberWithStatus_twoGroupsToOneResource");
    vo = setUpVo();
    member = setUpMember(vo);
    group = setUpGroup(vo, member);
    Group group2 = new Group("ResourcesManagerTestGroup2", "");
    group2 = perun.getGroupsManager().createGroup(sess, vo, group2);
    perun.getGroupsManager().addMember(sess, group2, member);
    facility = setUpFacility();
    resource = setUpResource();
    // both the resources assign to the group
    resourcesManager.assignGroupToResource(sess, group2, resource, false, false, false);
    resourcesManager.deactivateGroupResourceAssignment(sess, group2, resource);
    resourcesManager.assignGroupToResource(sess, group, resource, false, false, false);
    AssignedResource resourceActive = new AssignedResource(new EnrichedResource(resource, null), GroupResourceStatus.ACTIVE, null, null, facility, false);
    AssignedResource resourceInactive = new AssignedResource(new EnrichedResource(resource, null), GroupResourceStatus.INACTIVE, null, null, facility, false);
    List<AssignedResource> resources = resourcesManager.getAssignedResourcesWithStatus(sess, member);
    assertEquals("member should be assigned to a single resources", 1, resources.size());
    assertTrue("assigned resources should be in returned list", resources.contains(resourceActive));
    // removing group should change the status
    resourcesManager.removeGroupFromResource(sess, group, resource);
    resources = resourcesManager.getAssignedResourcesWithStatus(sess, member);
    assertEquals("member should be assigned to a single resources", 1, resources.size());
    assertTrue("assigned resource should be in returned list", resources.contains(resourceInactive));
}
Also used : EnrichedGroup(cz.metacentrum.perun.core.api.EnrichedGroup) AssignedGroup(cz.metacentrum.perun.core.api.AssignedGroup) Group(cz.metacentrum.perun.core.api.Group) EnrichedResource(cz.metacentrum.perun.core.api.EnrichedResource) AssignedResource(cz.metacentrum.perun.core.api.AssignedResource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 7 with EnrichedResource

use of cz.metacentrum.perun.core.api.EnrichedResource in project perun by CESNET.

the class ResourcesManagerEntryIntegrationTest method getEnrichedResourceByIdWithGivenAttributes.

@Test
public void getEnrichedResourceByIdWithGivenAttributes() throws Exception {
    System.out.println(CLASS_NAME + "getEnrichedResourceByIdWithGivenAttributes");
    vo = setUpVo();
    facility = setUpFacility();
    Resource resource = setUpResource();
    EnrichedResource eResource = resourcesManager.getEnrichedResourceById(sess, resource.getId(), Collections.singletonList(A_R_C_ID));
    assertThat(eResource.getResource()).isEqualTo(resource);
    assertThat(eResource.getAttributes()).hasSize(1);
    assertThat(eResource.getAttributes().get(0).getName()).isEqualTo(A_R_C_ID);
}
Also used : EnrichedResource(cz.metacentrum.perun.core.api.EnrichedResource) AssignedResource(cz.metacentrum.perun.core.api.AssignedResource) Resource(cz.metacentrum.perun.core.api.Resource) BanOnResource(cz.metacentrum.perun.core.api.BanOnResource) RichResource(cz.metacentrum.perun.core.api.RichResource) EnrichedResource(cz.metacentrum.perun.core.api.EnrichedResource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 8 with EnrichedResource

use of cz.metacentrum.perun.core.api.EnrichedResource in project perun by CESNET.

the class ResourcesManagerEntryIntegrationTest method getEnrichedResourcesForFacilityWithAllAttributes.

@Test
public void getEnrichedResourcesForFacilityWithAllAttributes() throws Exception {
    System.out.println(CLASS_NAME + "getEnrichedResourcesForFacilityWithAllAttributes");
    vo = setUpVo();
    facility = setUpFacility();
    Resource resource = setUpResource();
    List<EnrichedResource> eResources = resourcesManager.getEnrichedResourcesForFacility(sess, facility, null);
    assertThat(eResources).hasSize(1);
    assertThat(eResources.get(0).getResource()).isEqualTo(resource);
    assertThat(eResources.get(0).getAttributes()).isNotEmpty();
}
Also used : EnrichedResource(cz.metacentrum.perun.core.api.EnrichedResource) AssignedResource(cz.metacentrum.perun.core.api.AssignedResource) Resource(cz.metacentrum.perun.core.api.Resource) BanOnResource(cz.metacentrum.perun.core.api.BanOnResource) RichResource(cz.metacentrum.perun.core.api.RichResource) EnrichedResource(cz.metacentrum.perun.core.api.EnrichedResource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

EnrichedResource (cz.metacentrum.perun.core.api.EnrichedResource)8 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)7 AssignedResource (cz.metacentrum.perun.core.api.AssignedResource)7 Test (org.junit.Test)7 BanOnResource (cz.metacentrum.perun.core.api.BanOnResource)5 Resource (cz.metacentrum.perun.core.api.Resource)5 RichResource (cz.metacentrum.perun.core.api.RichResource)5 AssignedGroup (cz.metacentrum.perun.core.api.AssignedGroup)1 EnrichedGroup (cz.metacentrum.perun.core.api.EnrichedGroup)1 Group (cz.metacentrum.perun.core.api.Group)1 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)1