use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults 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));
}
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceTest method makeGroup.
@Test
public void makeGroup() {
WsGetMembersResults getMembersResults = new WsGetMembersResults();
WsGetMembersResult[] getMembersResult = new WsGetMembersResult[1];
WsGetMembersResult getMembersResult1 = new WsGetMembersResult();
WsSubject[] subjects = new WsSubject[0];
getMembersResult1.setWsSubjects(subjects);
getMembersResult[0] = getMembersResult1;
getMembersResults.setResults(getMembersResult);
assertNotNull(groupingAssignmentService.makeGroup(getMembersResults));
subjects = new WsSubject[1];
getMembersResults.getResults()[0].setWsSubjects(subjects);
assertNotNull(groupingAssignmentService.makeGroup(getMembersResults));
subjects[0] = new WsSubject();
getMembersResults.getResults()[0].setWsSubjects(subjects);
assertNotNull(groupingAssignmentService.makeGroup(getMembersResults));
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method makeWsGetMembersResults.
@Override
public WsGetMembersResults makeWsGetMembersResults(String subjectAttributeName, WsSubjectLookup lookup, String groupName) {
WsGetMembersResults wsGetMembersResults = new WsGetMembersResults();
String[] attributeNames = new String[] { UID_KEY, UUID_KEY, LAST_NAME_KEY, COMPOSITE_NAME_KEY, FIRST_NAME_KEY };
wsGetMembersResults.setSubjectAttributeNames(attributeNames);
WsGetMembersResult wsGetMembersResult = new WsGetMembersResult();
WsSubject[] subjects;
Group group = groupRepository.findByPath(groupName);
List<Person> members = group.getMembers();
List<WsSubject> subjectList = new ArrayList<>();
for (Person person : members) {
WsSubject subject = new WsSubject();
subject.setId(person.getUuid());
subject.setName(person.getName());
// has to be the same order as attributeNames array
subject.setAttributeValues(new String[] { person.getUsername(), person.getUuid(), person.getLastName(), person.getName(), person.getFirstName() });
subjectList.add(subject);
}
subjects = subjectList.toArray(new WsSubject[subjectList.size()]);
wsGetMembersResult.setWsSubjects(subjects);
wsGetMembersResults.setResults(new WsGetMembersResult[] { wsGetMembersResult });
return wsGetMembersResults;
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceImpl method getMembers.
// returns a group from grouper or the database
@Override
public Group getMembers(String ownerUsername, String groupPath) {
logger.info("getMembers; user: " + ownerUsername + "; group: " + groupPath + ";");
WsSubjectLookup lookup = grouperFS.makeWsSubjectLookup(ownerUsername);
WsGetMembersResults members = grouperFS.makeWsGetMembersResults(SUBJECT_ATTRIBUTE_NAME_UID, lookup, groupPath);
// todo should we use EmptyGroup?
Group groupMembers = new Group();
if (members.getResults() != null) {
groupMembers = makeGroup(members);
}
return groupMembers;
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceImpl method makeGroup.
// makes a group filled with members from membersResults
@Override
public Group makeGroup(WsGetMembersResults membersResults) {
Group group = new Group();
try {
WsSubject[] subjects = membersResults.getResults()[0].getWsSubjects();
String[] attributeNames = membersResults.getSubjectAttributeNames();
if (subjects.length > 0) {
for (WsSubject subject : subjects) {
if (subject != null) {
group.addMember(makePerson(subject, attributeNames));
}
}
}
} catch (NullPointerException npe) {
return new Group();
}
return group;
}
Aggregations