use of org.springframework.test.web.servlet.ResultActions in project Red-Team by CSC480-18S.
the class DictionaryApplicationTests method validateTwoWordsEach.
@Test
public void validateTwoWordsEach() throws Exception {
String words = "hello,acquire,fuck,shit,lake,snow,snarfblar,xadf";
MockHttpServletRequestBuilder builder = get("/dictionary/validate?words=" + words);
builder.contentType(MediaType.APPLICATION_JSON_UTF8);
ResultActions res = mvc.perform(builder);
res.andExpect(jsonPath("$", hasSize(8)));
res.andExpect(jsonPath(String.format("$[0].valid"), is(true)));
res.andExpect(jsonPath(String.format("$[1].valid"), is(true)));
res.andExpect(jsonPath(String.format("$[2].bad"), is(true)));
res.andExpect(jsonPath(String.format("$[3].bad"), is(true)));
res.andExpect(jsonPath(String.format("$[4].special"), is(true)));
res.andExpect(jsonPath(String.format("$[5].special"), is(true)));
res.andExpect(jsonPath(String.format("$[6].valid"), is(false)));
res.andExpect(jsonPath(String.format("$[7].valid"), is(false)));
}
use of org.springframework.test.web.servlet.ResultActions in project Red-Team by CSC480-18S.
the class DictionaryApplicationTests method validateWithWhiteSpace.
/**
* performs a validation request with an entry
* containing whitespace
*/
@Test
public void validateWithWhiteSpace() throws Exception {
String word = "this has whitespace";
MockHttpServletRequestBuilder builder = get("/dictionary/validate?words=" + word);
builder.contentType(MediaType.APPLICATION_JSON_UTF8);
ResultActions res = mvc.perform(builder);
res.andExpect(jsonPath("$", hasSize(1)));
res.andExpect(jsonPath("$[0].valid", is(false)));
}
use of org.springframework.test.web.servlet.ResultActions in project Red-Team by CSC480-18S.
the class TeamTests method getAllTeams.
/**
* performs a GET request on /teams
*/
@Test
public void getAllTeams() throws Exception {
MockHttpServletRequestBuilder builder = get("/teams");
builder.contentType(MediaType.APPLICATION_JSON_UTF8);
ResultActions res = mvc.perform(builder);
res.andExpect(jsonPath("$._embedded.teams[0].name", is("Gold")));
res.andExpect(jsonPath("$._embedded.teams[1].name", is("Green")));
}
use of org.springframework.test.web.servlet.ResultActions in project community by GoogleCloudPlatform.
the class VetControllerTests method testShowResourcesVetList.
@Test
public void testShowResourcesVetList() throws Exception {
ResultActions actions = mockMvc.perform(get("/vets.json").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
actions.andExpect(content().contentType("application/json;charset=UTF-8")).andExpect(jsonPath("$.vetList[0].id").value(1));
}
use of org.springframework.test.web.servlet.ResultActions in project openlmis-stockmanagement by OpenLMIS.
the class ReasonConfigurationOptionsControllerIntegrationTest method shouldGetReasonTypes.
@Test
public void shouldGetReasonTypes() throws Exception {
// when
ResultActions resultActions = mvc.perform(get(reasonTypesApi).param(ACCESS_TOKEN, ACCESS_TOKEN_VALUE));
// then
resultActions.andExpect(status().isOk()).andDo(print()).andExpect(jsonPath("$", hasSize(2))).andExpect(jsonPath("$.[0]", is("CREDIT"))).andExpect(jsonPath("$.[1]", is("DEBIT")));
}
Aggregations