diff --git a/src/test/java/com/kert/UserTest.java b/src/test/java/com/kert/UserTest.java index 30d6edb..4b899af 100644 --- a/src/test/java/com/kert/UserTest.java +++ b/src/test/java/com/kert/UserTest.java @@ -248,8 +248,18 @@ public void deleteUserByIdWithAdmin() throws Exception { } @Test - @DisplayName("delete user with not_admin") - public void deleteUserByIdWithNotAdmin() throws Exception { - mockMvc.perform(delete("/users/", testUser.getStudentId()).header("Authorization", "Bearer " + userJwtToken)).andExpect(status().isForbidden()); + @DisplayName("delete user with self") + public void deleteUserByIdWithSelf() throws Exception { + when(userService.getUserById(testUser.getStudentId())).thenReturn(testUser); + + mockMvc.perform(delete("/users/{studentId}", testUser.getStudentId()).header("Authorization", "Bearer " + userJwtToken)).andExpect(status().isNoContent()); + } + + @Test + @DisplayName("delete user with another") + public void deleteUserByIdWithAnother() throws Exception { + when(userService.getUserById(2L)).thenReturn(new User()); + + mockMvc.perform(delete("/users/2", testUser.getStudentId()).header("Authorization", "Bearer " + userJwtToken)).andExpect(status().isForbidden()); } }