use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method getSetOptIn.
@Test
@WithMockUhUser
public void getSetOptIn() throws Exception {
final String grouping = "grouping";
final String username = "user";
List<GroupingsServiceResult> gsResults = new ArrayList<>();
List<GroupingsServiceResult> gsResults2 = new ArrayList<>();
GroupingsServiceResult gsr = new GroupingsServiceResult("SUCCESS", "OptIn has been added to grouping");
GroupingsServiceResult gsr2 = new GroupingsServiceResult("SUCCESS", "OptIn has been removed from grouping");
gsResults.add(gsr);
gsResults2.add(gsr2);
given(groupAttributeService.changeOptInStatus(grouping, username, true)).willReturn(gsResults);
given(groupAttributeService.changeOptInStatus(grouping, username, false)).willReturn(gsResults2);
mockMvc.perform(post("/api/groupings/grouping/true/setOptIn").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("$[0].resultCode").value("SUCCESS")).andExpect(jsonPath("$[0].action").value("OptIn has been added to grouping"));
mockMvc.perform(post("/api/groupings/grouping/false/setOptIn").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("$[0].resultCode").value("SUCCESS")).andExpect(jsonPath("$[0].action").value("OptIn has been removed from grouping"));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method getSetListserv.
@Test
@WithMockUhUser
public void getSetListserv() throws Exception {
final String grouping = "grouping";
final String username = "user";
GroupingsServiceResult gsr = new GroupingsServiceResult("SUCCESS", "listserv has been added to grouping");
GroupingsServiceResult gsr2 = new GroupingsServiceResult("SUCCESS", "listserv has been removed from grouping");
given(groupAttributeService.changeListservStatus(grouping, username, true)).willReturn(gsr);
given(groupAttributeService.changeListservStatus(grouping, username, false)).willReturn(gsr2);
mockMvc.perform(post("/api/groupings/grouping/true/setListserv").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("resultCode").value("SUCCESS")).andExpect(jsonPath("action").value("listserv has been added to grouping"));
mockMvc.perform(post("/api/groupings/grouping/false/setListserv").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("resultCode").value("SUCCESS")).andExpect(jsonPath("action").value("listserv has been removed from grouping"));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method getAddMember.
@Test
@WithMockUhUser
public void getAddMember() throws Exception {
final String grouping = "grouping";
final String username = "user";
List<GroupingsServiceResult> gsrList = new ArrayList<>();
List<GroupingsServiceResult> gsrList2 = new ArrayList<>();
gsrList.add(new GroupingsServiceResult("SUCCESS", "add member to include group"));
gsrList2.add(new GroupingsServiceResult("SUCCESS", "add member to exclude group"));
given(membershipService.addGroupMemberByUsername(username, grouping + ":include", username)).willReturn(gsrList);
given(membershipService.addGroupMemberByUsername(username, grouping + ":exclude", username)).willReturn(gsrList2);
mockMvc.perform(post("/api/groupings/grouping/user/addMemberToIncludeGroup").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("$[0].resultCode").value("SUCCESS")).andExpect(jsonPath("$[0].action").value("add member to include group"));
mockMvc.perform(post("/api/groupings/grouping/user/addMemberToExcludeGroup").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("$[0].resultCode").value("SUCCESS")).andExpect(jsonPath("$[0].action").value("add member to exclude group"));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method addByUsernameTest.
@Test
@WithMockUhUser
public void addByUsernameTest() throws Exception {
List<GroupingsServiceResult> gsrList = new ArrayList<>();
gsrList.add(new GroupingsServiceResult("SUCCESS", "add grouping member by username"));
given(membershipService.addGroupingMemberByUsername("user", "grouping", "user")).willReturn(gsrList);
mockMvc.perform(post("/api/groupings/grouping/user/addGroupingMemberByUsername").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("$[0].resultCode").value("SUCCESS")).andExpect(jsonPath("$[0].action").value("add grouping member by username"));
}
use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingsRestController method addDeleteAdminTest.
@Test
@WithMockUhUser(username = "iamtst01")
public void addDeleteAdminTest() throws Exception {
GroupingsServiceResult addAdminResults;
GroupingsServiceResult deleteAdminResults;
try {
// addAdminResults = gc.addAdmin(tst[0], tst[0]).getBody();
addAdminResults = mapGSR("/api/groupings/" + tst[0] + "/addAdmin");
} catch (GroupingsHTTPException ghe) {
addAdminResults = new GroupingsServiceResult();
addAdminResults.setResultCode(FAILURE);
}
try {
// deleteAdminResults = gc.deleteAdmin(tst[0], tst[0]).getBody();
deleteAdminResults = mapGSR("/api/groupings/" + tst[0] + "/deleteAdmin");
} catch (GroupingsHTTPException ghe) {
deleteAdminResults = new GroupingsServiceResult();
deleteAdminResults.setResultCode(FAILURE);
}
assertTrue(addAdminResults.getResultCode().startsWith(FAILURE));
assertTrue(deleteAdminResults.getResultCode().startsWith(FAILURE));
}
Aggregations