use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method deleteByUsernameTest.
@Test
@WithMockUhUser
public void deleteByUsernameTest() throws Exception {
List<GroupingsServiceResult> gsrList = new ArrayList<>();
gsrList.add(new GroupingsServiceResult("SUCCESS", "delete grouping member by username"));
// new GroupingsServiceResult("SUCCESS", "delete grouping member by username")
given(membershipService.deleteGroupingMemberByUsername("user", "grouping", "user")).willReturn(gsrList);
mockMvc.perform(post("/api/groupings/grouping/user/deleteGroupingMemberByUsername").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("$[0].resultCode").value("SUCCESS")).andExpect(jsonPath("$[0].action").value("delete grouping member by username"));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser 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.groupings.controller.WithMockUhUser 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.groupings.controller.WithMockUhUser 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.groupings.controller.WithMockUhUser 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]);
}
Aggregations