Skip to content
Snippets Groups Projects
Commit 812bd033 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

La til applikasjonen som kontekst-objekt

parent 99fef2d8
Branches
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ import todolist.core.TodoModel; ...@@ -23,7 +23,7 @@ import todolist.core.TodoModel;
import todolist.json.TodoModule; import todolist.json.TodoModule;
@AutoConfigureMockMvc @AutoConfigureMockMvc
@ContextConfiguration(classes = { TodoModelController.class, TodoModelService.class }) @ContextConfiguration(classes = { TodoModelController.class, TodoModelService.class, TodoModelApplication.class })
@WebMvcTest @WebMvcTest
public class TodoModelApplicationTest { public class TodoModelApplicationTest {
...@@ -37,15 +37,20 @@ public class TodoModelApplicationTest { ...@@ -37,15 +37,20 @@ public class TodoModelApplicationTest {
objectMapper = new ObjectMapper().registerModule(new TodoModule(false));; objectMapper = new ObjectMapper().registerModule(new TodoModule(false));;
} }
private String todoUrl(String... segments) {
String url = "/" + TodoModelController.TODO_MODEL_SERVICE_PATH;
for (String segment : segments) {
url = url + "/" + segment;
}
return url;
}
@Test @Test
public void testGet_todo() throws Exception { public void testGet_todo() throws Exception {
MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get("/todo") MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get(todoUrl())
// .content(birthday)
// .contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)) .accept(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andReturn(); .andReturn();
try { try {
TodoModel todoModel = objectMapper.readValue(result.getResponse().getContentAsString(), TodoModel.class); TodoModel todoModel = objectMapper.readValue(result.getResponse().getContentAsString(), TodoModel.class);
Iterator<AbstractTodoList> it = todoModel.iterator(); Iterator<AbstractTodoList> it = todoModel.iterator();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment