Browse Source

修复测试用例,改一个小问题

xuexiaobo 5 years ago
parent
commit
3afda49e3b

+ 1 - 1
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/impl/ThemeLogicImpl.java

@@ -680,7 +680,7 @@ public class ThemeLogicImpl implements ThemeLogic {
         ThemeEntityRelations themeEntityRelations = themeService
                 .checkRelationBetweenThemeAndEntity(courseId, resourceId, EntityTypeEnum.COURSE_RESOURCE);
         ThemeDetail course = themeService.getThemeDetailById(courseId);
-        if (course.getIsDeleted()==1 || course.getReleased()==0){
+        if (course.getIsDeleted()==1 || course.getReleased()==1){
             throw new HttpForbiddenException("Course can't view now");
         }
         if (themeEntityRelations == null)

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

@@ -86,11 +86,14 @@ public class ThemeLogicImplTest {
         CourseResource courseResource = new CourseResource();
         CourseResourceVO courseResourceVO = new CourseResourceVO();
         ThemeEntityRelations themeEntityRelations = new ThemeEntityRelations();
-        when(courseResourceService.getCourseResourceByResourceId(1L)).thenReturn(courseResource);
+        ThemeDetail course = new ThemeDetail();
+        course.setIsDeleted(0);
+        course.setReleased(0);
+        when(themeService.getThemeDetailById(1L)).thenReturn(course);
         when(courseResourceVOWrapper.wrap(courseResource)).thenReturn(courseResourceVO);
         when(themeService.checkRelationBetweenThemeAndEntity(1L, 1L, EntityTypeEnum.COURSE_RESOURCE)).thenReturn(themeEntityRelations);
         thrown.expect(HttpForbiddenException.class);
-        thrown.expectMessage("This Course should buy and resource can't preview");
+        thrown.expectMessage("This Course should buy or hasn't open, and resource can't preview");
         themeLogic.getCourseResource(1L,1L);
     }
 }