use of cz.metacentrum.perun.core.api.AssignedGroup in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method assignInactiveGroupToResourceActivatesItsSubgroups.
@Test
public void assignInactiveGroupToResourceActivatesItsSubgroups() throws Exception {
System.out.println(CLASS_NAME + "assignInactiveGroupToResourceActivatesItsSubgroups");
vo = setUpVo();
member = setUpMember(vo);
facility = setUpFacility();
Resource inactiveResource = setUpResource();
group = setUpGroup(vo, member);
subGroup = setUpSubGroup(group);
sess.getPerun().getResourcesManager().assignGroupToResource(sess, group, inactiveResource, false, true, true);
List<AssignedGroup> assignedGroups = sess.getPerun().getResourcesManager().getGroupAssignments(sess, inactiveResource, List.of());
AssignedGroup assignedGroup = new AssignedGroup(new EnrichedGroup(group, List.of()), GroupResourceStatus.INACTIVE, null, null, true);
AssignedGroup assignedSubgroup = new AssignedGroup(new EnrichedGroup(subGroup, List.of()), GroupResourceStatus.ACTIVE, group.getId(), null, true);
assertThat(assignedGroups).containsExactlyInAnyOrder(assignedGroup, assignedSubgroup);
}
use of cz.metacentrum.perun.core.api.AssignedGroup in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method createGroupAssignsSubgroup.
@Test
public void createGroupAssignsSubgroup() throws Exception {
System.out.println(CLASS_NAME + "createGroupAssignsSubgroup");
vo = setUpVo();
member = setUpMember(vo);
group = setUpGroup(vo, member);
facility = setUpFacility();
resource = setUpResource();
sess.getPerun().getResourcesManager().assignGroupToResource(sess, group, resource, false, false, true);
// subgroup gets assigned upon creation
subGroup = setUpSubGroup(group);
AssignedGroup assignedGroup = new AssignedGroup(new EnrichedGroup(group, List.of()), GroupResourceStatus.ACTIVE, null, null, true);
AssignedGroup assignedSubgroup = new AssignedGroup(new EnrichedGroup(subGroup, List.of()), GroupResourceStatus.ACTIVE, group.getId(), null, true);
List<AssignedGroup> assignedGroups = sess.getPerun().getResourcesManager().getGroupAssignments(sess, resource, List.of());
assertThat(assignedGroups).containsExactlyInAnyOrder(assignedGroup, assignedSubgroup);
}
use of cz.metacentrum.perun.core.api.AssignedGroup in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method removeGroupFromResourceWithSubgroups.
@Test
public void removeGroupFromResourceWithSubgroups() throws Exception {
System.out.println(CLASS_NAME + "removeGroupFromResourceWithSubgroups");
vo = setUpVo();
member = setUpMember(vo);
group = setUpGroup(vo, member);
facility = setUpFacility();
resource = setUpResource();
subGroup = setUpSubGroup(group);
Group subGroup2 = setUpSubGroup(subGroup);
Group subGroup3 = setUpSubGroup(subGroup2);
Group subGroup4 = setUpSubGroup(subGroup3);
resourcesManager.assignGroupToResource(sess, group, resource, false, false, true);
List<AssignedGroup> assignedGroups = resourcesManager.getGroupAssignments(sess, resource, null);
assertThat(assignedGroups.size()).isEqualTo(5);
// removing parent group from resource should unassign all subgroups
resourcesManager.removeGroupFromResource(sess, group, resource);
assignedGroups = resourcesManager.getGroupAssignments(sess, resource, null);
assertThat(assignedGroups).isEmpty();
}
use of cz.metacentrum.perun.core.api.AssignedGroup in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method assignGroupToResourceWithSubgroup.
@Test
public void assignGroupToResourceWithSubgroup() throws Exception {
System.out.println(CLASS_NAME + "assignGroupToResourceWithSubgroup");
vo = setUpVo();
facility = setUpFacility();
resource = setUpResource();
assertNotNull("unable to create resource", resource);
member = setUpMember(vo);
group = setUpGroup(vo, member);
subGroup = setUpSubGroup(group);
AssignedGroup expectedGroup = new AssignedGroup(new EnrichedGroup(group, null), GroupResourceStatus.ACTIVE, null, null, true);
AssignedGroup expectedSubGroup = new AssignedGroup(new EnrichedGroup(subGroup, null), GroupResourceStatus.ACTIVE, expectedGroup.getEnrichedGroup().getGroup().getId(), null, true);
resourcesManager.assignGroupToResource(sess, group, resource, false, false, true);
List<AssignedGroup> assignedGroups = resourcesManager.getGroupAssignments(sess, resource, null);
assertEquals("two groups (group with subgroup) should be assigned to our Resource", 2, assignedGroups.size());
assertTrue("Our group should be assigned to resource.", assignedGroups.contains(expectedGroup));
assertTrue("Our subgroup should be assigned to resource.", assignedGroups.contains(expectedSubGroup));
}
use of cz.metacentrum.perun.core.api.AssignedGroup in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method removeGroupFromResourceWithoutManuallyAssignedSubgroup.
@Test
public void removeGroupFromResourceWithoutManuallyAssignedSubgroup() throws Exception {
System.out.println(CLASS_NAME + "removeGroupFromResourceWithoutManuallyAssignedSubgroup");
vo = setUpVo();
member = setUpMember(vo);
group = setUpGroup(vo, member);
facility = setUpFacility();
resource = setUpResource();
// subgroups should get assigned to resource upon creation
resourcesManager.assignGroupToResource(sess, group, resource, false, false, true);
subGroup = setUpSubGroup(group);
// manually assign subgroup
resourcesManager.assignGroupToResource(sess, subGroup, resource, false, false, false);
resourcesManager.removeGroupFromResource(sess, group, resource);
List<AssignedGroup> assignedGroups = resourcesManager.getGroupAssignments(sess, resource, null);
AssignedGroup assignedSubgroup = new AssignedGroup(new EnrichedGroup(subGroup, List.of()), GroupResourceStatus.ACTIVE, null, null, false);
assertThat(assignedGroups).containsExactly(assignedSubgroup);
}
Aggregations