Search in sources :

Example 6 with EnrichedGroup

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

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

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

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

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