Search in sources :

Example 36 with ResultActions

use of org.springframework.test.web.servlet.ResultActions in project theskeleton by codenergic.

the class UserRestControllerTest method testUpdateUser.

@Test
public void testUpdateUser() throws Exception {
    final UserEntity user = new UserEntity().setId("user123");
    when(userAdminService.updateUser(eq("user123"), any())).thenReturn(user);
    ResultActions resultActions = mockMvc.perform(put("/api/users/user123").content("{\"username\": \"user123\", \"email\": \"user@server.com\"}").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andDo(document("user-update"));
    MockHttpServletResponse response = resultActions.andReturn().getResponse();
    assertThat(response.getContentAsByteArray()).isEqualTo(objectMapper.writeValueAsBytes(UserRestData.builder().fromUserEntity(user).build()));
    verify(userAdminService).updateUser(eq("user123"), any());
}
Also used : ResultActions(org.springframework.test.web.servlet.ResultActions) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 37 with ResultActions

use of org.springframework.test.web.servlet.ResultActions in project spring-cloud-open-service-broker by spring-cloud.

the class CatalogControllerIntegrationTest method catalogIsRetrievedWithPlatformInstanceId.

@Test
public void catalogIsRetrievedWithPlatformInstanceId() throws Exception {
    ResultActions result = this.mockMvc.perform(get("/123/v2/catalog").accept(MediaType.APPLICATION_JSON));
    assertResult(result);
}
Also used : ResultActions(org.springframework.test.web.servlet.ResultActions) Test(org.junit.Test)

Example 38 with ResultActions

use of org.springframework.test.web.servlet.ResultActions in project spring-cloud-open-service-broker by spring-cloud.

the class CatalogControllerIntegrationTest method catalogIsRetrieved.

@Test
@SuppressWarnings("unchecked")
public void catalogIsRetrieved() throws Exception {
    ResultActions result = this.mockMvc.perform(get("/v2/catalog").accept(MediaType.APPLICATION_JSON));
    assertResult(result);
}
Also used : ResultActions(org.springframework.test.web.servlet.ResultActions) Test(org.junit.Test)

Example 39 with ResultActions

use of org.springframework.test.web.servlet.ResultActions in project incubator-rya by apache.

the class RdfControllerAccumuloTest method loadDataWithVisibilities.

@Test
public void loadDataWithVisibilities() throws Exception {
    this.mockMvc.perform(post("/loadrdf").content("<http://loadDataWithVisibilities/AB> <http://loadDataWithVisibilities#pred1> \"loadDataWithVisibilities_AB\" . ").param("format", "N-Triples").param("conf.cv", "A&B")).andExpect(status().isOk());
    this.mockMvc.perform(post("/loadrdf").content("<http://loadDataWithVisibilities/BC> <http://loadDataWithVisibilities#pred1> \"loadDataWithVisibilities_BC\" . ").param("format", "N-Triples").param("conf.cv", "B&C")).andExpect(status().isOk());
    ResultActions actions;
    actions = this.mockMvc.perform(get("/queryrdf").param("query.resultformat", "xml").param("query", "SELECT (COUNT(?s) as ?c) WHERE {?s <http://loadDataWithVisibilities#pred1> ?o}")).andExpect(status().isOk());
    validateCount(actions.andReturn().getResponse(), 0);
    actions = this.mockMvc.perform(get("/queryrdf").param("query.resultformat", "xml").param("query.auth", "A").param("query", "SELECT (COUNT(?s) as ?c) WHERE {?s <http://loadDataWithVisibilities#pred1> ?o}")).andExpect(status().isOk());
    validateCount(actions.andReturn().getResponse(), 0);
    actions = this.mockMvc.perform(get("/queryrdf").param("query.resultformat", "xml").param("query.auth", "A,B").param("query", "SELECT (COUNT(?s) as ?c) WHERE {?s <http://loadDataWithVisibilities#pred1> ?o}")).andExpect(status().isOk());
    validateCount(actions.andReturn().getResponse(), 1);
    actions = this.mockMvc.perform(get("/queryrdf").param("query.resultformat", "xml").param("query.auth", "B,C").param("query", "SELECT (COUNT(?s) as ?c) WHERE {?s <http://loadDataWithVisibilities#pred1> ?o}")).andExpect(status().isOk());
    validateCount(actions.andReturn().getResponse(), 1);
    actions = this.mockMvc.perform(get("/queryrdf").param("query.resultformat", "xml").param("query.auth", "A,B,C").param("query", "SELECT (COUNT(?s) as ?c) WHERE {?s <http://loadDataWithVisibilities#pred1> ?o}")).andExpect(status().isOk());
    validateCount(actions.andReturn().getResponse(), 2);
}
Also used : ResultActions(org.springframework.test.web.servlet.ResultActions) Test(org.junit.Test)

Example 40 with ResultActions

use of org.springframework.test.web.servlet.ResultActions in project incubator-rya by apache.

the class RdfControllerAccumuloTest method updateQueryWithVisibilities.

@Test
public void updateQueryWithVisibilities() throws Exception {
    this.mockMvc.perform(get("/queryrdf").param("query", "INSERT DATA { <http://mynamespace/ProductType1_AB> <http://mynamespace#pred1> \"test_AB\" }").param("conf.cv", "A&B")).andExpect(status().isOk());
    this.mockMvc.perform(get("/queryrdf").param("query", "INSERT DATA { <http://mynamespace/ProductType1_BC> <http://mynamespace#pred1> \"test_BC\" }").param("conf.cv", "B&C")).andExpect(status().isOk());
    ResultActions actions;
    actions = this.mockMvc.perform(get("/queryrdf").param("query.resultformat", "xml").param("query", "SELECT (COUNT(?s) as ?c) WHERE {?s <http://mynamespace#pred1> ?o}")).andExpect(status().isOk());
    validateCount(actions.andReturn().getResponse(), 0);
    actions = this.mockMvc.perform(get("/queryrdf").param("query.resultformat", "xml").param("query.auth", "A").param("query", "SELECT (COUNT(?s) as ?c) WHERE {?s <http://mynamespace#pred1> ?o}")).andExpect(status().isOk());
    validateCount(actions.andReturn().getResponse(), 0);
    actions = this.mockMvc.perform(get("/queryrdf").param("query.resultformat", "xml").param("query.auth", "A,B").param("query", "SELECT (COUNT(?s) as ?c) WHERE {?s <http://mynamespace#pred1> ?o}")).andExpect(status().isOk());
    validateCount(actions.andReturn().getResponse(), 1);
    actions = this.mockMvc.perform(get("/queryrdf").param("query.resultformat", "xml").param("query.auth", "B,C").param("query", "SELECT (COUNT(?s) as ?c) WHERE {?s <http://mynamespace#pred1> ?o}")).andExpect(status().isOk());
    validateCount(actions.andReturn().getResponse(), 1);
    actions = this.mockMvc.perform(get("/queryrdf").param("query.resultformat", "xml").param("query.auth", "A,B,C").param("query", "SELECT (COUNT(?s) as ?c) WHERE {?s <http://mynamespace#pred1> ?o}")).andExpect(status().isOk());
    validateCount(actions.andReturn().getResponse(), 2);
}
Also used : ResultActions(org.springframework.test.web.servlet.ResultActions) Test(org.junit.Test)

Aggregations

ResultActions (org.springframework.test.web.servlet.ResultActions)600 Test (org.junit.Test)525 UserDetails (com.agiletec.aps.system.services.user.UserDetails)297 AbstractControllerIntegrationTest (org.entando.entando.web.AbstractControllerIntegrationTest)221 AbstractControllerTest (org.entando.entando.web.AbstractControllerTest)101 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)43 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)39 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)38 MvcResult (org.springframework.test.web.servlet.MvcResult)27 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)26 UUID (java.util.UUID)22 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)22 InputStream (java.io.InputStream)18 IEntityTypesConfigurer (com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)17 HashMap (java.util.HashMap)17 RequestBuilder (org.springframework.test.web.servlet.RequestBuilder)16 Test (org.junit.jupiter.api.Test)15 WebIntegrationBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest)14 IPage (com.agiletec.aps.system.services.page.IPage)13 Page (com.agiletec.aps.system.services.page.Page)12