resource module API

DELETE /resource
DELETE /resource/like
DELETE /resource/collection

Change-Id: Icd5a47ae44c33727597d30a93bc1ab849edebc41
diff --git a/src/test/java/com/g9/g9backend/controller/ResourceControllerTest.java b/src/test/java/com/g9/g9backend/controller/ResourceControllerTest.java
index 9d0600b..9d7c908 100644
--- a/src/test/java/com/g9/g9backend/controller/ResourceControllerTest.java
+++ b/src/test/java/com/g9/g9backend/controller/ResourceControllerTest.java
@@ -201,4 +201,56 @@
                         .content(objectMapper.writeValueAsString(new UserResourceDTO(1, 1))))
                 .andExpect(status().isOk());
     }
+
+    // 删除资源
+    @Test
+    public void testDeleteResource_success() throws Exception {
+
+        // 密码正确
+        when(userService.getOne(any())).thenReturn(new User(1, "hcy", "123", null, 0, 0, null, 0, 0, 0));
+        when(resourceService.removeById(1)).thenReturn(true);
+
+        mockMvc.perform(delete("/resource")
+                        .param("resourceId", "1")
+                        .param("userId", "1")
+                        .param("password", "123"))
+                .andExpect(status().isNoContent());
+    }
+
+    @Test
+    public void testDeleteResource_wrongPassword() throws Exception {
+
+        // 密码错误
+        when(userService.getOne(any())).thenReturn(new User(1, "hcy", "123", null, 0, 0, null, 0, 0, 0));
+
+        mockMvc.perform(delete("/resource")
+                        .param("resourceId", "1")
+                        .param("userId", "1")
+                        .param("password", "wrong"))
+                .andExpect(status().is(408));
+    }
+
+    // 取消点赞
+    @Test
+    public void testLikeDelete() throws Exception {
+
+        when(userLikeService.remove(any())).thenReturn(true);
+
+        mockMvc.perform(delete("/resource/like")
+                        .param("userId", "1")
+                        .param("resourceId", "1"))
+                .andExpect(status().isNoContent());
+    }
+
+    // 取消收藏
+    @Test
+    public void testCollectionDelete() throws Exception {
+
+        when(userCollectionService.remove(any())).thenReturn(true);
+
+        mockMvc.perform(delete("/resource/collection")
+                        .param("userId", "1")
+                        .param("resourceId", "1"))
+                .andExpect(status().isNoContent());
+    }
 }
\ No newline at end of file