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