Search in sources :

Example 21 with WithMockUhUser

use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingsRestControllerTest method setOptOutFalseTest.

@Test
@WithMockUhUser
public void setOptOutFalseTest() throws Exception {
    String uri = REST_CONTROLLER_BASE + GROUPING + "/false/setOptOut";
    given(httpRequestService.makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.PUT))).willReturn(new ResponseEntity(HttpStatus.OK));
    assertNotNull(mockMvc.perform(post(uri).with(csrf())).andExpect(status().isOk()).andReturn());
    verify(httpRequestService, times(1)).makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.PUT));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 22 with WithMockUhUser

use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingsRestControllerTest method enableSyncDestTest.

@Test
@WithMockUhUser
public void enableSyncDestTest() throws Exception {
    String uri = REST_CONTROLLER_BASE + "groupings/" + GROUPING + "/syncDests/listserv/enable";
    given(httpRequestService.makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.PUT))).willReturn(new ResponseEntity(HttpStatus.OK));
    assertNotNull(mockMvc.perform(post(uri).with(csrf())).andExpect(status().isOk()).andReturn());
    verify(httpRequestService, times(1)).makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.PUT));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 23 with WithMockUhUser

use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingsRestControllerTest method optInTest.

@Test
@WithMockUhUser
public void optInTest() throws Exception {
    String uri = REST_CONTROLLER_BASE + GROUPING + "/optIn";
    given(httpRequestService.makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.PUT))).willReturn(new ResponseEntity(HttpStatus.OK));
    assertNotNull(mockMvc.perform(post(uri).with(csrf())).andExpect(status().isOk()).andReturn());
    verify(httpRequestService, times(1)).makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.PUT));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 24 with WithMockUhUser

use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingsRestControllerTest method currentUsernameTest.

@Test
@WithMockUhUser
public void currentUsernameTest() throws Exception {
    String uri = REST_CONTROLLER_BASE + "/currentUser";
    assertNotNull(mockMvc.perform(get(uri).with(csrf())).andExpect(status().isOk()).andExpect(content().json("{'username':" + USERNAME + "}")).andReturn());
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 25 with WithMockUhUser

use of edu.hawaii.its.groupings.controller.WithMockUhUser in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingsRestControllerTest method numberOfMembershipsTest.

@Test
@WithMockUhUser
public void numberOfMembershipsTest() throws Exception {
    String uri = REST_CONTROLLER_BASE + "/members/memberships";
    given(httpRequestService.makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.GET))).willReturn(new ResponseEntity(HttpStatus.OK));
    assertNotNull(mockMvc.perform(get(uri).with(csrf())).andExpect(status().isOk()).andReturn());
    verify(httpRequestService, times(1)).makeApiRequest(eq(USERNAME), anyString(), eq(HttpMethod.GET));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Aggregations

WithMockUhUser (edu.hawaii.its.groupings.controller.WithMockUhUser)69 Test (org.junit.Test)69 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)69 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)34 ResponseEntity (org.springframework.http.ResponseEntity)31 GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)15 ArrayList (java.util.ArrayList)10 Grouping (edu.hawaii.its.api.type.Grouping)9 GroupingAssignment (edu.hawaii.its.api.type.GroupingAssignment)7 Principal (java.security.Principal)3 SimplePrincipal (org.jasig.cas.client.authentication.SimplePrincipal)3 AdminListsHolder (edu.hawaii.its.api.type.AdminListsHolder)2 Realm (edu.hawaii.its.groupings.configuration.Realm)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HttpRequestService (edu.hawaii.its.api.service.HttpRequestService)1 Group (edu.hawaii.its.api.type.Group)1 GroupingsHTTPException (edu.hawaii.its.api.type.GroupingsHTTPException)1 ApiServerHandshakeException (edu.hawaii.its.groupings.exceptions.ApiServerHandshakeException)1 Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1