use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingsRestController method getGroupingTest.
@Test
@WithMockUhUser(username = "iamtst01")
public void getGroupingTest() throws Exception {
Grouping grouping = mapGrouping(GROUPING);
Group basis = grouping.getBasis();
Group composite = grouping.getComposite();
Group exclude = grouping.getExclude();
Group include = grouping.getInclude();
// basis
assertTrue(basis.getUsernames().contains(tst[3]));
assertTrue(basis.getUsernames().contains(tst[4]));
assertTrue(basis.getUsernames().contains(tst[5]));
assertTrue(basis.getNames().contains(tstName[3]));
assertTrue(basis.getNames().contains(tstName[4]));
assertTrue(basis.getNames().contains(tstName[5]));
// composite
assertTrue(composite.getUsernames().contains(tst[0]));
assertTrue(composite.getUsernames().contains(tst[1]));
assertTrue(composite.getUsernames().contains(tst[2]));
assertTrue(composite.getUsernames().contains(tst[4]));
assertTrue(composite.getUsernames().contains(tst[5]));
assertTrue(composite.getNames().contains(tstName[0]));
assertTrue(composite.getNames().contains(tstName[1]));
assertTrue(composite.getNames().contains(tstName[2]));
assertTrue(composite.getNames().contains(tstName[4]));
assertTrue(composite.getNames().contains(tstName[5]));
// exclude
assertTrue(exclude.getUsernames().contains(tst[3]));
assertTrue(exclude.getNames().contains(tstName[3]));
// include
assertTrue(include.getUsernames().contains(tst[0]));
assertTrue(include.getUsernames().contains(tst[1]));
assertTrue(include.getUsernames().contains(tst[2]));
assertTrue(include.getNames().contains(tstName[0]));
assertTrue(include.getNames().contains(tstName[1]));
assertTrue(include.getNames().contains(tstName[2]));
assertFalse(grouping.getOwners().getNames().contains(tstName[5]));
mapGSR("/api/groupings/" + grouping.getPath() + "/" + tst[5] + "/assignOwnership");
grouping = mapGrouping(GROUPING);
assertTrue(grouping.getOwners().getNames().contains(tstName[5]));
mapGSR("/api/groupings/" + grouping.getPath() + "/" + tst[5] + "/removeOwnership");
grouping = mapGrouping(GROUPING);
assertFalse(grouping.getOwners().getNames().contains(tstName[5]));
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class DatabaseSetup method removeExcludedMembers.
private Group removeExcludedMembers(Group basisPlusInclude, Group exclude) {
List<Person> newBasisPlusInclude = new ArrayList<>(basisPlusInclude.getMembers());
newBasisPlusInclude.removeAll(exclude.getMembers());
Group basisPlusIncludeMinusExcludeGroup = new Group();
basisPlusIncludeMinusExcludeGroup.setMembers(newBasisPlusInclude);
return basisPlusIncludeMinusExcludeGroup;
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class DatabaseSetup method setUpMemberships.
private void setUpMemberships() {
Person grouperAll = new Person();
grouperAll.setUsername("GrouperAll");
personRepository.save(grouperAll);
Iterable<Group> groups = groupRepository.findAll();
for (Group group : groups) {
group.addMember(grouperAll);
groupRepository.save(group);
for (Person person : group.getMembers()) {
Membership membership = new Membership(person, group);
membershipRepository.save(membership);
}
}
Iterable<Grouping> groupings = groupingRepository.findAll();
for (Grouping grouping : groupings) {
Membership allExclude = membershipRepository.findByPersonAndGroup(grouperAll, grouping.getExclude());
Membership allInclude = membershipRepository.findByPersonAndGroup(grouperAll, grouping.getInclude());
Membership allComposite = membershipRepository.findByPersonAndGroup(grouperAll, grouping.getComposite());
if (grouping.isOptOutOn()) {
allComposite.setOptOutEnabled(true);
allExclude.setOptInEnabled(true);
allExclude.setOptOutEnabled(true);
}
if (grouping.isOptInOn()) {
allComposite.setOptInEnabled(true);
allInclude.setOptInEnabled(true);
allInclude.setOptOutEnabled(true);
}
membershipRepository.save(allComposite);
membershipRepository.save(allExclude);
membershipRepository.save(allInclude);
}
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupAttributeServiceTest 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 groupingsOptedOutOfTest.
@Test
public void groupingsOptedOutOfTest() {
String user1 = users.get(1).getUsername();
Iterable<Group> groups = groupRepository.findByMembersUsername(user1);
List<String> groupPaths = new ArrayList<>();
for (Group group : groups) {
groupPaths.add(group.getPath());
}
List<Grouping> groupingsOptedOutOf = groupingAssignmentService.groupingsOptedOutOf(user1, groupPaths);
// starts with no groupings out of
assertEquals(0, groupingsOptedOutOf.size());
// opt out of a grouping
membershipService.optOut(user1, GROUPING_1_PATH);
groups = groupRepository.findByMembersUsername(user1);
groupPaths = new ArrayList<>();
for (Group group : groups) {
groupPaths.add(group.getPath());
}
groupingsOptedOutOf = groupingAssignmentService.groupingsOptedOutOf(user1, groupPaths);
assertEquals(1, groupingsOptedOutOf.size());
// opt out of another grouping
membershipService.optOut(user1, GROUPING_3_PATH);
groups = groupRepository.findByMembersUsername(user1);
groupPaths = new ArrayList<>();
for (Group group : groups) {
groupPaths.add(group.getPath());
}
groupingsOptedOutOf = groupingAssignmentService.groupingsOptedOutOf(user1, groupPaths);
assertEquals(2, groupingsOptedOutOf.size());
// opt into a grouping
membershipService.optIn(user1, GROUPING_3_PATH);
groups = groupRepository.findByMembersUsername(user1);
groupPaths = new ArrayList<>();
for (Group group : groups) {
groupPaths.add(group.getPath());
}
groupingsOptedOutOf = groupingAssignmentService.groupingsOptedOutOf(user1, groupPaths);
assertEquals(1, groupingsOptedOutOf.size());
// opt into another grouping
membershipService.optIn(user1, GROUPING_1_PATH);
groups = groupRepository.findByMembersUsername(user1);
groupPaths = new ArrayList<>();
for (Group group : groups) {
groupPaths.add(group.getPath());
}
groupingsOptedOutOf = groupingAssignmentService.groupingsOptedOutOf(user1, groupPaths);
assertEquals(0, groupingsOptedOutOf.size());
}
Aggregations