|
@@ -10,9 +10,12 @@ import cn.iselab.mooctest.site.web.data.CourseResourceVO;
|
|
import cn.iselab.mooctest.site.web.data.ThemeVO;
|
|
import cn.iselab.mooctest.site.web.data.ThemeVO;
|
|
import cn.iselab.mooctest.site.web.data.wrapper.CourseResourceVOWrapper;
|
|
import cn.iselab.mooctest.site.web.data.wrapper.CourseResourceVOWrapper;
|
|
import cn.iselab.mooctest.site.web.data.wrapper.ThemeVOWrapper;
|
|
import cn.iselab.mooctest.site.web.data.wrapper.ThemeVOWrapper;
|
|
|
|
+import cn.iselab.mooctest.site.web.exception.HttpForbiddenException;
|
|
import cn.iselab.mooctest.site.web.logic.ThemeLogic;
|
|
import cn.iselab.mooctest.site.web.logic.ThemeLogic;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
+import org.junit.Rule;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
+import org.junit.rules.ExpectedException;
|
|
import org.junit.runner.RunWith;
|
|
import org.junit.runner.RunWith;
|
|
import org.mockito.InjectMocks;
|
|
import org.mockito.InjectMocks;
|
|
import org.mockito.Mock;
|
|
import org.mockito.Mock;
|
|
@@ -47,6 +50,8 @@ public class ThemeLogicImplTest {
|
|
@Mock
|
|
@Mock
|
|
private ThemeVOWrapper themeVOWrapper;
|
|
private ThemeVOWrapper themeVOWrapper;
|
|
|
|
|
|
|
|
+ @Rule
|
|
|
|
+ public ExpectedException thrown= ExpectedException.none();
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void test_getTheme() {
|
|
public void test_getTheme() {
|
|
@@ -84,7 +89,8 @@ public class ThemeLogicImplTest {
|
|
when(courseResourceService.getCourseResourceByResourceId(1L)).thenReturn(courseResource);
|
|
when(courseResourceService.getCourseResourceByResourceId(1L)).thenReturn(courseResource);
|
|
when(courseResourceVOWrapper.wrap(courseResource)).thenReturn(courseResourceVO);
|
|
when(courseResourceVOWrapper.wrap(courseResource)).thenReturn(courseResourceVO);
|
|
when(themeService.checkRelationBetweenThemeAndEntity(1L, 1L, EntityTypeEnum.COURSE_RESOURCE)).thenReturn(themeEntityRelations);
|
|
when(themeService.checkRelationBetweenThemeAndEntity(1L, 1L, EntityTypeEnum.COURSE_RESOURCE)).thenReturn(themeEntityRelations);
|
|
- CourseResourceVO courseResource1 = themeLogic.getCourseResource(1L,1L);
|
|
|
|
- assertEquals(courseResource.getId(),courseResource1.getId());
|
|
|
|
|
|
+ thrown.expect(HttpForbiddenException.class);
|
|
|
|
+ thrown.expectMessage("This Course should buy and resource can't preview");
|
|
|
|
+ themeLogic.getCourseResource(1L,1L);
|
|
}
|
|
}
|
|
}
|
|
}
|