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