Search in sources :

Example 6 with AssignedGroup

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);
}
Also used : 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) AssignedGroup(cz.metacentrum.perun.core.api.AssignedGroup) EnrichedGroup(cz.metacentrum.perun.core.api.EnrichedGroup) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 7 with AssignedGroup

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);
}
Also used : AssignedGroup(cz.metacentrum.perun.core.api.AssignedGroup) EnrichedGroup(cz.metacentrum.perun.core.api.EnrichedGroup) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 8 with AssignedGroup

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();
}
Also used : EnrichedGroup(cz.metacentrum.perun.core.api.EnrichedGroup) AssignedGroup(cz.metacentrum.perun.core.api.AssignedGroup) Group(cz.metacentrum.perun.core.api.Group) AssignedGroup(cz.metacentrum.perun.core.api.AssignedGroup) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 9 with AssignedGroup

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));
}
Also used : AssignedGroup(cz.metacentrum.perun.core.api.AssignedGroup) EnrichedGroup(cz.metacentrum.perun.core.api.EnrichedGroup) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 10 with AssignedGroup

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);
}
Also used : AssignedGroup(cz.metacentrum.perun.core.api.AssignedGroup) EnrichedGroup(cz.metacentrum.perun.core.api.EnrichedGroup) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

AssignedGroup (cz.metacentrum.perun.core.api.AssignedGroup)16 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)10 EnrichedGroup (cz.metacentrum.perun.core.api.EnrichedGroup)10 Test (org.junit.Test)10 Group (cz.metacentrum.perun.core.api.Group)8 Resource (cz.metacentrum.perun.core.api.Resource)7 GroupResourceMismatchException (cz.metacentrum.perun.core.api.exceptions.GroupResourceMismatchException)6 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)6 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)6 BanOnResource (cz.metacentrum.perun.core.api.BanOnResource)5 GroupAlreadyRemovedFromResourceException (cz.metacentrum.perun.core.api.exceptions.GroupAlreadyRemovedFromResourceException)5 GroupNotDefinedOnResourceException (cz.metacentrum.perun.core.api.exceptions.GroupNotDefinedOnResourceException)5 PerunSession (cz.metacentrum.perun.core.api.PerunSession)4 GroupAlreadyAssignedException (cz.metacentrum.perun.core.api.exceptions.GroupAlreadyAssignedException)4 PerunBl (cz.metacentrum.perun.core.bl.PerunBl)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 AssignedResource (cz.metacentrum.perun.core.api.AssignedResource)3