use of edu.hawaii.its.api.type.GroupingAssignment 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.GroupingAssignment 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.GroupingAssignment 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.GroupingAssignment in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingAssignmentService method groupingsOwnedTest.
@Test
public void groupingsOwnedTest() {
GroupingAssignment groupingAssignment = groupingAssignmentService.getGroupingAssignment(username[0]);
boolean ownsGrouping = false;
for (Grouping grouping : groupingAssignment.getGroupingsOwned()) {
if (grouping.getPath().contains(GROUPING)) {
ownsGrouping = true;
break;
}
}
assertTrue(ownsGrouping);
ownsGrouping = false;
groupingAssignment = groupingAssignmentService.getGroupingAssignment(username[4]);
for (Grouping grouping : groupingAssignment.getGroupingsOwned()) {
if (grouping.getPath().contains(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 TestGroupingAssignmentService method groupingsToOptTest.
@Test
public void groupingsToOptTest() {
GroupingAssignment groupingAssignment = groupingAssignmentService.getGroupingAssignment(username[0]);
boolean canOptIn = false;
for (Grouping grouping : groupingAssignment.getGroupingsToOptInTo()) {
if (grouping.getPath().contains(GROUPING)) {
canOptIn = true;
break;
}
}
assertFalse(canOptIn);
boolean canOptOut = false;
for (Grouping grouping : groupingAssignment.getGroupingsToOptOutOf()) {
if (grouping.getPath().contains(GROUPING)) {
canOptOut = true;
break;
}
}
assertTrue(canOptOut);
}
Aggregations