use of cz.metacentrum.perun.core.api.EnrichedGroup in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method createGroupAssignsSubgroupTree.
@Test
public void createGroupAssignsSubgroupTree() throws Exception {
System.out.println(CLASS_NAME + "createGroupAssignsSubgroupTree");
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 on creation
subGroup = setUpSubGroup(group);
Group subGroup2 = setUpSubGroup(subGroup);
Group subGroup3 = setUpSubGroup(subGroup2);
AssignedGroup assignedSubgroup21 = new AssignedGroup(new EnrichedGroup(subGroup2, List.of()), GroupResourceStatus.ACTIVE, group.getId(), null, true);
AssignedGroup assignedSubgroup22 = new AssignedGroup(new EnrichedGroup(subGroup3, List.of()), GroupResourceStatus.ACTIVE, group.getId(), null, true);
List<AssignedGroup> assignedGroups = sess.getPerun().getResourcesManager().getGroupAssignments(sess, resource, List.of());
assertThat(assignedGroups).contains(assignedSubgroup21, assignedSubgroup22);
}
use of cz.metacentrum.perun.core.api.EnrichedGroup in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method autoAssignSubgroupWithInactiveSourceGroup.
@Test
public void autoAssignSubgroupWithInactiveSourceGroup() throws Exception {
System.out.println(CLASS_NAME + "autoAssignSubgroupWithInactiveSourceGroup");
vo = setUpVo();
member = setUpMember(vo);
group = setUpGroup(vo, member);
facility = setUpFacility();
Resource inactiveResource = setUpResource();
sess.getPerun().getResourcesManager().assignGroupToResource(sess, group, inactiveResource, false, true, true);
sess.getPerun().getResourcesManager().deactivateGroupResourceAssignment(sess, group, inactiveResource);
// subgroup gets assigned on creation
subGroup = setUpSubGroup(group);
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.EnrichedGroup in project perun by CESNET.
the class ResourcesManagerEntryIntegrationTest method assignGroupToResourceAsInactive.
@Test
public void assignGroupToResourceAsInactive() throws Exception {
System.out.println(CLASS_NAME + "assignGroupToResourceAsInactive");
vo = setUpVo();
facility = setUpFacility();
resource = setUpResource();
assertNotNull("unable to create resource", resource);
member = setUpMember(vo);
group = setUpGroup(vo, member);
resourcesManager.assignGroupToResource(sess, group, resource, false, true, false);
AssignedGroup expectedGroup = new AssignedGroup(new EnrichedGroup(group, null), GroupResourceStatus.INACTIVE, null, null, false);
List<AssignedGroup> assignedGroups = resourcesManager.getGroupAssignments(sess, resource, null);
assertEquals("one group should be assigned to our Resource", 1, assignedGroups.size());
assertTrue("our group should be assigned to resource Expected: " + group.getName() + ", Actual: " + assignedGroups.get(0).getEnrichedGroup().getGroup().getName(), assignedGroups.contains(expectedGroup));
assertEquals("our group should be assigned to resource as inactive", assignedGroups.get(0).getStatus(), GroupResourceStatus.INACTIVE);
}
use of cz.metacentrum.perun.core.api.EnrichedGroup 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.EnrichedGroup 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);
}
Aggregations