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