diff --git a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/user/UserControllerTest.java b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/user/UserControllerTest.java index f1cd0beae361e0bfd37aea276431386dbbdc72ce..4548693afe968eee3014091773d0c9106472c929 100644 --- a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/user/UserControllerTest.java +++ b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/user/UserControllerTest.java @@ -174,7 +174,7 @@ class UserControllerTest { @Test void login() throws Exception { - mockMvc.perform(get("/users/login") + mockMvc.perform(post("/users/login") .content(asJsonString(USER_TO_LOGIN)) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); @@ -189,6 +189,19 @@ class UserControllerTest { .andExpect(status().is4xxClientError()); } + @Test + void logout() throws Exception { + String response = mockMvc.perform(post("/users") + .content(asJsonString(USER_TO_CREATE)) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + String id = objectMapper.readValue(response, UserDto.class).getId(); + + mockMvc.perform(post("/users/logout/{id}", id)) + .andExpect(status().isOk()); + } + private static String asJsonString(final Object obj) throws JsonProcessingException { return new ObjectMapper().writeValueAsString(obj); }