use of cz.metacentrum.perun.core.api.EnrichedGroup 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.EnrichedGroup 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);
}
use of cz.metacentrum.perun.core.api.EnrichedGroup in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method getGroupAssignments.
@Test
public void getGroupAssignments() throws Exception {
System.out.println(CLASS_NAME + "getGroupAssignments");
vo = setUpVo();
member = setUpMember(vo);
group = setUpGroup(vo, member);
facility = setUpFacility();
resource = setUpResource();
resourcesManager.assignGroupToResource(sess, group, resource, false, false, false);
List<AssignedGroup> groups = resourcesManager.getGroupAssignments(sess, resource, null);
AssignedGroup expectedGroup = new AssignedGroup(new EnrichedGroup(group, null), GroupResourceStatus.ACTIVE, null, null, false);
assertThat(groups.size()).isEqualTo(1);
assertThat(groups).containsExactly(expectedGroup);
assertThat(groups.get(0).getEnrichedGroup().getAttributes()).containsExactlyInAnyOrderElementsOf(perun.getAttributesManager().getAttributes(sess, group));
}
use of cz.metacentrum.perun.core.api.EnrichedGroup in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method assignMembersGroupToResourceWithSubgroups.
@Test
public void assignMembersGroupToResourceWithSubgroups() throws Exception {
System.out.println(CLASS_NAME + "assignMembersGroupToResourceWithSubgroups");
vo = setUpVo();
facility = setUpFacility();
resource = setUpResource();
assertNotNull("unable to create resource", resource);
member = setUpMember(vo);
group = setUpGroup(vo, member);
Group members = sess.getPerun().getGroupsManager().getGroupByName(sess, vo, VosManager.MEMBERS_GROUP);
AssignedGroup expectedMembersGroupActive = new AssignedGroup(new EnrichedGroup(members, null), GroupResourceStatus.ACTIVE, null, null, true);
AssignedGroup expectedGroupActive = new AssignedGroup(new EnrichedGroup(group, null), GroupResourceStatus.ACTIVE, expectedMembersGroupActive.getEnrichedGroup().getGroup().getId(), null, true);
resourcesManager.assignGroupToResource(sess, members, resource, false, false, true);
List<AssignedGroup> assignedGroups = resourcesManager.getGroupAssignments(sess, resource, null);
assertEquals("two groups should be assigned to our Resource('members' and other test group)", 2, assignedGroups.size());
assertTrue("our group should be assigned to resource.", assignedGroups.contains(expectedGroupActive));
assertTrue("our members group should be assigned to resource", assignedGroups.contains(expectedMembersGroupActive));
}
Aggregations