Search in sources :

Example 1 with EnrichedGroup

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

Example 2 with EnrichedGroup

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);
}
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 3 with EnrichedGroup

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);
}
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 4 with EnrichedGroup

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);
}
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 5 with EnrichedGroup

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

AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)9 AssignedGroup (cz.metacentrum.perun.core.api.AssignedGroup)9 EnrichedGroup (cz.metacentrum.perun.core.api.EnrichedGroup)9 Test (org.junit.Test)9 AssignedResource (cz.metacentrum.perun.core.api.AssignedResource)2 BanOnResource (cz.metacentrum.perun.core.api.BanOnResource)2 EnrichedResource (cz.metacentrum.perun.core.api.EnrichedResource)2 Group (cz.metacentrum.perun.core.api.Group)2 Resource (cz.metacentrum.perun.core.api.Resource)2 RichResource (cz.metacentrum.perun.core.api.RichResource)2