user module API

DELETE /user
DELETE /user/search
DELETE /user/subscription

Change-Id: I4d6dfa5da5ed782c6fd78b8324191fd60bf8cfff
diff --git a/src/test/java/com/g9/g9backend/controller/UserControllerTest.java b/src/test/java/com/g9/g9backend/controller/UserControllerTest.java
index 208645c..3f06b32 100644
--- a/src/test/java/com/g9/g9backend/controller/UserControllerTest.java
+++ b/src/test/java/com/g9/g9backend/controller/UserControllerTest.java
@@ -34,6 +34,9 @@
     @Mock
     private SubscriptionService subscriptionService;
 
+    @Mock
+    private SearchHistoryService searchHistoryService;
+
     private final ObjectMapper objectMapper = new ObjectMapper();
 
     @BeforeEach
@@ -169,4 +172,50 @@
                         .content(objectMapper.writeValueAsString(new Subscription(1, 2))))
                 .andExpect(status().isOk());
     }
+
+    // 注销
+    @Test
+    public void testUserDelete_success() throws Exception {
+
+        when(userService.getOne(any())).thenReturn(new User(1, "hcy", "123", null, 0, 0, null, 0, 0, 0));
+
+        mockMvc.perform(delete("/user")
+                        .param("userId", "1")
+                        .param("password", "123"))
+                .andExpect(status().isNoContent());
+    }
+
+    @Test
+    public void testUserDelete_wrongPassword() throws Exception {
+
+        when(userService.getOne(any())).thenReturn(new User(1, "hcy", "123", null, 0, 0, null, 0, 0, 0));
+
+        mockMvc.perform(delete("/user")
+                        .param("userId", "1")
+                        .param("password", "wrong"))
+                .andExpect(status().is(408));
+    }
+
+    // 删除搜索历史
+    @Test
+    public void testSearchDelete() throws Exception {
+
+        when(searchHistoryService.removeById(anyInt())).thenReturn(true);
+
+        mockMvc.perform(delete("/user/search")
+                        .param("searchHistoryId", "1"))
+                .andExpect(status().isNoContent());
+    }
+
+    // 取消关注
+    @Test
+    public void testSubscriptionDelete() throws Exception {
+
+        when(subscriptionService.remove(any())).thenReturn(true);
+
+        mockMvc.perform(delete("/user/subscription")
+                        .param("userId", "1")
+                        .param("followerId", "2"))
+                .andExpect(status().isNoContent());
+    }
 }
\ No newline at end of file