Commit ef9bd6a8 authored by Andreas Gärtner's avatar Andreas Gärtner
Browse files

Added test for requestParam.

parent a98e5e8a
package de.thm.arsnova.connector.web;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
......@@ -39,7 +40,7 @@ public class UniRepControllerTest {
mockMvc = standaloneSetup(controller).build();
when(service.getTreeObjects(anyInt())).thenReturn(new IliasCategoryNode());
when(service.getQuestions(anyInt())).thenReturn(new ArrayList<IliasQuestion>());
when(service.getQuestions(anyInt(), anyBoolean())).thenReturn(new ArrayList<IliasQuestion>());
}
@Test
......@@ -55,4 +56,17 @@ public class UniRepControllerTest {
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
}
@Test
public void testShouldReturnAllQuestions() throws Exception {
mockMvc.perform(get("/ilias/question/123").param("source", "ALL").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
}
@Test
public void testShouldGetClientErrorOnInvalidSourceParam() throws Exception {
mockMvc.perform(get("/ilias/question/123").param("source", "INVALID").accept(MediaType.APPLICATION_JSON))
.andExpect(status().is4xxClientError());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment