1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.enrollment.class2.examoffering.service.impl;
17
18 import org.junit.Ignore;
19 import org.junit.Test;
20 import org.junit.runner.RunWith;
21 import org.kuali.rice.core.api.criteria.QueryByCriteria;
22 import org.kuali.student.enrollment.exam.dto.ExamInfo;
23 import org.kuali.student.enrollment.examoffering.dto.ExamOfferingInfo;
24 import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
25 import org.kuali.student.r2.common.exceptions.DependentObjectsExistException;
26 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
27 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
28 import org.kuali.student.r2.common.exceptions.MissingParameterException;
29 import org.kuali.student.r2.common.exceptions.OperationFailedException;
30 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
31 import org.kuali.student.r2.common.exceptions.ReadOnlyException;
32 import org.kuali.student.r2.common.exceptions.VersionMismatchException;
33 import org.kuali.student.r2.common.util.RichTextHelper;
34 import org.kuali.student.r2.common.util.constants.ExamOfferingServiceConstants;
35 import org.kuali.student.r2.common.util.constants.ExamServiceConstants;
36 import org.kuali.student.r2.core.class1.type.dto.TypeInfo;
37 import org.kuali.student.r2.core.class1.type.service.TypeService;
38 import org.springframework.test.context.ContextConfiguration;
39 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
40 import org.springframework.transaction.annotation.Transactional;
41
42 import javax.annotation.Resource;
43
44 import java.util.List;
45
46 import static org.junit.Assert.assertEquals;
47 import static org.junit.Assert.assertNotNull;
48 import static org.junit.Assert.fail;
49
50 @RunWith(SpringJUnit4ClassRunner.class)
51 @ContextConfiguration(locations = {"classpath:examoffering-test-context.xml"})
52 @Transactional
53 public class TestExamOfferingServiceImplIntegration extends TestExamOfferingServiceImplConformanceExtendedCrud {
54
55 @Resource
56 private TypeService typeService;
57
58 public TypeService getTypeService() {
59 return typeService;
60 }
61
62 public void setTypeService(TypeService typeService) {
63 this.typeService = typeService;
64 }
65
66
67 @Test
68 public void testCrudExamOfferingRelation() throws DataValidationErrorException, DoesNotExistException,
69 InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException,
70 ReadOnlyException, VersionMismatchException, DependentObjectsExistException {
71
72 }
73
74
75
76 @Ignore
77 public void test_searchForExamOfferingIds_ignore() throws InvalidParameterException, MissingParameterException,
78 OperationFailedException, PermissionDeniedException {
79
80 createExamOfferingTestData();
81
82 try {
83 QueryByCriteria.Builder qbcBuilder = QueryByCriteria.Builder.create();
84 QueryByCriteria criteria = qbcBuilder.build();
85
86 List<String> examOfferingIds = this.getExamOfferingService().searchForExamOfferingIds(criteria, contextInfo);
87 assertNotNull(examOfferingIds);
88 assertEquals(1, examOfferingIds.size());
89 } catch (Exception ex) {
90 fail("Exception from service call :" + ex.getMessage());
91 }
92 }
93
94
95
96 @Ignore
97 public void test_searchForExamOfferings_ignore() throws InvalidParameterException, MissingParameterException,
98 OperationFailedException, PermissionDeniedException {
99 createExamOfferingTestData();
100
101 try {
102 QueryByCriteria.Builder qbcBuilder = QueryByCriteria.Builder.create();
103 QueryByCriteria criteria = qbcBuilder.build();
104
105 List<ExamOfferingInfo> examOfferings = this.getExamOfferingService().searchForExamOfferings(criteria, contextInfo);
106 assertNotNull(examOfferings);
107 assertEquals(1, examOfferings.size());
108 ExamOfferingInfo eoInfo = examOfferings.get(0);
109 } catch (Exception ex) {
110 fail("Exception from service call :" + ex.getMessage());
111 }
112 }
113
114
115 @Test
116 public void test_searchForExamOfferingRelationIds() throws InvalidParameterException, MissingParameterException,
117 OperationFailedException, PermissionDeniedException {
118 }
119
120
121 @Test
122 public void test_searchForExamOfferingRelations() throws InvalidParameterException, MissingParameterException,
123 OperationFailedException, PermissionDeniedException {
124 }
125
126 private void createExamOfferingTestData() {
127 createExamOfferingToSearch("typeKey01", "stateKey01", "name01", "descr01");
128 createExamOfferingToSearch(ExamOfferingServiceConstants.EXAM_OFFERING_FINAL_TYPE_KEY, "stateKey02", "name02", "descr02");
129 }
130
131 private void createExamOfferingToSearch(String typeKey, String stateKey, String name, String descr) {
132 try {
133 ExamOfferingInfo toSearch = new ExamOfferingInfo();
134 toSearch.setExamId("ExamId1");
135 toSearch.setExamPeriodId("ExamPeriodId1");
136 toSearch.setScheduleId("ScheduleId1");
137 toSearch.setTypeKey(typeKey);
138 toSearch.setStateKey(stateKey);
139 toSearch.setName(name);
140 toSearch.setDescr(RichTextHelper.buildRichTextInfo(descr, descr));
141 this.getExamOfferingService().createExamOffering(toSearch.getExamPeriodId(), toSearch.getExamId(), toSearch.getTypeKey(), toSearch, contextInfo);
142 } catch (Exception e) {
143 fail("Unable to create exam to search for :" + e.getMessage());
144 }
145 }
146 }