Search in sources :

Example 11 with WsGroup

use of edu.internet2.middleware.grouperClient.ws.beans.WsGroup in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceTest method extractGroupPaths.

// ///////////////////////////////////////////////////
// non-mocked tests//////////////////////////////////
// ///////////////////////////////////////////////////
@Test
public void extractGroupPaths() {
    List<WsGroup> groups = null;
    List<String> groupNames = groupingAssignmentService.extractGroupPaths(groups);
    assertEquals(0, groupNames.size());
    groups = new ArrayList<>();
    final int size = 300;
    for (int i = 0; i < size; i++) {
        WsGroup w = new WsGroup();
        w.setName("testName_" + i);
        groups.add(w);
    }
    assertEquals(size, groups.size());
    groupNames = groupingAssignmentService.extractGroupPaths(groups);
    for (int i = 0; i < size; i++) {
        assertTrue(groupNames.contains("testName_" + i));
    }
    assertEquals(size, groupNames.size());
    // Create some duplicates.
    groups = new ArrayList<>();
    for (int j = 0; j < 3; j++) {
        for (int i = 0; i < size; i++) {
            WsGroup w = new WsGroup();
            w.setName("testName_" + i);
            groups.add(w);
        }
    }
    assertEquals(size * 3, groups.size());
    // Duplicates should not be in groupNames list.
    groupNames = groupingAssignmentService.extractGroupPaths(groups);
    assertEquals(size, groupNames.size());
    for (int i = 0; i < size; i++) {
        assertTrue(groupNames.contains("testName_" + i));
    }
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with WsGroup

use of edu.internet2.middleware.grouperClient.ws.beans.WsGroup in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method removeGroupsWithoutOptOut.

private WsGetAttributeAssignmentsResults removeGroupsWithoutOptOut(WsGetAttributeAssignmentsResults wsGetAttributeAssignmentsResults) {
    List<WsGroup> wsGroupList = Arrays.asList(wsGetAttributeAssignmentsResults.getWsGroups());
    List<WsAttributeAssign> wsAttributeAssignList = Arrays.asList(wsGetAttributeAssignmentsResults.getWsAttributeAssigns());
    List<WsGroup> newWsGroupList = new ArrayList<>();
    List<WsAttributeAssign> newWsAttributeAssignList = new ArrayList<>();
    for (WsGroup wsGroup : wsGroupList) {
        Grouping grouping = groupingRepository.findByPath(wsGroup.getName());
        if (grouping.isOptOutOn()) {
            newWsGroupList.add(wsGroup);
        }
    }
    for (WsAttributeAssign wsAttributeAssign : wsAttributeAssignList) {
        Grouping grouping = groupingRepository.findByPath(wsAttributeAssign.getOwnerGroupName());
        if (grouping.isOptOutOn()) {
            newWsAttributeAssignList.add(wsAttributeAssign);
        }
    }
    wsGetAttributeAssignmentsResults.setWsAttributeAssigns(newWsAttributeAssignList.toArray(new WsAttributeAssign[newWsAttributeAssignList.size()]));
    wsGetAttributeAssignmentsResults.setWsGroups(newWsGroupList.toArray(new WsGroup[newWsGroupList.size()]));
    return wsGetAttributeAssignmentsResults;
}
Also used : ArrayList(java.util.ArrayList) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) WsAttributeAssign(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign) Grouping(edu.hawaii.its.api.type.Grouping)

Example 13 with WsGroup

use of edu.internet2.middleware.grouperClient.ws.beans.WsGroup in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceImpl method groupingsOpted.

// returns a list of groupings corresponding to the include group orr exclude group (includeOrrExclude) in groupPaths that
// have the self-opted attribute set in the membership
public List<Grouping> groupingsOpted(String includeOrrExclude, String username, List<String> groupPaths) {
    logger.info("groupingsOpted; includeOrrExclude: " + includeOrrExclude + "; username: " + username + ";");
    List<String> groupingsOpted = new ArrayList<>();
    List<String> groupsOpted = groupPaths.stream().filter(group -> group.endsWith(includeOrrExclude) && memberAttributeService.isSelfOpted(group, username)).map(helperService::parentGroupingPath).collect(Collectors.toList());
    if (groupsOpted.size() > 0) {
        List<WsGetAttributeAssignmentsResults> attributeAssignmentsResults = grouperFS.makeWsGetAttributeAssignmentsResultsTrio(ASSIGN_TYPE_GROUP, TRIO, groupsOpted);
        List<WsGroup> triosList = new ArrayList<>();
        for (WsGetAttributeAssignmentsResults results : attributeAssignmentsResults) {
            triosList.addAll(Arrays.asList(results.getWsGroups()));
        }
        groupingsOpted.addAll(triosList.stream().map(WsGroup::getName).collect(Collectors.toList()));
    }
    return helperService.makeGroupings(groupingsOpted);
}
Also used : ArrayList(java.util.ArrayList) WsGetAttributeAssignmentsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup)

Example 14 with WsGroup

use of edu.internet2.middleware.grouperClient.ws.beans.WsGroup in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceImpl method getGroupPaths.

// returns the list of groups that the user is in
@Override
public List<String> getGroupPaths(String username) {
    logger.info("getGroupPaths; username: " + username + ";");
    WsStemLookup stemLookup = grouperFS.makeWsStemLookup(STEM);
    WsGetGroupsResults wsGetGroupsResults = grouperFS.makeWsGetGroupsResults(username, stemLookup, StemScope.ALL_IN_SUBTREE);
    WsGetGroupsResult groupResults = wsGetGroupsResults.getResults()[0];
    List<WsGroup> groups = new ArrayList<>();
    if (groupResults.getWsGroups() != null) {
        groups = new ArrayList<>(Arrays.asList(groupResults.getWsGroups()));
    }
    return extractGroupPaths(groups);
}
Also used : WsGetGroupsResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult) WsStemLookup(edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup) WsGetGroupsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults) ArrayList(java.util.ArrayList) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup)

Example 15 with WsGroup

use of edu.internet2.middleware.grouperClient.ws.beans.WsGroup in project cas by apereo.

the class GrouperFacadeTests method verifyGroups.

@Test
public void verifyGroups() {
    val facade = new DefaultGrouperFacade() {

        @Override
        public WsGetGroupsResult[] fetchGroupsFor(final String subjectId) {
            val group = new WsGroup();
            group.setExtension("GroupExtension");
            group.setDisplayName("DisplayNameGroupExtension");
            group.setDisplayExtension("DisplaySampleGroupExtension");
            group.setDescription("Group Desc");
            group.setName("SampleGroup");
            group.setUuid(UUID.randomUUID().toString());
            val result = new WsGetGroupsResult();
            result.setWsGroups(new WsGroup[] { group });
            return new WsGetGroupsResult[] { result };
        }
    };
    assertFalse(facade.getGroupsForSubjectId("casuser").isEmpty());
}
Also used : lombok.val(lombok.val) WsGetGroupsResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Test(org.junit.jupiter.api.Test)

Aggregations

WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)20 ArrayList (java.util.ArrayList)9 WsGetGroupsResult (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult)5 GroupsException (org.apereo.portal.groups.GroupsException)5 IEntityGroup (org.apereo.portal.groups.IEntityGroup)5 WsFindGroupsResults (edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults)4 Grouping (edu.hawaii.its.api.type.Grouping)3 GcFindGroups (edu.internet2.middleware.grouperClient.api.GcFindGroups)3 GcGroupSave (edu.internet2.middleware.grouperClient.api.GcGroupSave)3 WsGetGroupsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults)3 WsGroupToSave (edu.internet2.middleware.grouperClient.ws.beans.WsGroupToSave)3 WsSubjectLookup (edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup)3 lombok.val (lombok.val)3 Test (org.junit.jupiter.api.Test)3 Group (edu.hawaii.its.api.type.Group)2 WsAttributeAssign (edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)2 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)2 WsGroupLookup (edu.internet2.middleware.grouperClient.ws.beans.WsGroupLookup)2 WsQueryFilter (edu.internet2.middleware.grouperClient.ws.beans.WsQueryFilter)2 WsStemLookup (edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup)2