Search in sources :

Example 26 with GroupingsServiceResult

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

Example 27 with GroupingsServiceResult

use of edu.hawaii.its.api.type.GroupingsServiceResult 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"));
}
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 28 with GroupingsServiceResult

use of edu.hawaii.its.api.type.GroupingsServiceResult 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"));
}
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 29 with GroupingsServiceResult

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

Example 30 with GroupingsServiceResult

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

the class HelperServiceTest method makeGroupingsServiceResult.

@Test
public void makeGroupingsServiceResult() {
    String action = "add a member";
    String resultCode = "successfully added member";
    WsAddMemberResults gr = new WsAddMemberResults();
    WsResultMeta resultMeta = new WsResultMeta();
    resultMeta.setResultCode(resultCode);
    gr.setResultMetadata(resultMeta);
    GroupingsServiceResult gsr = helperService.makeGroupingsServiceResult(gr, action);
    assertEquals(action, gsr.getAction());
    assertEquals(resultCode, gsr.getResultCode());
}
Also used : GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) WsAddMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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