Search in sources :

Example 21 with GroupingsServiceResult

use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingsRestControllerTest method deleteByUuIDTest.

@Test
@WithMockUhUser
public void deleteByUuIDTest() throws Exception {
    List<GroupingsServiceResult> gsrList = new ArrayList<>();
    gsrList.add(new GroupingsServiceResult("SUCCESS", "delete grouping member by uuid"));
    // new GroupingsServiceResult("SUCCESS", "delete grouping member by username")
    given(membershipService.deleteGroupingMemberByUuid("user", "grouping", "user")).willReturn(gsrList);
    mockMvc.perform(post("/api/groupings/grouping/user/deleteGroupingMemberByUuid").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("$[0].resultCode").value("SUCCESS")).andExpect(jsonPath("$[0].action").value("delete grouping member by uuid"));
}
Also used : GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 22 with GroupingsServiceResult

use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingsRestControllerTest method addByUuIDTest.

@Test
@WithMockUhUser
public void addByUuIDTest() throws Exception {
    List<GroupingsServiceResult> gsrList = new ArrayList<>();
    gsrList.add(new GroupingsServiceResult("SUCCESS", "add grouping member by uuid"));
    given(membershipService.addGroupingMemberByUuid("user", "grouping", "user")).willReturn(gsrList);
    mockMvc.perform(post("/api/groupings/grouping/user/addGroupingMemberByUuid").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("$[0].resultCode").value("SUCCESS")).andExpect(jsonPath("$[0].action").value("add grouping member by uuid"));
}
Also used : GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 23 with GroupingsServiceResult

use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingsRestControllerTest method getSetOptOut.

@Test
@WithMockUhUser
public void getSetOptOut() 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", "OptOut has been added to grouping");
    GroupingsServiceResult gsr2 = new GroupingsServiceResult("SUCCESS", "OptOut has been removed from grouping");
    gsResults.add(gsr);
    gsResults2.add(gsr2);
    given(groupAttributeService.changeOptOutStatus(grouping, username, true)).willReturn(gsResults);
    given(groupAttributeService.changeOptOutStatus(grouping, username, false)).willReturn(gsResults2);
    mockMvc.perform(post("/api/groupings/grouping/true/setOptOut").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("$[0].resultCode").value("SUCCESS")).andExpect(jsonPath("$[0].action").value("OptOut has been added to grouping"));
    mockMvc.perform(post("/api/groupings/grouping/false/setOptOut").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("$[0].resultCode").value("SUCCESS")).andExpect(jsonPath("$[0].action").value("OptOut has been removed from grouping"));
}
Also used : GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 24 with GroupingsServiceResult

use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingsRestControllerTest method getOptOut.

@Test
@WithMockUhUser
public void getOptOut() throws Exception {
    final String grouping = "grouping";
    final String username = "user";
    List<GroupingsServiceResult> gsr = new ArrayList<>();
    gsr.add(new GroupingsServiceResult("SUCCESS", "delete member from include group"));
    gsr.add(new GroupingsServiceResult("SUCCESS", "add member to exclude group"));
    gsr.add(new GroupingsServiceResult("SUCCESS", "add self-opted attribute to exclude group"));
    gsr.add(new GroupingsServiceResult("SUCCESS", "remove self-opted attribute to include group"));
    gsr.add(new GroupingsServiceResult("SUCCESS", "update last-modified attribute for include group"));
    gsr.add(new GroupingsServiceResult("SUCCESS", "update last-modified attribute for exclude group"));
    given(membershipService.optOut(username, grouping)).willReturn(gsr);
    mockMvc.perform(post("/api/groupings/grouping/optOut").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("$", hasSize(6))).andExpect(jsonPath("$[0].resultCode").value("SUCCESS")).andExpect(jsonPath("$[0].action").value("delete member from include group")).andExpect(jsonPath("$[1].resultCode").value("SUCCESS")).andExpect(jsonPath("$[1].action").value("add member to exclude group")).andExpect(jsonPath("$[2].resultCode").value("SUCCESS")).andExpect(jsonPath("$[2].action").value("add self-opted attribute to exclude group")).andExpect(jsonPath("$[3].resultCode").value("SUCCESS")).andExpect(jsonPath("$[3].action").value("remove self-opted attribute to include group")).andExpect(jsonPath("$[4].resultCode").value("SUCCESS")).andExpect(jsonPath("$[4].action").value("update last-modified attribute for include group")).andExpect(jsonPath("$[5].resultCode").value("SUCCESS")).andExpect(jsonPath("$[5].action").value("update last-modified attribute for exclude group"));
}
Also used : GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 25 with GroupingsServiceResult

use of edu.hawaii.its.api.type.GroupingsServiceResult 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"));
}
Also used : GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Aggregations

GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)43 Test (org.junit.Test)32 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)32 GroupingsServiceResultException (edu.hawaii.its.api.type.GroupingsServiceResultException)15 WithMockUhUser (edu.hawaii.its.groupings.controller.WithMockUhUser)15 ArrayList (java.util.ArrayList)15 Grouping (edu.hawaii.its.api.type.Grouping)6 WsSubjectLookup (edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup)4 Person (edu.hawaii.its.api.type.Person)3 WsAddMemberResults (edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults)3 WsDeleteMemberResults (edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults)2 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)2 Group (edu.hawaii.its.api.type.Group)1 GroupingsHTTPException (edu.hawaii.its.api.type.GroupingsHTTPException)1 Membership (edu.hawaii.its.api.type.Membership)1 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)1 WsStemLookup (edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1