use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method getMyGroupings.
@Test
@WithMockUhUser
public void getMyGroupings() throws Exception {
ObjectMapper om = new ObjectMapper();
final String username = "user";
List<Grouping> groupings = new ArrayList<>();
for (int i = 0; i < 3; i++) {
groupings.add(grouping());
groupings.get(i).setPath("grouping" + i);
}
given(groupingAssignmentService.getGroupingAssignment(username)).willReturn(myGroupings());
String mvcResult = mockMvc.perform(get("/api/groupings/groupingAssignment")).andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
GroupingAssignment mg = om.readValue(mvcResult, GroupingAssignment.class);
Assert.assertTrue(mg.getGroupingsIn().get(0).getName().equals(groupings.get(0).getName()));
Assert.assertTrue(mg.getGroupingsIn().get(0).getPath().equals(groupings.get(0).getPath()));
Assert.assertTrue(mg.getGroupingsIn().get(0).getOwners().getNames().equals(groupings.get(0).getOwners().getNames()));
Assert.assertTrue(mg.getGroupingsIn().get(0).getOwners().getUsernames().equals(groupings.get(0).getOwners().getUsernames()));
Assert.assertTrue(mg.getGroupingsIn().get(0).getOwners().getUuids().equals(groupings.get(0).getOwners().getUuids()));
Assert.assertTrue(mg.getGroupingsOwned().get(0).getName().equals(groupings.get(0).getName()));
Assert.assertTrue(mg.getGroupingsOwned().get(0).getPath().equals(groupings.get(0).getPath()));
Assert.assertTrue(mg.getGroupingsOwned().get(0).getOwners().getNames().equals(groupings.get(0).getOwners().getNames()));
Assert.assertTrue(mg.getGroupingsOwned().get(0).getOwners().getUsernames().equals(groupings.get(0).getOwners().getUsernames()));
Assert.assertTrue(mg.getGroupingsOwned().get(0).getOwners().getUuids().equals(groupings.get(0).getOwners().getUuids()));
Assert.assertTrue(mg.getGroupingsToOptInTo().get(0).getName().equals(groupings.get(0).getName()));
Assert.assertTrue(mg.getGroupingsToOptInTo().get(0).getPath().equals(groupings.get(0).getPath()));
Assert.assertTrue(mg.getGroupingsToOptInTo().get(0).getOwners().getNames().equals(groupings.get(0).getOwners().getNames()));
Assert.assertTrue(mg.getGroupingsToOptInTo().get(0).getOwners().getUsernames().equals(groupings.get(0).getOwners().getUsernames()));
Assert.assertTrue(mg.getGroupingsToOptInTo().get(0).getOwners().getUuids().equals(groupings.get(0).getOwners().getUuids()));
Assert.assertTrue(mg.getGroupingsToOptOutOf().get(0).getName().equals(groupings.get(0).getName()));
Assert.assertTrue(mg.getGroupingsToOptOutOf().get(0).getPath().equals(groupings.get(0).getPath()));
Assert.assertTrue(mg.getGroupingsToOptOutOf().get(0).getOwners().getNames().equals(groupings.get(0).getOwners().getNames()));
Assert.assertTrue(mg.getGroupingsToOptOutOf().get(0).getOwners().getUsernames().equals(groupings.get(0).getOwners().getUsernames()));
Assert.assertTrue(mg.getGroupingsToOptOutOf().get(0).getOwners().getUuids().equals(groupings.get(0).getOwners().getUuids()));
Assert.assertTrue(mg.getGroupingsOptedInTo().get(0).getName().equals(groupings.get(0).getName()));
Assert.assertTrue(mg.getGroupingsOptedInTo().get(0).getPath().equals(groupings.get(0).getPath()));
Assert.assertTrue(mg.getGroupingsOptedInTo().get(0).getOwners().getNames().equals(groupings.get(0).getOwners().getNames()));
Assert.assertTrue(mg.getGroupingsOptedInTo().get(0).getOwners().getUsernames().equals(groupings.get(0).getOwners().getUsernames()));
Assert.assertTrue(mg.getGroupingsOptedInTo().get(0).getOwners().getUuids().equals(groupings.get(0).getOwners().getUuids()));
Assert.assertTrue(mg.getGroupingsOptedOutOf().get(0).getName().equals(groupings.get(0).getName()));
Assert.assertTrue(mg.getGroupingsOptedOutOf().get(0).getPath().equals(groupings.get(0).getPath()));
Assert.assertTrue(mg.getGroupingsOptedOutOf().get(0).getOwners().getNames().equals(groupings.get(0).getOwners().getNames()));
Assert.assertTrue(mg.getGroupingsOptedOutOf().get(0).getOwners().getUsernames().equals(groupings.get(0).getOwners().getUsernames()));
Assert.assertTrue(mg.getGroupingsOptedOutOf().get(0).getOwners().getUuids().equals(groupings.get(0).getOwners().getUuids()));
}
use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingsRestController method getEmptyGroupingTest.
@Test
@WithMockUhUser(username = "iamtst01")
public void getEmptyGroupingTest() throws Exception {
Grouping storeEmpty = mapGrouping(GROUPING_STORE_EMPTY);
Grouping trueEmpty = mapGrouping(GROUPING_TRUE_EMPTY);
assertTrue(storeEmpty.getBasis().getMembers().size() == 1);
assertTrue(storeEmpty.getComposite().getMembers().size() == 0);
assertTrue(storeEmpty.getExclude().getMembers().size() == 0);
assertTrue(storeEmpty.getInclude().getMembers().size() == 0);
assertTrue(storeEmpty.getOwners().getUsernames().contains(tst[0]));
assertTrue(trueEmpty.getBasis().getMembers().size() == 0);
assertTrue(trueEmpty.getComposite().getMembers().size() == 0);
assertTrue(trueEmpty.getExclude().getMembers().size() == 0);
assertTrue(trueEmpty.getInclude().getMembers().size() == 0);
assertTrue(trueEmpty.getOwners().getUsernames().contains(tst[0]));
}
use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingsRestController method groupingsAssignmentEmptyTest.
@Test
@WithMockUhUser(username = "iamtst05")
public void groupingsAssignmentEmptyTest() throws Exception {
GroupingAssignment groupings = mapGroupingAssignment();
assertEquals(groupings.getGroupingsIn().size(), groupings.getGroupingsToOptOutOf().size());
for (Grouping grouping : groupings.getGroupingsIn()) {
mapGSRs("/api/groupings/" + grouping.getPath() + "/optOut");
}
groupings = mapGroupingAssignment();
assertEquals(0, groupings.getGroupingsIn().size());
assertEquals(0, groupings.getGroupingsToOptOutOf().size());
}
use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingsRestController method myGroupingsTest4.
@Test
@WithMockUhUser(username = "iamtst06")
public void myGroupingsTest4() throws Exception {
boolean optedOut = false;
GroupingAssignment tst5Groupings = mapGroupingAssignment();
assertEquals(tst5Groupings.getGroupingsOptedOutOf().size(), 0);
mapGSRs("/api/groupings/" + GROUPING + "/optOut");
tst5Groupings = mapGroupingAssignment();
for (Grouping grouping : tst5Groupings.getGroupingsOptedOutOf()) {
if (grouping.getPath().contains(this.GROUPING)) {
optedOut = true;
}
}
assertTrue(optedOut);
membershipService.deleteGroupMemberByUsername(tst[0], GROUPING_EXCLUDE, tst[5]);
}
use of edu.hawaii.its.api.type.Grouping 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]));
}
Aggregations