add more tests
This commit is contained in:
parent
cbff011de4
commit
ab081d7d96
|
@ -33,11 +33,40 @@ public class RequestAndPathVariableValidationControllerIntegrationTest {
|
|||
|
||||
@Test
|
||||
public void getNameOfDayByNumberRequestParam_whenGetWithProperRequestParam_thenReturn200() throws Exception {
|
||||
mockMvc.perform(get("/public/api/1/name-for-day").param("dayOfWeek", Integer.toString(5))).andExpect(status().isOk());
|
||||
mockMvc.perform(get("/public/api/1/name-for-day").param("dayOfWeek", Integer.toString(5)))
|
||||
.andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNameOfDayByNumberRequestParam_whenGetWithInvalidRequestParam_thenReturn400() throws Exception {
|
||||
mockMvc.perform(get("/public/api/1/name-for-day").param("dayOfWeek", Integer.toString(5))).andExpect(status().isBadRequest());
|
||||
public void getNameOfDayByNumberRequestParam_whenGetWithRequestParamOutOfRange_thenReturn400() throws Exception {
|
||||
mockMvc.perform(get("/public/api/1/name-for-day").param("dayOfWeek", Integer.toString(15)))
|
||||
.andExpect(status().isBadRequest());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNameOfDayByPathVariable_whenGetWithProperRequestParam_thenReturn200() throws Exception {
|
||||
mockMvc.perform(get("/public/api/1/name-for-day/{dayOfWeek}", Integer.toString(5))).andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNameOfDayByPathVariable_whenGetWithRequestParamOutOfRange_thenReturn400() throws Exception {
|
||||
mockMvc.perform(get("/public/api/1/name-for-day/{dayOfWeek}", Integer.toString(15)))
|
||||
.andExpect(status().isBadRequest());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validStringRequestParam_whenGetWithProperRequestParam_thenReturn200() throws Exception {
|
||||
mockMvc.perform(get("/public/api/1/valid-name").param("name", "John")).andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validStringRequestParam_whenGetWithTooLongRequestParam_thenReturn400() throws Exception {
|
||||
mockMvc.perform(get("/public/api/1/valid-name").param("name", "asdfghjklqw"))
|
||||
.andExpect(status().isBadRequest());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validStringRequestParam_whenGetWithLowerCaseRequestParam_thenReturn400() throws Exception {
|
||||
mockMvc.perform(get("/public/api/1/valid-name").param("name", "john")).andExpect(status().isBadRequest());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue