1
2
3
4
5 package org.kuali.student.r2.lum.lu.service.impl;
6
7 import java.util.ArrayList;
8 import java.util.Date;
9 import java.util.List;
10 import org.junit.After;
11 import org.junit.AfterClass;
12 import org.junit.Before;
13 import org.junit.BeforeClass;
14 import org.junit.Test;
15 import static org.junit.Assert.*;
16 import org.kuali.student.r2.common.dto.ContextInfo;
17 import org.kuali.student.r2.core.versionmanagement.dto.VersionDisplayInfo;
18 import org.kuali.student.r2.lum.clu.dto.CluInfo;
19 import org.kuali.student.r2.lum.clu.dto.CluSetInfo;
20 import org.kuali.student.r2.lum.clu.service.CluService;
21 import org.kuali.student.r2.lum.util.constants.CluServiceConstants;
22
23
24
25
26
27 public class TestCluServiceMockImpl {
28
29 public TestCluServiceMockImpl() {
30 }
31
32 @BeforeClass
33 public static void setUpClass() {
34 }
35
36 @AfterClass
37 public static void tearDownClass() {
38 }
39 private CluService cluService = null;
40 private ContextInfo contextInfo = null;
41
42 protected void loadCluService () {
43 if (cluService == null) {
44 cluService = new CluServiceMockImpl();
45 }
46 }
47
48 @Before
49 public void setUp() {
50 contextInfo = new ContextInfo();
51 contextInfo.setPrincipalId("TESTUSER");
52 contextInfo.setCurrentDate(new Date());
53
54
55 loadCluService ();
56
57 CluDataLoader cluDataLoader = new CluDataLoader();
58 cluDataLoader.setCluService(cluService);
59 cluDataLoader.setContextInfo(contextInfo);
60 cluDataLoader.load();
61
62 CluSetDataLoader cluSetDataLoader = new CluSetDataLoader();
63 cluSetDataLoader.setCluService(cluService);
64 cluSetDataLoader.setContextInfo(contextInfo);
65 cluSetDataLoader.load();
66 }
67
68 @After
69 public void tearDown() {
70 }
71
72 @Test
73 public void testCluSet() throws Exception {
74 System.out.println("testCluSet");
75 CluSetInfo orig = new CluSetInfo();
76 orig.setTypeKey(CluServiceConstants.CLUSET_TYPE_CREDIT_COURSE);
77 orig.setStateKey("Active");
78 orig.setName("MyCluSet");
79 orig.setEffectiveDate(new Date());
80 orig.setIsReferenceable(Boolean.TRUE);
81 orig.setIsReusable(Boolean.FALSE);
82 List<String> cluIds = new ArrayList<String>();
83 CluInfo cluInfo1 = this.cluService.getClu("COURSE1", contextInfo);
84 cluIds.add(cluInfo1.getVersion().getVersionIndId());
85 CluInfo cluInfo2 = this.cluService.getClu("COURSE2", contextInfo);
86 cluIds.add(cluInfo2.getVersion().getVersionIndId());
87 orig.setCluIds(cluIds);
88 CluSetInfo info = this.cluService.createCluSet(orig.getTypeKey(), orig, contextInfo);
89 assertEquals(orig.getTypeKey(), info.getTypeKey());
90 assertEquals(orig.getStateKey(), info.getStateKey());
91 }
92
93 private CluInfo getCurrentCluInfoByVersionIndId(String id, ContextInfo contextInfo) {
94 VersionDisplayInfo versionDisplayInfo = null;
95 try {
96 versionDisplayInfo = this.cluService.getCurrentVersion(CluServiceConstants.CLU_NAMESPACE_URI, id, contextInfo);
97 } catch (Exception ex) {
98 throw new IllegalArgumentException("Unexpected", ex);
99 }
100 try {
101 return this.cluService.getClu(versionDisplayInfo.getId(), contextInfo);
102 } catch (Exception ex) {
103 throw new IllegalArgumentException("Unexpected", ex);
104 }
105 }
106 }