Search in sources :

Example 21 with Group

use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.

the class DatabaseSetup method makeGrouping.

private void makeGrouping(String path, Group basis, Group exclude, Group include, Group owners, boolean listserveOn, boolean optInOn, boolean optOutOn) {
    Grouping grouping = new Grouping(path);
    Group composite = buildComposite(include, exclude, basis, path);
    groupRepository.save(composite);
    grouping.setBasis(basis);
    grouping.setExclude(exclude);
    grouping.setInclude(include);
    grouping.setOwners(owners);
    grouping.setComposite(composite);
    grouping.setListservOn(listserveOn);
    grouping.setOptInOn(optInOn);
    grouping.setOptOutOn(optOutOn);
    groupings.add(grouping);
}
Also used : Group(edu.hawaii.its.api.type.Group) Grouping(edu.hawaii.its.api.type.Grouping)

Example 22 with Group

use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceTest method setup.

@Before
public void setup() {
    new DatabaseSetup(personRepository, groupRepository, groupingRepository, membershipRepository);
    admins.add(ADMIN_PERSON);
    adminGroup = new Group(GROUPING_ADMINS, admins);
    personRepository.save(ADMIN_PERSON);
    groupRepository.save(adminGroup);
    admins.add(APP_PERSON);
    appGroup = new Group(GROUPING_APPS, apps);
    personRepository.save(APP_PERSON);
    groupRepository.save(appGroup);
    for (int i = 0; i < 100; i++) {
        String name = NAME + i;
        String uuid = UUID + i;
        String username = USERNAME + i;
        Person person = new Person(name, uuid, username);
        users.add(person);
        WsSubjectLookup lookup = new WsSubjectLookup(null, null, username);
        lookups.add(lookup);
    }
}
Also used : Group(edu.hawaii.its.api.type.Group) WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) Person(edu.hawaii.its.api.type.Person) Before(org.junit.Before)

Example 23 with Group

use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceTest method groupingsInTest.

@Test
public void groupingsInTest() {
    Iterable<Group> groupsIn = groupRepository.findByMembersUsername(users.get(6).getUsername());
    List<String> groupPaths = new ArrayList<>();
    List<String> supposedGroupings = new ArrayList<>();
    for (Group group : groupsIn) {
        groupPaths.add(group.getPath());
    }
    supposedGroupings.addAll(groupPaths.stream().filter(groupPath -> groupPath.matches("[a-zA-Z0-9:]*grouping[0-9]*")).collect(Collectors.toList()));
    List<Grouping> groupingsIn = groupingAssignmentService.groupingsIn(groupPaths);
    List<String> groupingPaths = groupingsIn.stream().map(Grouping::getPath).collect(Collectors.toList());
    for (String path : supposedGroupings) {
        assertTrue(groupingPaths.contains(path));
    }
    for (Grouping grouping : groupingsIn) {
        assertTrue(supposedGroupings.contains(grouping.getPath()));
    }
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) ArrayList(java.util.ArrayList) Grouping(edu.hawaii.its.api.type.Grouping) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 24 with Group

use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceTest method groupingsOptedIntoTest.

@Test
public void groupingsOptedIntoTest() {
    String user5 = users.get(5).getUsername();
    Iterable<Group> groups = groupRepository.findByMembersUsername(user5);
    List<String> groupPaths = new ArrayList<>();
    for (Group group : groups) {
        groupPaths.add(group.getPath());
    }
    List<Grouping> groupingsOptedInto = groupingAssignmentService.groupingsOptedInto(user5, groupPaths);
    // starts with no groupings opted into
    assertEquals(0, groupingsOptedInto.size());
    // opt into a grouping
    membershipService.optIn(user5, GROUPING_1_PATH);
    groupingsOptedInto = groupingAssignmentService.groupingsOptedInto(user5, groupPaths);
    assertEquals(1, groupingsOptedInto.size());
    // opt into another grouping
    membershipService.optIn(user5, GROUPING_3_PATH);
    groupingsOptedInto = groupingAssignmentService.groupingsOptedInto(user5, groupPaths);
    assertEquals(2, groupingsOptedInto.size());
    // opt out of a grouping
    membershipService.optOut(user5, GROUPING_3_PATH);
    groupingsOptedInto = groupingAssignmentService.groupingsOptedInto(user5, groupPaths);
    assertEquals(1, groupingsOptedInto.size());
    // opt out of another grouping
    membershipService.optOut(user5, GROUPING_1_PATH);
    groupingsOptedInto = groupingAssignmentService.groupingsOptedInto(user5, groupPaths);
    assertEquals(0, groupingsOptedInto.size());
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) ArrayList(java.util.ArrayList) Grouping(edu.hawaii.its.api.type.Grouping) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 25 with Group

use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceTest method makeGroupTest.

@Test
public void makeGroupTest() {
    WsGetMembersResults getMembersResults = new WsGetMembersResults();
    WsGetMembersResult[] getMembersResult = new WsGetMembersResult[1];
    WsGetMembersResult getMembersResult1 = new WsGetMembersResult();
    WsSubject[] list = new WsSubject[3];
    for (int i = 0; i < 3; i++) {
        list[i] = new WsSubject();
        list[i].setName("testSubject_" + i);
        list[i].setId("testSubject_uuid_" + i);
        list[i].setAttributeValues(new String[] { "testSubject_username_" + i });
    }
    getMembersResult1.setWsSubjects(list);
    getMembersResult[0] = getMembersResult1;
    getMembersResults.setResults(getMembersResult);
    Group group = groupingAssignmentService.makeGroup(getMembersResults);
    for (int i = 0; i < group.getMembers().size(); i++) {
        assertTrue(group.getMembers().get(i).getName().equals("testSubject_" + i));
        assertTrue(group.getNames().contains("testSubject_" + i));
        assertTrue(group.getMembers().get(i).getUuid().equals("testSubject_uuid_" + i));
        assertTrue(group.getUuids().contains("testSubject_uuid_" + i));
        assertTrue(group.getMembers().get(i).getUsername().equals("testSubject_username_" + i));
        assertTrue(group.getUsernames().contains("testSubject_username_" + i));
    }
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsGetMembersResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResult) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) WsGetMembersResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Group (edu.hawaii.its.api.type.Group)40 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)23 Person (edu.hawaii.its.api.type.Person)21 Grouping (edu.hawaii.its.api.type.Grouping)13 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 WsSubjectLookup (edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup)9 Before (org.junit.Before)8 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)7 Membership (edu.hawaii.its.api.type.Membership)6 WsGetMembersResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults)4 WsSubject (edu.internet2.middleware.grouperClient.ws.beans.WsSubject)4 WsMembership (edu.internet2.middleware.grouperClient.ws.beans.WsMembership)3 AdminListsHolder (edu.hawaii.its.api.type.AdminListsHolder)2 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)2 WsGetGroupsResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult)2 WsGetGroupsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults)2 WsGetMembersResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResult)2 GroupingAssignment (edu.hawaii.its.api.type.GroupingAssignment)1