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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations