use of edu.hawaii.its.api.type.GroupingAssignment in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceImpl method getGroupingAssignment.
// get a GroupingAssignment object containing the groups that a user is in and can opt into
@Override
public GroupingAssignment getGroupingAssignment(String username) {
GroupingAssignment groupingAssignment = new GroupingAssignment();
List<String> groupPaths = getGroupPaths(username);
groupingAssignment.setGroupingsIn(groupingsIn(groupPaths));
groupingAssignment.setGroupingsOwned(groupingsOwned(groupPaths));
groupingAssignment.setGroupingsToOptInTo(groupingsToOptInto(username, groupPaths));
groupingAssignment.setGroupingsToOptOutOf(groupingsToOptOutOf(username, groupPaths));
groupingAssignment.setGroupingsOptedOutOf(groupingsOptedOutOf(username, groupPaths));
groupingAssignment.setGroupingsOptedInTo(groupingsOptedInto(username, groupPaths));
return groupingAssignment;
}
use of edu.hawaii.its.api.type.GroupingAssignment in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method myGroupings.
// Test data.
private GroupingAssignment myGroupings() {
GroupingAssignment mg = new GroupingAssignment();
List<Grouping> groupings = new ArrayList<>();
for (int i = 0; i < 3; i++) {
groupings.add(grouping());
groupings.get(i).setPath("grouping" + i);
}
mg.setGroupingsIn(groupings);
mg.setGroupingsOwned(groupings);
mg.setGroupingsOptedOutOf(groupings);
mg.setGroupingsOptedInTo(groupings);
mg.setGroupingsToOptOutOf(groupings);
mg.setGroupingsToOptInTo(groupings);
return mg;
}
use of edu.hawaii.its.api.type.GroupingAssignment in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingsRestController method myGroupingsTest3.
@Test
@WithMockUhUser(username = "iamtst04")
public void myGroupingsTest3() throws Exception {
boolean optedIn = false;
GroupingAssignment tst4Groupings = mapGroupingAssignment();
assertEquals(tst4Groupings.getGroupingsOptedInTo().size(), 0);
mapGSRs("/api/groupings/" + GROUPING + "/optIn");
tst4Groupings = mapGroupingAssignment();
for (Grouping grouping : tst4Groupings.getGroupingsOptedInTo()) {
if (grouping.getPath().contains(GROUPING)) {
optedIn = true;
}
}
// in basis
assertFalse(optedIn);
}
use of edu.hawaii.its.api.type.GroupingAssignment in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingsRestController method myGroupingsTest2.
@Test
@WithMockUhUser(username = "iamtst04")
public void myGroupingsTest2() throws Exception {
GroupingAssignment groupings = mapGroupingAssignment();
boolean inGrouping = false;
for (Grouping grouping : groupings.getGroupingsIn()) {
if (grouping.getPath().contains(this.GROUPING)) {
inGrouping = true;
break;
}
}
assertFalse(inGrouping);
boolean ownsGrouping = false;
for (Grouping grouping : groupings.getGroupingsOwned()) {
if (grouping.getPath().contains(this.GROUPING)) {
ownsGrouping = true;
break;
}
}
assertFalse(ownsGrouping);
}
use of edu.hawaii.its.api.type.GroupingAssignment in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingsRestController method aaronTest.
@Test
@WithMockUhUser(username = "aaronvil")
public void aaronTest() throws Exception {
// This test often fails because the test server is very slow.
// Because the server caches some results and gets quicker the more times
// it is run, we let it run a few times if it starts failing
int i = 0;
while (i < 5) {
try {
GroupingAssignment aaronsGroupings = mapGroupingAssignment();
assertNotNull(aaronsGroupings);
break;
} catch (AssertionError ae) {
i++;
}
}
assertTrue(i < 5);
}
Aggregations