use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceTest method setup.
@Before
public void setup() {
new DatabaseSetup(personRepository, groupRepository, groupingRepository, membershipRepository);
admins.add(ADMIN_PERSON);
Group adminGroup = new Group(GROUPING_ADMINS, admins);
personRepository.save(ADMIN_PERSON);
groupRepository.save(adminGroup);
admins.add(APP_PERSON);
Group 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);
}
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceTest method groupingsOwnedTest.
@Test
public void groupingsOwnedTest() {
Iterable<Group> groupsIn = groupRepository.findByMembersUsername(users.get(0).getUsername());
List<String> groupPaths = new ArrayList<>();
for (Group group : groupsIn) {
groupPaths.add(group.getPath());
}
List<Grouping> groupingsOwned = groupingAssignmentService.groupingsOwned(groupPaths);
for (int i = 0; i < groupingsOwned.size(); i++) {
assertTrue(groupingsOwned.get(i).getPath().equals(PATH_ROOT + i));
}
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class MemberAttributeServiceTest method checkSelfOptedTest.
@Test
public void checkSelfOptedTest() {
// user is not in group
boolean selfOpted = memberAttributeService.isSelfOpted(GROUPING_0_INCLUDE_PATH, users.get(2).getUsername());
assertFalse(selfOpted);
// user has not self opted
selfOpted = memberAttributeService.isSelfOpted(GROUPING_0_INCLUDE_PATH, users.get(5).getUsername());
assertFalse(selfOpted);
// user has self opted
Person person = personRepository.findByUsername(users.get(5).getUsername());
Group group = groupRepository.findByPath(GROUPING_0_INCLUDE_PATH);
Membership membership = membershipRepository.findByPersonAndGroup(person, group);
membership.setSelfOpted(true);
membershipRepository.save(membership);
selfOpted = memberAttributeService.isSelfOpted(GROUPING_0_INCLUDE_PATH, users.get(5).getUsername());
assertTrue(selfOpted);
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestMembershipService method getMembersTest.
@Test
public void getMembersTest() {
Group group = groupingAssignmentService.getMembers(username[0], GROUPING);
List<String> usernames = group.getUsernames();
assertTrue(usernames.contains(username[0]));
assertTrue(usernames.contains(username[1]));
assertTrue(usernames.contains(username[2]));
assertFalse(usernames.contains(username[3]));
assertTrue(usernames.contains(username[4]));
assertTrue(usernames.contains(username[5]));
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method makeWsAddMemberResults.
@Override
public WsAddMemberResults makeWsAddMemberResults(String group, WsSubjectLookup lookup, Person personToAdd) {
Person newGroupMember;
WsAddMemberResults wsAddMemberResults = new WsAddMemberResults();
WsResultMeta wsResultMeta = new WsResultMeta();
wsResultMeta.setResultCode(SUCCESS);
wsAddMemberResults.setResultMetadata(wsResultMeta);
Grouping grouping = groupingRepository.findByIncludePathOrExcludePathOrCompositePathOrOwnersPath(group, group, group, group);
if (personToAdd.getUsername() != null) {
newGroupMember = personRepository.findByUsername(personToAdd.getUsername());
} else {
newGroupMember = personRepository.findByUuid(personToAdd.getUuid());
}
if (grouping == null) {
Group groupToAddTo = groupRepository.findByPath(group);
addMember(groupToAddTo, newGroupMember);
} else {
boolean inBasis = grouping.getBasis().isMember(newGroupMember);
boolean inExclude = grouping.getExclude().isMember(newGroupMember);
boolean inInclude = grouping.getInclude().isMember(newGroupMember);
if (group.endsWith(OWNERS)) {
addMember(grouping.getOwners(), newGroupMember);
} else if (group.endsWith(EXCLUDE)) {
if (inBasis) {
addMember(grouping.getExclude(), newGroupMember);
} else if (inInclude) {
deleteMember(grouping.getInclude(), newGroupMember);
}
} else if (group.endsWith(INCLUDE)) {
if (inExclude) {
deleteMember(grouping.getExclude(), newGroupMember);
} else if (!inBasis) {
addMember(grouping.getInclude(), newGroupMember);
}
}
grouping = groupingRepository.findByPath(grouping.getPath());
Group composite = buildComposite(grouping.getInclude(), grouping.getExclude(), grouping.getBasis(), grouping.getPath());
groupRepository.save(composite);
}
return wsAddMemberResults;
}
Aggregations