Browse Source

Merge branch 'feature-case-classify' into 'Test'

Feature case classify



See merge request !1262

guochao 5 năm trước cách đây
mục cha
commit
8af5d24d0a

+ 1 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/ctrl/CaseController.java

@@ -190,6 +190,7 @@ public class CaseController extends BaseSearchController {
     @RequiresPermissions("case:view")
     @RequestMapping(value = UrlConstants.API + "case/{caseId}", method = RequestMethod.DELETE)
     public CaseExtendsVO deleteCase(@PathVariable("caseId") long caseId) {
+//        Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
         return caseLogic.delete(caseId);
     }
 

+ 3 - 4
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/impl/CaseLogicImpl.java

@@ -402,7 +402,6 @@ public class CaseLogicImpl implements CaseLogic {
 
     @Override
     public CaseExtendsVO delete(Long caseExtendsId) {
-        Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
         CaseExtends caseExtends = caseService.getCaseExtendsById(caseExtendsId);
         if (caseExtends == null) {
             throw new IllegalArgumentException("Cannot find the caseExtends");
@@ -412,9 +411,9 @@ public class CaseLogicImpl implements CaseLogic {
             throw new IllegalArgumentException("Cannot delete the public case");
         }
         // 判断是否是case的创建者
-        if (!caseExtends.getOwnerId().equals(userId)){
-            throw new IllegalArgumentException("Cannot delete the private case. Because you are not the owner of this case.");
-        }
+//        if (!caseExtends.getOwnerId().equals(userId)){
+//            throw new IllegalArgumentException("Cannot delete the private case. Because you are not the owner of this case.");
+//        }
         // 判断是否已删除
         if (caseExtends.getDeleted() == true){
             throw new IllegalArgumentException("The case is deleted");

+ 1 - 0
mooctest-site-server/src/test/java/cn/iselab/mooctest/site/web/ctrl/CaseControllerTest.java

@@ -211,6 +211,7 @@ public class CaseControllerTest extends AbstractShiroTest{
     @Test
     public void should_returnCaseExtendsVO_when_deleteCase() throws Exception{
         //arrange
+        expectCase.setVisible(false);
         when(caseLogic.delete(1L)).thenReturn(expectCase);
         //action
         MvcResult result = mockMvc.perform(delete("/api/case/1"))

+ 2 - 1
mooctest-site-server/src/test/java/cn/iselab/mooctest/site/web/logic/impl/CaseLogicImplTest.java

@@ -261,8 +261,9 @@ public class CaseLogicImplTest {
     @Test
     public void should_returnCaseExtendsVO_when_deleteCaseExtends(){
         //arrange
+        caseExtends.setVisible(false);
         when(caseService.getCaseExtendsById(11L)).thenReturn(caseExtends);
-        when(caseService.save(caseExtends)).thenReturn(caseExtends);
+        when(caseService.saveOnly(caseExtends)).thenReturn(caseExtends);
         //action
         CaseExtendsVO result = caseLogic.delete(11L);
         //assert