View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.lum.lu.service.impl;
17  
18  import edu.emory.mathcs.backport.java.util.Collections;
19  import org.junit.Assert;
20  import org.junit.Before;
21  import org.junit.FixMethodOrder;
22  import org.junit.Test;
23  import org.kuali.rice.core.api.criteria.PredicateFactory;
24  import org.kuali.rice.core.api.criteria.QueryByCriteria;
25  import org.kuali.student.common.test.spring.AbstractServiceTest;
26  import org.kuali.student.common.test.spring.Client;
27  import org.kuali.student.common.test.spring.Dao;
28  import org.kuali.student.common.test.spring.Daos;
29  import org.kuali.student.common.test.spring.PersistenceFileLocation;
30  import org.kuali.student.common.test.util.ContextInfoTestUtility;
31  import org.kuali.student.r2.common.dto.AmountInfo;
32  import org.kuali.student.r2.common.dto.AttributeInfo;
33  import org.kuali.student.r2.common.dto.ContextInfo;
34  import org.kuali.student.r2.common.dto.CurrencyAmountInfo;
35  import org.kuali.student.r2.common.dto.RichTextInfo;
36  import org.kuali.student.r2.common.dto.StatusInfo;
37  import org.kuali.student.r2.common.dto.TimeAmountInfo;
38  import org.kuali.student.r2.common.dto.ValidationResultInfo;
39  import org.kuali.student.r2.common.exceptions.AlreadyExistsException;
40  import org.kuali.student.r2.common.exceptions.CircularRelationshipException;
41  import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
42  import org.kuali.student.r2.common.exceptions.DependentObjectsExistException;
43  import org.kuali.student.r2.common.exceptions.DoesNotExistException;
44  import org.kuali.student.r2.common.exceptions.IllegalVersionSequencingException;
45  import org.kuali.student.r2.common.exceptions.InvalidParameterException;
46  import org.kuali.student.r2.common.exceptions.MissingParameterException;
47  import org.kuali.student.r2.common.exceptions.OperationFailedException;
48  import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
49  import org.kuali.student.r2.common.exceptions.ReadOnlyException;
50  import org.kuali.student.r2.common.exceptions.UnsupportedActionException;
51  import org.kuali.student.r2.common.exceptions.VersionMismatchException;
52  import org.kuali.student.r2.common.util.ContextUtils;
53  import org.kuali.student.r2.common.util.date.DateFormatters;
54  import org.kuali.student.r2.core.search.dto.SearchParamInfo;
55  import org.kuali.student.r2.core.search.dto.SearchRequestInfo;
56  import org.kuali.student.r2.core.search.dto.SearchResultCellInfo;
57  import org.kuali.student.r2.core.search.dto.SearchResultInfo;
58  import org.kuali.student.r2.core.search.dto.SearchResultRowInfo;
59  import org.kuali.student.r2.core.versionmanagement.dto.VersionDisplayInfo;
60  import org.kuali.student.r2.lum.clu.dto.AccreditationInfo;
61  import org.kuali.student.r2.lum.clu.dto.AdminOrgInfo;
62  import org.kuali.student.r2.lum.clu.dto.AffiliatedOrgInfo;
63  import org.kuali.student.r2.lum.clu.dto.CluAccountingInfo;
64  import org.kuali.student.r2.lum.clu.dto.CluCluRelationInfo;
65  import org.kuali.student.r2.lum.clu.dto.CluFeeInfo;
66  import org.kuali.student.r2.lum.clu.dto.CluFeeRecordInfo;
67  import org.kuali.student.r2.lum.clu.dto.CluIdentifierInfo;
68  import org.kuali.student.r2.lum.clu.dto.CluInfo;
69  import org.kuali.student.r2.lum.clu.dto.CluInstructorInfo;
70  import org.kuali.student.r2.lum.clu.dto.CluLoRelationInfo;
71  import org.kuali.student.r2.lum.clu.dto.CluPublicationInfo;
72  import org.kuali.student.r2.lum.clu.dto.CluResultInfo;
73  import org.kuali.student.r2.lum.clu.dto.CluSetInfo;
74  import org.kuali.student.r2.lum.clu.dto.CluSetTreeViewInfo;
75  import org.kuali.student.r2.lum.clu.dto.FieldInfo;
76  import org.kuali.student.r2.lum.clu.dto.LuCodeInfo;
77  import org.kuali.student.r2.lum.clu.dto.MembershipQueryInfo;
78  import org.kuali.student.r2.lum.clu.dto.ResultOptionInfo;
79  import org.kuali.student.r2.lum.clu.service.CluService;
80  import org.kuali.student.r2.lum.lu.dao.LuDao;
81  import org.kuali.student.r2.lum.util.constants.CluServiceConstants;
82  import org.springframework.beans.factory.annotation.Autowired;
83  import org.springframework.test.context.ContextConfiguration;
84  
85  import java.text.ParseException;
86  import java.util.ArrayList;
87  import java.util.Arrays;
88  import java.util.Comparator;
89  import java.util.Date;
90  import java.util.List;
91  
92  import static org.junit.Assert.assertEquals;
93  import static org.junit.Assert.assertFalse;
94  import static org.junit.Assert.assertNotNull;
95  import static org.junit.Assert.assertNull;
96  import static org.junit.Assert.assertTrue;
97  import static org.junit.Assert.fail;
98  import static org.junit.runners.MethodSorters.NAME_ASCENDING;
99  
100 @Daos({@Dao(value = "org.kuali.student.r2.lum.lu.dao.impl.LuDaoImpl", testSqlFile = "classpath:ks-lu.sql")})
101 @PersistenceFileLocation("classpath:META-INF/lu-persistence.xml")
102 @FixMethodOrder(NAME_ASCENDING)
103 @ContextConfiguration(locations = {"classpath:course-test-context.xml"})
104 public class TestCluServiceImpl extends AbstractServiceTest {
105 
106     @Autowired
107     LuDao luDao;
108     @Client(value = "org.kuali.student.r2.lum.lu.service.impl.CluServiceImpl", additionalContextFile = "classpath:clu-additional-context.xml")
109     public CluService client;
110 
111     private  CluResultInfo dto;
112     private CluResultInfo createCluResult;
113     private ContextInfo contextInfo;
114 
115     @Before
116     public void setUp(){
117         contextInfo = ContextInfoTestUtility.getEnglishContextInfo();
118         contextInfo.setPrincipalId("123");
119 
120         dto = new CluResultInfo();
121         RichTextInfo desc1 = new RichTextInfo();
122         desc1.setPlain("Plain description");
123         dto.setDescr(desc1);
124         dto.setCluId("CLU-1");
125         dto.setStateKey("Suspended");
126         dto.setTypeKey("kuali.resultType.gradeCourseResult");
127         dto.setEffectiveDate(new Date());
128         dto.setExpirationDate(new Date());
129 
130         List<ResultOptionInfo> resultOptions = new ArrayList<ResultOptionInfo>();
131         ResultOptionInfo option = new ResultOptionInfo();
132         RichTextInfo desc2 = new RichTextInfo();
133         desc2.setPlain("Plain description");
134         option.setDescr(desc2);
135         option.setEffectiveDate(new Date());
136         option.setExpirationDate(new Date());
137         option.setResultComponentId("kuali.resultComponent.grade.letter");
138         option.setStateKey("Suspended");
139         resultOptions.add(option);
140         dto.setResultOptions(resultOptions);
141     }
142 
143 
144 
145     @Test
146     public void test00Clu() throws DoesNotExistException,
147             InvalidParameterException, MissingParameterException,
148             OperationFailedException, PermissionDeniedException {
149         // getClu
150 
151         CluInfo clu = client.getClu("CLU-1", contextInfo);
152         assertNotNull(clu);
153         assertEquals(clu.getId(), "CLU-1");
154 
155         try {
156             clu = client.getClu("CLX-1", contextInfo);
157             assertTrue(false);
158         } catch (DoesNotExistException e) {
159             assertTrue(true);
160         }
161 
162         try {
163             clu = client.getClu(null, contextInfo);
164             assertTrue(false);
165         } catch (MissingParameterException e) {
166             assertTrue(true);
167         }
168 
169         // getClusByIdList
170         List<String> ids = new ArrayList<String>(1);
171         ids.add("CLU-2");
172         List<CluInfo> clus = client.getClusByIds(ids, contextInfo);
173         assertNotNull(clus);
174         assertEquals(1, clus.size());
175 
176         ids.clear();
177         ids.add("CLX-42");
178         clus = client.getClusByIds(ids, contextInfo);
179         assertTrue(clus == null || clus.size() == 0);
180 
181         try {
182             clus = client.getClusByIds(null, contextInfo);
183             assertTrue(false);
184         } catch (MissingParameterException e) {
185             assertTrue(true);
186         }
187 
188         // getCluIdsByLuType
189         ids = client.getCluIdsByLuType("luType.shell.program", "STATE2", contextInfo);
190         assertTrue(null != ids);
191         assertEquals(1, ids.size());
192         assertEquals("CLU-2", ids.get(0));
193 
194         ids = client.getCluIdsByLuType("LUTYPE-1X", "STATE1", contextInfo);
195         assertTrue(ids == null || ids.size() == 0);
196         ids = client.getCluIdsByLuType("luType.shell.course", "STATE1X", contextInfo);
197         assertTrue(ids == null || ids.size() == 0);
198 
199         try {
200             ids = client.getCluIdsByLuType(null, "STATE1", contextInfo);
201             assertTrue(false);
202         } catch (MissingParameterException e) {
203             assertTrue(true);
204         }
205 
206         try {
207             ids = client.getCluIdsByLuType("luType.shell.course", null, contextInfo);
208             assertTrue(false);
209         } catch (MissingParameterException e) {
210             assertTrue(true);
211         }
212 
213         // getClusByLuType
214         clus = client.getClusByLuType("luType.shell.program", "STATE2", contextInfo);
215         assertTrue(null != clus);
216         assertEquals(1, clus.size());
217         assertEquals("CLU-2", clus.get(0).getId());
218 
219         clus = client.getClusByLuType("LUTYPE-1X", "STATE1", contextInfo);
220         assertTrue(clus == null || clus.size() == 0);
221         clus = client.getClusByLuType("luType.shell.course", "STATE1X", contextInfo);
222         assertTrue(clus == null || clus.size() == 0);
223 
224         try {
225             clus = client.getClusByLuType(null, "STATE1", contextInfo);
226             assertTrue(false);
227         } catch (MissingParameterException e) {
228             assertTrue(true);
229         }
230 
231         try {
232             clus = client.getClusByLuType("luType.shell.course", null, contextInfo);
233             assertTrue(false);
234         } catch (MissingParameterException e) {
235             assertTrue(true);
236         }
237     }
238 
239     @Test
240     public void test01CluSet() throws DoesNotExistException,
241             InvalidParameterException, MissingParameterException,
242             OperationFailedException, PermissionDeniedException {
243         // getCluSetInfo
244         CluSetInfo csi = client.getCluSet("CLUSET-2", contextInfo);
245         assertNotNull(csi);
246 
247         csi = client.getCluSet("CLUSET-1", contextInfo);
248         assertNotNull(csi);
249 
250         try {
251             csi = client.getCluSet("CLUSETXX-42", contextInfo);
252             assertTrue(false);
253         } catch (DoesNotExistException e1) {
254             assertTrue(true);
255         }
256 
257         try {
258             csi = client.getCluSet(null, contextInfo);
259             assertTrue(false);
260         } catch (MissingParameterException e) {
261             assertTrue(true);
262         }
263 
264         // getCluSetInfoByIdList
265         List<String> ids = new ArrayList<String>(1);
266         ids.add("CLUSET-2");
267         List<CluSetInfo> cluSets = client.getCluSetsByIds(ids, contextInfo);
268         assertEquals(1, cluSets.size());
269 
270         ids.clear();
271         ids.add("CLUSETXXX-42");
272         cluSets = client.getCluSetsByIds(ids, contextInfo);
273         assertTrue(cluSets == null || cluSets.size() == 0);
274 
275         try {
276             cluSets = client.getCluSetsByIds(null, contextInfo);
277             assertTrue(false);
278         } catch (MissingParameterException e) {
279             assertTrue(true);
280         }
281 
282         // getCluIdsFromCluSet
283         ids = client.getCluIdsFromCluSet("CLUSET-2", contextInfo);
284         assertEquals(2, ids.size());
285         assertEquals("CLU-1", ids.get(0));
286 
287         try {
288             ids = client.getCluIdsFromCluSet("CLUSETXXX-42", contextInfo);
289             assertTrue(false);
290         } catch (DoesNotExistException e) {
291             assertTrue(true);
292         }
293 
294         try {
295             ids = client.getCluIdsFromCluSet(null, contextInfo);
296             assertTrue(false);
297         } catch (MissingParameterException e) {
298             assertTrue(true);
299         }
300 
301         // getAllClusInCluSet
302         List<CluInfo> clus = client.getClusFromCluSet("CLUSET-2", contextInfo);
303         assertEquals(2, clus.size());
304         assertEquals("CLU-1", clus.get(0).getId());
305 
306         try {
307             clus = client.getClusFromCluSet("CLUSETXXX-42", contextInfo);
308             assertTrue(false);
309         } catch (DoesNotExistException e) {
310             assertTrue(true);
311         }
312 
313         try {
314             clus = client.getClusFromCluSet(null, contextInfo);
315             assertTrue(false);
316         } catch (MissingParameterException e) {
317             assertTrue(true);
318         }
319 
320         clus = client.getAllClusInCluSet("CLUSET-4", contextInfo);
321         assertEquals(2, clus.size());
322 
323         try {
324             ids = client.getAllCluIdsInCluSet(null, contextInfo);
325             assertTrue(false);
326         } catch (MissingParameterException e) {
327             assertTrue(true);
328         }
329 
330         clus = client.getAllClusInCluSet("CLUSET-2", contextInfo);
331         assertEquals(3, clus.size());
332 
333         // isCluInCluSet
334         Boolean inSet = client.isCluInCluSet("CLU-2", "CLUSET-4", contextInfo);
335         assertTrue(inSet);
336 
337         inSet = client.isCluInCluSet("CLU-3", "CLUSET-4", contextInfo);
338         assertTrue(inSet);
339 
340         inSet = client.isCluInCluSet("CLUXX-42", "CLUSET-4", contextInfo);
341         assertFalse(inSet);
342 
343         inSet = client.isCluInCluSet("CLU-2", "CLUSETXX-42", contextInfo);
344         assertFalse(inSet);
345 
346         try {
347             inSet = client.isCluInCluSet(null, "CLUSET-4", contextInfo);
348             assertTrue(false);
349         } catch (MissingParameterException e) {
350             assertTrue(true);
351         }
352         try {
353             inSet = client.isCluInCluSet("CLU-2", null, contextInfo);
354             assertTrue(false);
355         } catch (MissingParameterException e) {
356             assertTrue(true);
357         }
358     }
359 
360     @Test
361     public void test02CluSetCrud() throws AlreadyExistsException,
362             DataValidationErrorException, InvalidParameterException,
363             MissingParameterException, OperationFailedException,
364             PermissionDeniedException, DoesNotExistException, ParseException,
365             VersionMismatchException, UnsupportedActionException,
366             CircularRelationshipException, ReadOnlyException {
367 
368         CluSetInfo cluSetInfo = new CluSetInfo();
369 
370         RichTextInfo desc = new RichTextInfo();
371         desc.setFormatted("<p>Formatted Desc</p>");
372         desc.setPlain("plain");
373         cluSetInfo.setTypeKey("kuali.cluSet.type.CreditCourse");
374         cluSetInfo.setStateKey("draft");
375         cluSetInfo.setAdminOrg("uuid-1234");
376         cluSetInfo.setDescr(desc);
377         cluSetInfo.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20080101"));
378         cluSetInfo.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20180101"));
379         cluSetInfo.setName("testCluSet1");
380         cluSetInfo.getCluIds().add("CLU-1");
381         cluSetInfo.getCluIds().add("CLU-2");
382 //		cluSetInfo.getCluSetIds().add("CLUSET-1");
383 //		cluSetInfo.getCluSetIds().add("CLUSET-2");
384 
385         cluSetInfo.getAttributes().add(new AttributeInfo("cluSet1ArrtKey1", "cluSet1ArrtValue1"));
386         cluSetInfo.getAttributes().add(new AttributeInfo("cluSet1ArrtKey2", "cluSet1ArrtValue2"));
387 
388         CluSetInfo createdSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", cluSetInfo, contextInfo);
389 
390         assertEquals("kuali.cluSet.type.CreditCourse", createdSet1.getTypeKey());
391         assertEquals("uuid-1234", createdSet1.getAdminOrg());
392         assertEquals("<p>Formatted Desc</p>", createdSet1.getDescr().getFormatted());
393         assertEquals("plain", createdSet1.getDescr().getPlain());
394         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20080101"), createdSet1.getEffectiveDate());
395         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20180101"), createdSet1.getExpirationDate());
396         assertEquals("testCluSet1", createdSet1.getName());
397         assertEquals("CLU-1", createdSet1.getCluIds().get(0));
398         assertEquals("CLU-2", createdSet1.getCluIds().get(1));
399 //		assertEquals("CLUSET-1", createdSet1.getCluSetIds().get(0));
400 //		assertEquals("CLUSET-2", createdSet1.getCluSetIds().get(1));
401         assertEquals("cluSet1ArrtValue1", createdSet1.getAttributeValue("cluSet1ArrtKey1"));
402         assertEquals("cluSet1ArrtValue2", createdSet1.getAttributeValue("cluSet1ArrtKey2"));
403         assertNotNull(createdSet1.getMeta().getCreateTime());
404         assertNotNull(createdSet1.getMeta().getUpdateTime());
405         assertNotNull(createdSet1.getId());
406 
407         createdSet1.setAdminOrg("uuid-1234-5678");
408         createdSet1.getDescr().setFormatted("UP<p>Formatted Desc</p>");
409         createdSet1.getDescr().setPlain("UPplain");
410         createdSet1.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20090101"));
411         createdSet1.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20190101"));
412         createdSet1.setName("UPtestCluSet1");
413         createdSet1.getCluIds().remove(1);
414         createdSet1.getCluIds().add("CLU-3");
415 //		createdSet1.getCluSetIds().remove(1);
416 //		createdSet1.getCluSetIds().add("CLUSET-3");
417         createdSet1.getAttributes().set(0, new AttributeInfo("cluSet1ArrtKey1", "UPcluSet1ArrtValue1"));
418         createdSet1.getAttributes().remove(1);
419         createdSet1.getAttributes().add(new AttributeInfo("cluSet1ArrtKey3", "cluSet1ArrtValue3"));
420 
421         CluSetInfo updatedSet1 = client.updateCluSet(createdSet1.getId(), createdSet1, contextInfo);
422 
423         assertEquals("uuid-1234-5678", updatedSet1.getAdminOrg());
424         assertEquals("UP<p>Formatted Desc</p>", updatedSet1.getDescr().getFormatted());
425         assertEquals("UPplain", updatedSet1.getDescr().getPlain());
426         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20090101"), updatedSet1.getEffectiveDate());
427         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20190101"), updatedSet1.getExpirationDate());
428         assertEquals("UPtestCluSet1", updatedSet1.getName());
429         assertEquals("CLU-1", updatedSet1.getCluIds().get(0));
430         assertEquals("CLU-3", updatedSet1.getCluIds().get(1));
431         assertEquals(2, updatedSet1.getCluIds().size());
432 //		assertEquals("CLUSET-1", updatedSet1.getCluSetIds().get(0));
433 //		assertEquals("CLUSET-3", updatedSet1.getCluSetIds().get(1));
434 //		assertEquals(2, updatedSet1.getCluSetIds().size());
435         assertEquals("UPcluSet1ArrtValue1", updatedSet1.getAttributeValue("cluSet1ArrtKey1"));
436         assertEquals("cluSet1ArrtValue3", updatedSet1.getAttributeValue("cluSet1ArrtKey3"));
437         assertEquals(2, updatedSet1.getAttributes().size());
438         assertNotNull(updatedSet1.getMeta().getUpdateTime());
439     }
440 
441     @Test
442     public void test03RemoveCluFromCluSet() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
443         CluSetInfo createCluSet = createCluSetInfo();
444         createCluSet.getCluIds().add("CLU-1");
445         createCluSet.getCluIds().add("CLU-2");
446         createCluSet.getCluIds().add("CLU-3");
447 
448         CluSetInfo createdCluSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSet, contextInfo);
449         assertEquals(3, createdCluSet1.getCluIds().size());
450 
451         StatusInfo status = client.removeCluFromCluSet("CLU-2", createdCluSet1.getId(), contextInfo);
452         assertTrue(status.getIsSuccess());
453 
454         createdCluSet1 = client.getCluSet(createdCluSet1.getId(), contextInfo);
455 
456         assertEquals(2, createdCluSet1.getCluIds().size());
457         assertTrue(createdCluSet1.getCluIds().contains("CLU-1"));
458         assertFalse(createdCluSet1.getCluIds().contains("CLU-2"));
459         assertTrue(createdCluSet1.getCluIds().contains("CLU-3"));
460     }
461 
462     @Test
463     public void test04RemoveCluSetFromCluSet() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
464         CluSetInfo createCluSet = createCluSetInfo();
465         createCluSet.getCluSetIds().add("CLUSET-1");
466         createCluSet.getCluSetIds().add("CLUSET-2");
467         createCluSet.getCluSetIds().add("CLUSET-3");
468 
469         CluSetInfo createdCluSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSet, contextInfo);
470         assertEquals(3, createdCluSet1.getCluSetIds().size());
471 
472         StatusInfo status = client.removeCluSetFromCluSet(createdCluSet1.getId(), "CLUSET-2", contextInfo);
473         assertTrue(status.getIsSuccess());
474 
475         createdCluSet1 = client.getCluSet(createdCluSet1.getId(), contextInfo);
476 
477         assertEquals(2, createdCluSet1.getCluSetIds().size());
478         assertTrue(createdCluSet1.getCluSetIds().contains("CLUSET-1"));
479         assertFalse(createdCluSet1.getCluSetIds().contains("CLUSET-2"));
480         assertTrue(createdCluSet1.getCluSetIds().contains("CLUSET-3"));
481     }
482 
483     @Test
484     public void test05DeleteCluSet() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
485         CluSetInfo createCluSet = createCluSetInfo();
486 
487         CluSetInfo createdCluSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSet, contextInfo);
488 
489         StatusInfo status = client.deleteCluSet(createdCluSet1.getId(), contextInfo);
490         assertTrue(status.getIsSuccess());
491 
492         try {
493             client.getCluSet(createdCluSet1.getId(), contextInfo);
494             fail("Should have thrown DoesNotExistException");
495         } catch (DoesNotExistException e) {
496             assertTrue(true);
497         }
498     }
499 
500     @Test
501     public void test06CluCluRelation() throws ParseException,
502             AlreadyExistsException, DataValidationErrorException,
503             DoesNotExistException, InvalidParameterException,
504             MissingParameterException, OperationFailedException,
505             PermissionDeniedException, VersionMismatchException,
506             DependentObjectsExistException {
507         List<CluCluRelationInfo> ccrs = client.getCluCluRelationsByClu("CLU-1", contextInfo);
508         assertNotNull(ccrs);
509         assertEquals(2, ccrs.size());
510 
511         ccrs = client.getCluCluRelationsByClu("CLUXX-42", contextInfo);
512         assertTrue(ccrs == null || ccrs.size() == 0);
513 
514         try {
515             ccrs = client.getCluCluRelationsByClu(null, contextInfo);
516             assertTrue(false);
517         } catch (MissingParameterException e) {
518             assertTrue(true);
519         }
520 
521     }
522 
523     // KSCM-484 TODO CluAdminOrg missing parameter state
524     @Test
525     public void test07CluCrud() throws ParseException, AlreadyExistsException,
526             DataValidationErrorException, DoesNotExistException,
527             InvalidParameterException, MissingParameterException,
528             OperationFailedException, PermissionDeniedException,
529             VersionMismatchException, DependentObjectsExistException, ReadOnlyException {
530 
531         CluInfo clu = createCluInfo();
532 
533         clu.getOfficialIdentifier().setCode("offId-divisionoffId-suffixcode");
534         clu.getOfficialIdentifier().getAttributes().add(new AttributeInfo("OfficialIdentKey", "OfficialIdentValue"));
535 
536         clu.getAlternateIdentifiers().get(0).setCode("cluId1-divisioncluId1-suffixcode");
537         clu.getAlternateIdentifiers().get(0).getAttributes().add(new AttributeInfo("AltIdentKey", "AltIdentValue"));
538         clu.getAlternateIdentifiers().get(1).setCode("cluId2-divisioncluId2-suffixcode");
539         clu.getAlternateIdentifiers().get(1).getAttributes().add(new AttributeInfo("AltIdentKey", "AltIdentValue"));
540 
541 
542         // Do the actual create call
543         CluInfo createdClu = client.createClu("luType.shell.course", clu, contextInfo);
544         createdClu = client.getClu(createdClu.getId(), contextInfo);
545         // Validate Results
546         assertNotNull(createdClu);
547 
548         assertEquals("AccountingAttrValue1", createdClu.getAccountingInfo().getAttributeValue("AccountingAttrKey1"));
549         assertEquals("AccountingAttrValue2", createdClu.getAccountingInfo().getAttributeValue("AccountingAttrKey2"));
550 
551         assertEquals("offId-divisionoffId-suffixcode", createdClu.getOfficialIdentifier().getCode());
552         assertEquals("offId-division", createdClu.getOfficialIdentifier().getDivision());
553         assertEquals("offId-level", createdClu.getOfficialIdentifier().getLevel());
554         assertEquals("offId-longName", createdClu.getOfficialIdentifier().getLongName());
555         assertEquals("offId-shortName", createdClu.getOfficialIdentifier().getShortName());
556         assertEquals("offId-state", createdClu.getOfficialIdentifier().getStateKey());
557         assertEquals("offId-type", createdClu.getOfficialIdentifier().getTypeKey());
558         assertEquals("offId-variation", createdClu.getOfficialIdentifier().getVariation());
559         assertEquals("offId-suffixcode", createdClu.getOfficialIdentifier().getSuffixCode());
560         assertEquals("offId-orgid", createdClu.getOfficialIdentifier().getOrgId());
561         assertEquals("OfficialIdentValue", createdClu.getOfficialIdentifier().getAttributeValue("OfficialIdentKey"));
562 
563         assertEquals("cluId1-divisioncluId1-suffixcode", createdClu.getAlternateIdentifiers().get(0).getCode());
564         assertEquals("cluId1-division", createdClu.getAlternateIdentifiers().get(0).getDivision());
565         assertEquals("cluId1-level", createdClu.getAlternateIdentifiers().get(0).getLevel());
566         assertEquals("cluId1-longName", createdClu.getAlternateIdentifiers().get(0).getLongName());
567         assertEquals("cluId1-shortName", createdClu.getAlternateIdentifiers().get(0).getShortName());
568         assertEquals("cluId1-state", createdClu.getAlternateIdentifiers().get(0).getStateKey());
569         assertEquals("cluId1-type", createdClu.getAlternateIdentifiers().get(0).getTypeKey());
570         assertEquals("cluId1-variation", createdClu.getAlternateIdentifiers().get(0).getVariation());
571         assertEquals("cluId1-suffixcode", createdClu.getAlternateIdentifiers().get(0).getSuffixCode());
572         assertEquals("cluId1-orgid", createdClu.getAlternateIdentifiers().get(0).getOrgId());
573         assertEquals("AltIdentValue", createdClu.getAlternateIdentifiers().get(0).getAttributeValue("AltIdentKey"));
574 
575         assertEquals("cluId2-divisioncluId2-suffixcode", createdClu.getAlternateIdentifiers().get(1).getCode());
576         assertEquals("cluId2-division", createdClu.getAlternateIdentifiers().get(1).getDivision());
577         assertEquals("cluId2-level", createdClu.getAlternateIdentifiers().get(1).getLevel());
578         assertEquals("cluId2-longName", createdClu.getAlternateIdentifiers()
579                 .get(1).getLongName());
580         assertEquals("cluId2-shortName", createdClu.getAlternateIdentifiers()
581                 .get(1).getShortName());
582         assertEquals("cluId2-state", createdClu.getAlternateIdentifiers()
583                 .get(1).getStateKey());
584         assertEquals("cluId2-type", createdClu.getAlternateIdentifiers().get(1)
585                 .getTypeKey());
586         assertEquals("cluId2-variation", createdClu.getAlternateIdentifiers()
587                 .get(1).getVariation());
588         assertEquals("cluId2-suffixcode", createdClu.getAlternateIdentifiers()
589                 .get(1).getSuffixCode());
590         assertEquals("cluId2-orgid", createdClu.getAlternateIdentifiers()
591                 .get(1).getOrgId());
592         assertEquals("AltIdentValue", createdClu.getAlternateIdentifiers().get(1).getAttributeValue("AltIdentKey"));
593 
594         assertEquals("cluAttrValue1", createdClu.getAttributeValue("cluAttrKey1"));
595         assertEquals("cluAttrValue2", createdClu.getAttributeValue("cluAttrKey2"));
596 
597         assertTrue(createdClu.getCanCreateLui());
598 
599         assertEquals(545, createdClu.getDefaultEnrollmentEstimate());
600         assertEquals(999, createdClu.getDefaultMaximumEnrollment());
601 
602         assertEquals("<p>DESC FORMATTED</p>", createdClu.getDescr()
603                 .getFormatted());
604         assertEquals("DESC PLAIN", createdClu.getDescr().getPlain());
605 
606         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20100203"), createdClu.getEffectiveDate());
607         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21001231"), createdClu.getExpirationDate());
608 
609         assertTrue(createdClu.getIsEnrollable());
610 
611         assertEquals("FeeAttrValue1", createdClu.getFeeInfo().getAttributeValue("FeeAttrKey1"));
612         assertEquals("FeeAttrValue2", createdClu.getFeeInfo().getAttributeValue("FeeAttrKey2"));
613 
614         assertEquals("Clu Fee", createdClu.getFeeInfo().getDescr().getPlain());
615         assertEquals(2, createdClu.getFeeInfo().getCluFeeRecords().size());
616         assertEquals("FEE-TYPE-X", createdClu.getFeeInfo().getCluFeeRecords().get(0).getFeeType());
617         assertEquals("RATE-TYPE-X", createdClu.getFeeInfo().getCluFeeRecords().get(0).getRateType());
618         assertEquals("Clu Fee Record", createdClu.getFeeInfo().getCluFeeRecords().get(0).getDescr().getPlain());
619         assertEquals(3, createdClu.getFeeInfo().getCluFeeRecords().get(0).getFeeAmounts().size());
620         assertEquals(Integer.valueOf(200), createdClu.getFeeInfo().getCluFeeRecords().get(0).getFeeAmounts().get(0).getCurrencyQuantity());
621         assertEquals(0, createdClu.getFeeInfo().getCluFeeRecords().get(1).getFeeAmounts().size());
622 
623         assertEquals(2, createdClu.getFeeInfo().getCluFeeRecords().get(0).getAffiliatedOrgs().size());
624         assertEquals(35l, (long) createdClu.getFeeInfo().getCluFeeRecords().get(0).getAffiliatedOrgs().get(0).getPercentage());
625 
626         assertTrue(createdClu.getIsHasEarlyDropDeadline());
627         assertTrue(createdClu.getIsHazardousForDisabledStudents());
628 
629         assertEquals("EXT-orgId-1", createdClu.getPrimaryInstructor()
630                 .getOrgId());
631         assertEquals("EXT-personId-1", createdClu.getPrimaryInstructor()
632                 .getPersonId());
633         assertEquals("PrimaryInstAttrValue1", createdClu.getPrimaryInstructor().getAttributeValue("PrimaryInstAttrKey1"));
634         assertEquals("PrimaryInstAttrValue2", createdClu.getPrimaryInstructor().getAttributeValue("PrimaryInstAttrKey2"));
635 
636         assertEquals("EXT-orgId-2", createdClu.getInstructors().get(0)
637                 .getOrgId());
638         assertEquals("EXT-personId-2", createdClu.getInstructors().get(0)
639                 .getPersonId());
640         assertEquals("Inst1AttrValue1", createdClu.getInstructors().get(0).getAttributeValue("Inst1AttrKey1"));
641         assertEquals("Inst1AttrValue2", createdClu.getInstructors().get(0).getAttributeValue("Inst1AttrKey2"));
642 
643         assertEquals("EXT-orgId-3", createdClu.getInstructors().get(1)
644                 .getOrgId());
645         assertEquals("EXT-personId-3", createdClu.getInstructors().get(1)
646                 .getPersonId());
647         assertEquals("Inst2AttrValue1", createdClu.getInstructors().get(1).getAttributeValue("Inst2AttrKey1"));
648         assertEquals("Inst2AttrValue2", createdClu.getInstructors().get(1).getAttributeValue("Inst2AttrKey2"));
649 
650         assertEquals("luCode1.key", createdClu.getLuCodes().get(0).getId());
651         assertEquals("luCode1-desc", createdClu.getLuCodes().get(0).getDescr().getPlain());
652         assertEquals("luCode1-value", createdClu.getLuCodes().get(0).getValue());
653         assertEquals("luCode1AttrValue1", createdClu.getLuCodes().get(0).getAttributeValue("luCode1AttrKey1"));
654         assertEquals("luCode1AttrValue2", createdClu.getLuCodes().get(0).getAttributeValue("luCode1AttrKey2"));
655         assertNotNull(createdClu.getLuCodes().get(0).getMeta());
656         assertNotNull(createdClu.getLuCodes().get(0).getMeta()
657                 .getVersionInd());
658         assertNotNull(createdClu.getLuCodes().get(0).getMeta()
659                 .getCreateTime());
660 
661         assertEquals("luCode2.key", createdClu.getLuCodes().get(1).getId());
662         assertEquals("luCode2-desc", createdClu.getLuCodes().get(1).getDescr().getPlain());
663         assertEquals("luCode2-value", createdClu.getLuCodes().get(1).getValue());
664         assertEquals("luCode2AttrValue1", createdClu.getLuCodes().get(1).getAttributeValue("luCode2AttrKey1"));
665         assertEquals("luCode2AttrValue2", createdClu.getLuCodes().get(1).getAttributeValue("luCode2AttrKey2"));
666         assertNotNull(createdClu.getLuCodes().get(1).getMeta());
667         assertNotNull(createdClu.getLuCodes().get(1).getMeta()
668                 .getVersionInd());
669         assertNotNull(createdClu.getLuCodes().get(1).getMeta()
670                 .getCreateTime());
671 
672 
673         assertEquals("nextReviewPeriod", createdClu.getNextReviewPeriod());
674 
675         assertEquals("offeredAtpType1", createdClu.getOfferedAtpTypes().get(0));
676         assertEquals("offeredAtpType2", createdClu.getOfferedAtpTypes().get(1));
677 
678 
679         assertEquals("http://student.kuali.org/clus", createdClu
680                 .getReferenceURL());
681 
682         assertEquals("Clu-state", createdClu.getStateKey());
683 
684         assertEquals("EXT-stdDuration-Id1", createdClu.getStdDuration()
685                 .getAtpDurationTypeKey());
686         assertEquals(Integer.valueOf(7867), createdClu.getStdDuration()
687                 .getTimeQuantity());
688 
689         assertEquals("luType.shell.course", createdClu.getTypeKey());
690 
691         assertNotNull(createdClu.getMeta());
692         assertNotNull(createdClu.getMeta().getVersionInd());
693         assertNotNull(createdClu.getMeta().getCreateTime());
694 
695         assertNotNull(createdClu.getId());
696 
697         checkCampusLocationCreate(createdClu);
698 
699         checkIntensityCreate(createdClu);
700 
701         checkAccreditationListCreate(createdClu);
702 
703         checkAdminOrgsCreate(createdClu);
704 
705         // Now Update the Clu!
706         for (int i = 0; i < createdClu.getAccountingInfo().getAttributes().size(); i++) {
707             String attributeKey = createdClu.getAccountingInfo().getAttributes().get(i).getKey();
708             if (attributeKey.equals("AccountingAttrKey1")) {
709                 createdClu.getAccountingInfo().getAttributes().set(i, new AttributeInfo("AccountingAttrKey1", "AccountingAttrValue1"));
710             } else if (attributeKey.equals("AccountingAttrKey2")) {
711                 createdClu.getAccountingInfo().getAttributes().remove(i);
712             }
713         }
714         createdClu.getAccountingInfo().getAttributes().add(new AttributeInfo("AccountingAttrKey3", "AccountingAttrValue3"));
715 
716         createdClu.getOfficialIdentifier().setCode("UPoffId-code");
717         createdClu.getOfficialIdentifier().setDivision("UPoffId-division");
718         createdClu.getOfficialIdentifier().setLevel("UPoffId-level");
719         createdClu.getOfficialIdentifier().setSuffixCode("UPoffId-suffixcode");
720         createdClu.getOfficialIdentifier().setLongName("UPoffId-longName");
721         createdClu.getOfficialIdentifier().setShortName("UPoffId-shortName");
722         createdClu.getOfficialIdentifier().setStateKey("UPoffId-state");
723         createdClu.getOfficialIdentifier().setTypeKey("UPoffId-type");
724         createdClu.getOfficialIdentifier().setVariation("UPoffId-variation");
725         createdClu.getOfficialIdentifier().getAttributes().add(new AttributeInfo("OfficialIdentKeyUptd", "OfficialIdentValueUptd"));
726 
727 
728         createdClu.getAlternateIdentifiers().get(0).setCode("UPcluId1-code");
729         createdClu.getAlternateIdentifiers().get(0).setDivision("UPcluId1-division");
730         createdClu.getAlternateIdentifiers().get(0).setLevel("UPcluId1-level");
731         createdClu.getAlternateIdentifiers().get(0).setSuffixCode("UPcluId1-suffixcode");
732         createdClu.getAlternateIdentifiers().get(0).setLongName("UPcluId1-longName");
733         createdClu.getAlternateIdentifiers().get(0).setShortName("UPcluId1-shortName");
734         createdClu.getAlternateIdentifiers().get(0).setStateKey("UPcluId1-state");
735         createdClu.getAlternateIdentifiers().get(0).setTypeKey("UPcluId1-type");
736         createdClu.getAlternateIdentifiers().get(0).setVariation("UPcluId1-variation");
737         createdClu.getAlternateIdentifiers().get(0).getAttributes().add(new AttributeInfo("AltIdentKeyUptd", "AltIdentValueUptd"));
738 
739         createdClu.getAlternateIdentifiers().remove(1);
740 
741         CluIdentifierInfo cluId3 = new CluIdentifierInfo();
742         cluId3.setCode("cluId3-code");
743         cluId3.setDivision("cluId3-division");
744         cluId3.setSuffixCode("cluId3-suffixcode");
745         cluId3.setLevel("cluId3-level");
746         cluId3.setLongName("cluId3-longName");
747         cluId3.setShortName("cluId3-shortName");
748         cluId3.setStateKey("cluId3-state");
749         cluId3.setTypeKey("cluId3-type");
750         cluId3.setVariation("cluId3-variation");
751 
752 
753         createdClu.getAlternateIdentifiers().add(cluId3);
754 
755         for (int i = 0; i < createdClu.getAttributes().size(); i++) {
756             String attributeKey = createdClu.getAttributes().get(i).getKey();
757             if (attributeKey.equals("cluAttrKey1")) {
758                 createdClu.getAttributes().set(i, new AttributeInfo("cluAttrKey1", "cluAttrValue1"));
759             } else if (attributeKey.equals("cluAttrKey2")) {
760                 createdClu.getAttributes().remove(i);
761             }
762         }
763         createdClu.getAttributes().add(new AttributeInfo("cluAttrKey3", "cluAttrValue3"));
764 
765         createdClu.setCanCreateLui(false);
766 
767         createdClu.setDefaultEnrollmentEstimate(9545);
768         createdClu.setDefaultMaximumEnrollment(9999);
769 
770         createdClu.getDescr().setFormatted("UP<p>DESC FORMATTED</p>");
771         createdClu.getDescr().setPlain("UPDESC PLAIN");
772 
773         createdClu.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20190203"));
774         createdClu.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21091231"));
775 
776         createdClu.setIsEnrollable(false);
777 
778         for (int i = 0; i < createdClu.getFeeInfo().getAttributes().size(); i++) {
779             String attributeKey = createdClu.getFeeInfo().getAttributes().get(i).getKey();
780             if (attributeKey.equals("FeeAttrKey1")) {
781                 createdClu.getFeeInfo().getAttributes().set(i, new AttributeInfo("FeeAttrKey1", "FeeAttrValue1"));
782             } else if (attributeKey.equals("FeeAttrKey2")) {
783                 createdClu.getFeeInfo().getAttributes().remove(i);
784             }
785         }
786         createdClu.getFeeInfo().getAttributes().add(new AttributeInfo("FeeAttrKey3", "FeeAttrValue3"));
787 
788         createdClu.getFeeInfo().getCluFeeRecords().get(0).getAffiliatedOrgs().remove(0);
789         createdClu.getFeeInfo().getCluFeeRecords().get(1).setFeeType("FEE-TYPE-Z");
790 
791         createdClu.setIsHasEarlyDropDeadline(false);
792 
793         createdClu.setIsHazardousForDisabledStudents(false);
794 
795         createdClu.getPrimaryInstructor().setOrgId("UPEXT-orgId-1");
796         createdClu.getPrimaryInstructor().setPersonId("UPEXT-personId-1");
797         for (int i = 0; i < createdClu.getPrimaryInstructor().getAttributes().size(); i++) {
798             String attributeKey = createdClu.getPrimaryInstructor().getAttributes().get(i).getKey();
799             if (attributeKey.equals("PrimaryInstAttrKey1")) {
800                 createdClu.getPrimaryInstructor().getAttributes().set(i, new AttributeInfo("PrimaryInstAttrKey1", "PrimaryInstAttrValue1"));
801             } else if (attributeKey.equals("PrimaryInstAttrKey2")) {
802                 createdClu.getPrimaryInstructor().getAttributes().remove(i);
803             }
804         }
805         createdClu.getPrimaryInstructor().getAttributes().add(new AttributeInfo("PrimaryInstAttrKey3", "PrimaryInstAttrValue3"));
806 
807         createdClu.getInstructors().get(0).setOrgId("UPEXT-orgId-2");
808         createdClu.getInstructors().get(0).setPersonId("UPEXT-personId-2");
809         for (int i = 0; i < createdClu.getInstructors().get(0).getAttributes().size(); i++) {
810             String attributeKey = createdClu.getInstructors().get(0).getAttributes().get(i).getKey();
811             if (attributeKey.equals("Inst1AttrKey1")) {
812                 createdClu.getInstructors().get(0).getAttributes().set(i, new AttributeInfo("Inst1AttrKey1", "Inst1AttrValue1"));
813             } else if (attributeKey.equals("Inst1AttrKey2")) {
814                 createdClu.getInstructors().get(0).getAttributes().remove(i);
815             }
816         }
817         createdClu.getInstructors().get(0).getAttributes().add(new AttributeInfo("Inst1AttrKey3", "Inst1AttrValue3"));
818 
819         createdClu.getInstructors().remove(1);
820 
821         CluInstructorInfo instructor3 = new CluInstructorInfo();
822         instructor3.setOrgId("EXT-orgId-3");
823         instructor3.setPersonId("EXT-personId-3");
824         instructor3.getAttributes().add(new AttributeInfo("Inst3AttrKey1", "Inst3AttrValue1"));
825         instructor3.getAttributes().add(new AttributeInfo("Inst3AttrKey2", "Inst3AttrValue2"));
826         createdClu.getInstructors().add(instructor3);
827         RichTextInfo UPLuCode1Desc = new RichTextInfo();
828         UPLuCode1Desc.setPlain("luCodetwodesc");
829         createdClu.getLuCodes().get(0).setDescr(UPLuCode1Desc);
830         createdClu.getLuCodes().get(0).setValue("UPluCode1-value");
831         for (int i = 0; i < createdClu.getLuCodes().get(0).getAttributes().size(); i++) {
832             String attributeKey = createdClu.getLuCodes().get(0).getAttributes().get(i).getKey();
833             if (attributeKey.equals("luCode1AttrKey1")) {
834                 createdClu.getLuCodes().get(0).getAttributes().set(i, new AttributeInfo("luCode1AttrKey1", "luCode1AttrValue1"));
835             } else if (attributeKey.equals("luCode1AttrKey2")) {
836                 createdClu.getLuCodes().get(0).getAttributes().remove(i);
837             }
838         }
839         createdClu.getLuCodes().get(0).getAttributes().add(new AttributeInfo("luCode1AttrKey3", "luCode1AttrValue3"));
840         createdClu.getLuCodes().get(0).setTypeKey("updatedType");
841 
842         createdClu.getLuCodes().remove(1);
843 
844         LuCodeInfo luCode3 = new LuCodeInfo();
845         luCode3.setId("luCode3.key");
846         RichTextInfo luCode3Desc = new RichTextInfo();
847         luCode3Desc.setPlain("luCode3-desc");
848         luCode3.setDescr(luCode3Desc);
849         luCode3.setValue("luCode3-value");
850         luCode3.getAttributes().add(new AttributeInfo("luCode3AttrKey1", "luCode3AttrValue1"));
851         luCode3.getAttributes().add(new AttributeInfo("luCode3AttrKey2", "luCode3AttrValue2"));
852         luCode3.setTypeKey("updatedType");
853         createdClu.getLuCodes().add(luCode3);
854 
855 
856         createdClu.setNextReviewPeriod("UPnextReviewPeriod");
857 
858         createdClu.getOfferedAtpTypes().remove(1);
859         createdClu.getOfferedAtpTypes().add("offeredAtpType3");
860 
861 
862         CluInstructorInfo pubInstructor3 = new CluInstructorInfo();
863         pubInstructor3.setOrgId("EXT-orgId-3");
864         pubInstructor3.setPersonId("EXT-personId-3");
865         pubInstructor3.getAttributes().add(new AttributeInfo("PubInst3AttrKey1", "PubInst3AttrValue1"));
866         pubInstructor3.getAttributes().add(new AttributeInfo("PubInst3AttrKey2", "PubInst3AttrValue2"));
867 
868         createdClu.setReferenceURL("UPhttp://student.kuali.org/clus");
869 
870         createdClu.setStateKey("UPClu-state");
871 
872         createdClu.getStdDuration().setAtpDurationTypeKey(
873                 "UPEXT-stdDuration-Id1");
874         createdClu.getStdDuration().setTimeQuantity(new Integer(97867));
875 
876         createdClu.setTypeKey("luType.shell.program");
877 
878         updateAdminOrgs(createdClu);
879 
880         updateAccreditationList(createdClu);
881 
882         updateIntensity(createdClu);
883 
884         updateCampusLocationList(createdClu);
885 
886         // Do Update
887         CluInfo updatedClu = client.updateClu(createdClu.getId(), createdClu, contextInfo);
888 
889         // Validate Results
890         assertNotNull(updatedClu);
891 
892         assertEquals("AccountingAttrValue1", updatedClu.getAccountingInfo().getAttributeValue("AccountingAttrKey1"));
893         assertEquals("AccountingAttrValue3", updatedClu.getAccountingInfo().getAttributeValue("AccountingAttrKey3"));
894         assertEquals(2, updatedClu.getAccountingInfo().getAttributes().size());
895 
896         assertEquals("UPoffId-code", updatedClu
897                 .getOfficialIdentifier().getCode());
898         assertEquals("UPoffId-division", updatedClu.getOfficialIdentifier()
899                 .getDivision());
900         assertEquals("UPoffId-level", updatedClu.getOfficialIdentifier()
901                 .getLevel());
902         assertEquals("UPoffId-suffixcode", updatedClu.getOfficialIdentifier()
903                 .getSuffixCode());
904         assertEquals("UPoffId-longName", updatedClu.getOfficialIdentifier()
905                 .getLongName());
906         assertEquals("UPoffId-shortName", updatedClu.getOfficialIdentifier()
907                 .getShortName());
908         assertEquals("UPoffId-state", updatedClu.getOfficialIdentifier()
909                 .getStateKey());
910         assertEquals("UPoffId-type", updatedClu.getOfficialIdentifier()
911                 .getTypeKey());
912         assertEquals("UPoffId-variation", updatedClu.getOfficialIdentifier()
913                 .getVariation());
914         assertEquals(2, updatedClu.getOfficialIdentifier().getAttributes().size());
915         assertEquals("OfficialIdentValueUptd", updatedClu.getOfficialIdentifier().getAttributeValue("OfficialIdentKeyUptd"));
916 
917         assertEquals("UPcluId1-code", updatedClu
918                 .getAlternateIdentifiers().get(0).getCode());
919         assertEquals("UPcluId1-division", updatedClu.getAlternateIdentifiers()
920                 .get(0).getDivision());
921         assertEquals("UPcluId1-level", updatedClu.getAlternateIdentifiers()
922                 .get(0).getLevel());
923         assertEquals("UPcluId1-suffixcode", updatedClu
924                 .getAlternateIdentifiers().get(0).getSuffixCode());
925         assertEquals("UPcluId1-longName", updatedClu.getAlternateIdentifiers()
926                 .get(0).getLongName());
927         assertEquals("UPcluId1-shortName", updatedClu.getAlternateIdentifiers()
928                 .get(0).getShortName());
929         assertEquals("UPcluId1-state", updatedClu.getAlternateIdentifiers()
930                 .get(0).getStateKey());
931         assertEquals("UPcluId1-type", updatedClu.getAlternateIdentifiers().get(
932                 0).getTypeKey());
933         assertEquals("UPcluId1-variation", updatedClu.getAlternateIdentifiers()
934                 .get(0).getVariation());
935         assertEquals(2, updatedClu.getAlternateIdentifiers().get(0).getAttributes().size());
936         assertEquals("AltIdentValueUptd", createdClu.getAlternateIdentifiers().get(0).getAttributeValue("AltIdentKeyUptd"));
937 
938         assertEquals("cluId3-code", updatedClu
939                 .getAlternateIdentifiers().get(1).getCode());
940         assertEquals("cluId3-division", updatedClu.getAlternateIdentifiers()
941                 .get(1).getDivision());
942         assertEquals("cluId3-level", updatedClu.getAlternateIdentifiers()
943                 .get(1).getLevel());
944         assertEquals("cluId3-suffixcode", updatedClu.getAlternateIdentifiers()
945                 .get(1).getSuffixCode());
946         assertEquals("cluId3-longName", updatedClu.getAlternateIdentifiers()
947                 .get(1).getLongName());
948         assertEquals("cluId3-shortName", updatedClu.getAlternateIdentifiers()
949                 .get(1).getShortName());
950         assertEquals("cluId3-state", updatedClu.getAlternateIdentifiers()
951                 .get(1).getStateKey());
952         assertEquals("cluId3-type", updatedClu.getAlternateIdentifiers().get(1)
953                 .getTypeKey());
954         assertEquals("cluId3-variation", updatedClu.getAlternateIdentifiers()
955                 .get(1).getVariation());
956 
957         assertEquals(2, updatedClu.getAlternateIdentifiers().size());
958 
959         assertEquals("cluAttrValue1", updatedClu.getAttributeValue("cluAttrKey1"));
960         assertEquals("cluAttrValue3", updatedClu.getAttributeValue("cluAttrKey3"));
961         assertEquals(2, updatedClu.getAttributes().size());
962 
963         assertFalse(updatedClu.getCanCreateLui());
964 
965         assertEquals(9545, updatedClu.getDefaultEnrollmentEstimate());
966         assertEquals(9999, updatedClu.getDefaultMaximumEnrollment());
967 
968         assertEquals("UP<p>DESC FORMATTED</p>", updatedClu.getDescr()
969                 .getFormatted());
970         assertEquals("UPDESC PLAIN", updatedClu.getDescr().getPlain());
971 
972         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20190203"), updatedClu.getEffectiveDate());
973         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21091231"), updatedClu.getExpirationDate());
974 
975         assertFalse(updatedClu.getIsEnrollable());
976 
977         assertEquals("FeeAttrValue1", updatedClu.getFeeInfo().getAttributeValue("FeeAttrKey1"));
978         assertEquals("FeeAttrValue3", updatedClu.getFeeInfo().getAttributeValue("FeeAttrKey3"));
979         assertEquals(2, updatedClu.getFeeInfo().getAttributes().size());
980 
981         assertEquals(2, createdClu.getFeeInfo().getCluFeeRecords().size());
982         assertEquals("FEE-TYPE-Z", createdClu.getFeeInfo().getCluFeeRecords().get(1).getFeeType());
983 
984         assertEquals(1, createdClu.getFeeInfo().getCluFeeRecords().get(0).getAffiliatedOrgs().size());
985         assertEquals(65l, (long) createdClu.getFeeInfo().getCluFeeRecords().get(0).getAffiliatedOrgs().get(0).getPercentage());
986 
987         assertFalse(updatedClu.getIsHasEarlyDropDeadline());
988         assertFalse(updatedClu.getIsHazardousForDisabledStudents());
989 
990         assertEquals("UPEXT-orgId-1", updatedClu.getPrimaryInstructor()
991                 .getOrgId());
992         assertEquals("UPEXT-personId-1", updatedClu.getPrimaryInstructor()
993                 .getPersonId());
994         assertEquals("PrimaryInstAttrValue1", updatedClu.getPrimaryInstructor().getAttributeValue("PrimaryInstAttrKey1"));
995         assertEquals("PrimaryInstAttrValue3", updatedClu.getPrimaryInstructor().getAttributeValue("PrimaryInstAttrKey3"));
996         assertEquals(2, updatedClu.getPrimaryInstructor().getAttributes()
997                 .size());
998 
999         assertEquals(2, updatedClu.getInstructors().size());
1000 
1001         assertEquals("UPEXT-orgId-2", updatedClu.getInstructors().get(0)
1002                 .getOrgId());
1003         assertEquals("UPEXT-personId-2", updatedClu.getInstructors().get(0)
1004                 .getPersonId());
1005         assertEquals("Inst1AttrValue1", updatedClu.getInstructors().get(0).getAttributeValue("Inst1AttrKey1"));
1006         assertEquals("Inst1AttrValue3", updatedClu.getInstructors().get(0).getAttributeValue("Inst1AttrKey3"));
1007         assertEquals(2, updatedClu.getInstructors().get(0).getAttributes()
1008                 .size());
1009 
1010         assertEquals("EXT-orgId-3", updatedClu.getInstructors().get(1)
1011                 .getOrgId());
1012         assertEquals("EXT-personId-3", updatedClu.getInstructors().get(1)
1013                 .getPersonId());
1014         assertEquals("Inst3AttrValue1", updatedClu.getInstructors().get(1).getAttributeValue("Inst3AttrKey1"));
1015         assertEquals("Inst3AttrValue2", updatedClu.getInstructors().get(1).getAttributeValue("Inst3AttrKey2"));
1016         assertEquals(2, updatedClu.getInstructors().get(1).getAttributes()
1017                 .size());
1018 
1019         assertEquals(2, updatedClu.getLuCodes().size());
1020 
1021         assertEquals("luCode1.key", updatedClu.getLuCodes().get(0).getId());
1022         assertEquals("luCodetwodesc", updatedClu.getLuCodes().get(0).getDescr().getPlain());
1023         assertEquals("UPluCode1-value", updatedClu.getLuCodes().get(0)
1024                 .getValue());
1025         assertEquals("luCode1AttrValue1", updatedClu.getLuCodes().get(0).getAttributeValue("luCode1AttrKey1"));
1026         assertEquals("luCode1AttrValue3", updatedClu.getLuCodes().get(0).getAttributeValue("luCode1AttrKey3"));
1027         assertEquals(2, updatedClu.getLuCodes().get(0).getAttributes().size());
1028         assertNotNull(updatedClu.getLuCodes().get(0).getMeta());
1029         assertNotNull(updatedClu.getLuCodes().get(0).getMeta()
1030                 .getVersionInd());
1031         assertNotNull(updatedClu.getLuCodes().get(0).getMeta()
1032                 .getCreateTime());
1033         assertNotNull(updatedClu.getLuCodes().get(0).getMeta()
1034                 .getUpdateTime());
1035 
1036         // id is nulled and subsequently set to a uuid
1037         //assertEquals("luCode3.key", updatedClu.getLuCodes().get(1).getId());
1038         assertEquals("luCode3-desc", updatedClu.getLuCodes().get(1).getDescr().getPlain());
1039         assertEquals("luCode3-value", updatedClu.getLuCodes().get(1).getValue());
1040         assertEquals("luCode3AttrValue1", updatedClu.getLuCodes().get(1).getAttributeValue("luCode3AttrKey1"));
1041         assertEquals("luCode3AttrValue2", updatedClu.getLuCodes().get(1).getAttributeValue("luCode3AttrKey2"));
1042         assertNotNull(updatedClu.getLuCodes().get(1).getMeta());
1043         assertNotNull(updatedClu.getLuCodes().get(1).getMeta()
1044                 .getVersionInd());
1045         assertNotNull(updatedClu.getLuCodes().get(1).getMeta()
1046                 .getCreateTime());
1047         assertNotNull(updatedClu.getLuCodes().get(1).getMeta()
1048                 .getUpdateTime());
1049 
1050         assertEquals("UPnextReviewPeriod", updatedClu.getNextReviewPeriod());
1051 
1052         assertEquals("offeredAtpType1", updatedClu.getOfferedAtpTypes().get(0));
1053         assertEquals("offeredAtpType3", updatedClu.getOfferedAtpTypes().get(1));
1054         assertEquals(2, updatedClu.getOfferedAtpTypes().size());
1055 
1056 
1057         assertEquals("UPhttp://student.kuali.org/clus", updatedClu
1058                 .getReferenceURL());
1059 
1060         assertEquals("UPClu-state", updatedClu.getStateKey());
1061 
1062         assertEquals("UPEXT-stdDuration-Id1", updatedClu.getStdDuration()
1063                 .getAtpDurationTypeKey());
1064         assertEquals(Integer.valueOf(97867), updatedClu.getStdDuration()
1065                 .getTimeQuantity());
1066 
1067         assertEquals("luType.shell.program", updatedClu.getTypeKey());
1068 
1069         assertEquals(false, updatedClu.getIsEnrollable());
1070         assertEquals(false, updatedClu.getIsHazardousForDisabledStudents());
1071 
1072         assertNotNull(updatedClu.getMeta());
1073         assertNotNull(updatedClu.getMeta().getVersionInd());
1074         assertNotNull(updatedClu.getMeta().getCreateTime());
1075         assertNotNull(updatedClu.getMeta().getUpdateTime());
1076 
1077         assertEquals(createdClu.getId(), updatedClu.getId());
1078 
1079         checkAdminOrgUpdate(updatedClu);
1080 
1081         checkAccreditationListUpdate(updatedClu);
1082 
1083         checkCampusLocationUpdate(updatedClu);
1084 
1085         checkIntensityUpdate(updatedClu);
1086 
1087         // Test Optimistic locking
1088         try {
1089             updatedClu = client.updateClu(createdClu.getId(), createdClu, contextInfo);
1090             fail("Should have thrown VersionMismatchException");
1091         } catch (VersionMismatchException e) {
1092 
1093         }
1094 
1095         // Test Delete
1096         try {
1097             client.getClu(createdClu.getId(), contextInfo);
1098         } catch (DoesNotExistException e) {
1099             fail("Should not have thrown DoesNotExistException");
1100         }
1101 
1102         StatusInfo status = client.deleteClu(createdClu.getId(), contextInfo);
1103         assertTrue(status.getIsSuccess());
1104 
1105         try {
1106             client.getClu(createdClu.getId(), contextInfo);
1107             fail("Should have thrown DoesNotExistException");
1108         } catch (DoesNotExistException e) {
1109 
1110         }
1111 
1112     }
1113 
1114     @Test
1115     public void test08CluCluRelationCrud() throws Exception {
1116 
1117         final CluCluRelationInfo cluCluRelationInfo = new CluCluRelationInfo();
1118 
1119         final Date effectiveDate = DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20080101"),
1120                 expirationDate = DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20100101");
1121         cluCluRelationInfo.setEffectiveDate(effectiveDate);
1122         cluCluRelationInfo.setExpirationDate(expirationDate);
1123         cluCluRelationInfo.setIsCluRelationRequired(true);
1124         cluCluRelationInfo.setStateKey("hello");
1125 
1126         if (cluCluRelationInfo.getAttributes() == null) {
1127             cluCluRelationInfo.setAttributes(new ArrayList<AttributeInfo>());
1128         }
1129         cluCluRelationInfo.getAttributes().add(new AttributeInfo("clucluAttrKey1", "clucluAttrValue1"));
1130         cluCluRelationInfo.getAttributes().add(new AttributeInfo("clucluAttrKey2", "clucluAttrValue2"));
1131         cluCluRelationInfo.getAttributes().add(new AttributeInfo("clucluAttrKey3", "clucluAttrValue3"));
1132 
1133         CluCluRelationInfo created = client.createCluCluRelation("CLU-1",
1134                 "CLU-2", "luLuType.type1", cluCluRelationInfo, contextInfo);
1135 
1136         assertEquals(effectiveDate, created.getEffectiveDate());
1137         assertEquals(expirationDate, created.getExpirationDate());
1138         assertEquals(true, created.getIsCluRelationRequired());
1139         assertEquals("hello", created.getStateKey());
1140         assertEquals("CLU-1", created.getCluId());
1141         assertEquals("CLU-2", created.getRelatedCluId());
1142         assertEquals("luLuType.type1", created.getTypeKey());
1143         assertEquals("clucluAttrValue1", created.getAttributeValue("clucluAttrKey1"));
1144         assertEquals("clucluAttrValue2", created.getAttributeValue("clucluAttrKey2"));
1145         assertEquals("clucluAttrValue3", created.getAttributeValue("clucluAttrKey3"));
1146         assertNotNull(created.getId());
1147         assertNotNull(created.getMeta().getCreateTime());
1148         assertNotNull(created.getMeta().getVersionInd());
1149 
1150         created.getAttributes().remove(1);
1151         created.getAttributes().set(1, new AttributeInfo("clucluAttrKey3", "clucluAttrValue3-A"));
1152         created.getAttributes().add(new AttributeInfo("clucluAttrKey4", "clucluAttrValue4"));
1153         created.setCluId("CLU-2");
1154         created.setEffectiveDate(expirationDate);
1155         created.setExpirationDate(effectiveDate);
1156         created.setIsCluRelationRequired(false);
1157         created.setRelatedCluId("CLU-3");
1158         created.setStateKey("updated-hello");
1159         created.setTypeKey("luLuType.type2");
1160 
1161         CluCluRelationInfo updated = client.updateCluCluRelation(created.getId(), created, contextInfo);
1162 
1163         assertEquals(expirationDate, updated.getEffectiveDate());
1164         assertEquals(effectiveDate, updated.getExpirationDate());
1165         assertEquals(false, updated.getIsCluRelationRequired());
1166         assertEquals("updated-hello", updated.getStateKey());
1167         assertEquals("CLU-2", updated.getCluId());
1168         assertEquals("CLU-3", updated.getRelatedCluId());
1169         assertEquals("luLuType.type2", updated.getTypeKey());
1170         assertEquals("clucluAttrValue1", updated.getAttributeValue("clucluAttrKey1"));
1171         assertNull(updated.getAttributeValue("clucluAttrKey2"));
1172         assertEquals("clucluAttrValue3-A", updated.getAttributeValue("clucluAttrKey3"));
1173         assertEquals("clucluAttrValue4", updated.getAttributeValue("clucluAttrKey4"));
1174         assertNotNull(created.getId());
1175         assertNotNull(created.getMeta().getCreateTime());
1176         assertNotNull(created.getMeta().getVersionInd());
1177 
1178         // Test Delete
1179         try {
1180             client.getCluCluRelation(created.getId(), contextInfo);
1181         } catch (DoesNotExistException e) {
1182             fail("Should not have thrown DoesNotExistException");
1183         }
1184 
1185         StatusInfo status = client.deleteCluCluRelation(created.getId(), contextInfo);
1186         assertTrue(status.getIsSuccess());
1187 
1188         try {
1189             client.getCluCluRelation(created.getId(), contextInfo);
1190             fail("Should have thrown DoesNotExistException");
1191         } catch (DoesNotExistException e) {
1192 
1193         }
1194 
1195         List<String> relatedCluIdsByCluId = client.getRelatedCluIdsByCluAndRelationType(
1196                 "CLU-1", "luLuType.type1", contextInfo);
1197 
1198         assertEquals(2, relatedCluIdsByCluId.size());
1199         assertTrue(relatedCluIdsByCluId.contains("CLU-2"));
1200         assertTrue(relatedCluIdsByCluId.contains("CLU-3"));
1201 
1202         List<CluInfo> relatedClusByCluId = client.getRelatedClusByCluAndRelationType(
1203                 "CLU-1", "luLuType.type1", contextInfo);
1204         assertEquals(2, relatedClusByCluId.size());
1205     }
1206 
1207     /* LuiService not used in CM     @Test
1208      public void test09LuiLuiRelationCrud() throws Exception {
1209 
1210          ContextInfo contextInfo = ContextInfoTestUtility.getEnglishContextInfo();
1211 
1212          LuiLuiRelationInfo luiLuiRelationInfo = new LuiLuiRelationInfo();
1213 
1214          luiLuiRelationInfo.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20080101"));
1215          luiLuiRelationInfo.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20100101"));
1216          luiLuiRelationInfo.setState("hello");
1217          luiLuiRelationInfo.setType("goodbye");
1218          luiLuiRelationInfo.getAttributes().add(new AttributeInfo("luiluiAttrKey1","luiluiAttrValue1"));
1219          luiLuiRelationInfo.getAttributes().add(new AttributeInfo("luiluiAttrKey2","luiluiAttrValue2"));
1220 
1221          LuiLuiRelationInfo created = atpService.createLuiLuiRelation("LUI-1",
1222                  "LUI-2", "luLuType.type1", luiLuiRelationInfo, contextInfo);
1223 
1224          assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20080101"), created.getEffectiveDate());
1225          assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20100101"), created.getExpirationDate());
1226          assertEquals("hello", created.getState());
1227          assertEquals("luLuType.type1", created.getType());
1228          assertEquals("LUI-1", created.getLuiId());
1229          assertEquals("LUI-2", created.getRelatedLuiId());
1230          assertEquals("luiluiAttrValue1", created.getAttributeValue("luiluiAttrKey1"));
1231          assertEquals("luiluiAttrValue2", created.getAttributeValue("luiluiAttrKey2"));
1232          assertNotNull(created.getId());
1233          assertNotNull(created.getMetaInfo().getCreateTime());
1234          assertNotNull(created.getMetaInfo().getVersionInd());
1235 
1236          created.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20980101"));
1237          created.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20190101"));
1238          created.setState("sawyer");
1239          created.setType("luLuType.type2");
1240          created.setLuiId("LUI-2");
1241          created.setRelatedLuiId("LUI-3");
1242          created.getAttributes().add(new AttributeInfo("luiluiAttrKey1", "UPluiluiAttrValue1"));
1243          created.getAttributes().remove("luiluiAttrKey2");
1244          created.getAttributes().add(new AttributeInfo("luiluiAttrKey3", "luiluiAttrValue3"));
1245 
1246          LuiLuiRelationInfo updated = atpService.updateLuiLuiRelation(created
1247                  .getId(), created, contextInfo);
1248 
1249          assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20980101"), updated.getEffectiveDate());
1250          assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20190101"), updated.getExpirationDate());
1251          assertEquals("sawyer", updated.getState());
1252          assertEquals("luLuType.type2", updated.getType());
1253          assertEquals("LUI-2", updated.getLuiId());
1254          assertEquals("LUI-3", updated.getRelatedLuiId());
1255          assertEquals("UPluiluiAttrValue1", updated.getAttributeValue("luiluiAttrKey1"));
1256          assertEquals("luiluiAttrValue3", updated.getAttributeValue("luiluiAttrKey3"));
1257          assertEquals(2, updated.getAttributes().size());
1258          assertEquals(created.getId(), updated.getId());
1259          assertNotNull(updated.getMetaInfo().getUpdateTime());
1260 
1261          try {
1262              updated = atpService.updateLuiLuiRelation(created.getId(), created, contextInfo);
1263              fail("Should have thrown VersionMismatchException");
1264          } catch (VersionMismatchException e) {
1265          }
1266 
1267          try {
1268              atpService.getLuiLuiRelation(created.getId(), contextInfo);
1269          } catch (DoesNotExistException e) {
1270              fail("Should not have thrown DoesNotExistException");
1271          }
1272 
1273          StatusInfo status = R1R2ConverterUtil.convert(atpService.deleteLuiLuiRelation(updated.getId(), contextInfo), StatusInfo.class);
1274 
1275          assertTrue(status.getIsSuccess());
1276 
1277          try {
1278              atpService.getLuiLuiRelation(created.getId(), contextInfo);
1279              fail("Should have thrown DoesNotExistException");
1280          } catch (DoesNotExistException e) {
1281 
1282          }
1283 
1284          // TestFind
1285          List<LuiLuiRelationInfo> relations = atpService
1286                  .getLuiLuiRelationsByLui("LUI-1", contextInfo);
1287          assertEquals(2, relations.size());
1288          relations = atpService.getLuiLuiRelationsByLui("LUI-2", contextInfo);
1289          assertEquals(1, relations.size());
1290          relations = atpService.getLuiLuiRelationsByLui("LUI-3", contextInfo);
1291          assertTrue(relations == null || relations.size() == 0);
1292 
1293          List<String> relatedLuiIdsByLuiId = atpService.getRelatedLuiIdsByLuiId(
1294                  "LUI-1", "luLuType.type1", contextInfo);
1295          assertEquals(2, relatedLuiIdsByLuiId.size());
1296          assertTrue(relatedLuiIdsByLuiId.contains("LUI-2"));
1297          assertTrue(relatedLuiIdsByLuiId.contains("LUI-3"));
1298 
1299          List<LuiInfo> relatedLuisByLuiId = atpService.getRelatedLuisByLuiId(
1300                  "LUI-1", "luLuType.type1", contextInfo);
1301          assertEquals(2, relatedLuisByLuiId.size());
1302 
1303      }
1304 
1305      @Test
1306      public void test10GetLuisByIdList() throws DoesNotExistException,
1307              InvalidParameterException, MissingParameterException,
1308              OperationFailedException {
1309 
1310          List<LuiInfo> luiInfos;
1311          try {
1312              luiInfos = atpService.getLuisByIds(null, contextInfo);
1313              fail("CluService.getLuiByIdList() did not throw MissingParameterException for null Lui ID");
1314          } catch (MissingParameterException mpe) {
1315          } catch (Exception e) {
1316              fail("CluService.getLuiByIdList() threw unexpected "
1317                      + e.getClass().getSimpleName() + " for null Lui ID");
1318          }
1319          luiInfos = atpService.getLuisByIds(Arrays.asList("Not a LUI ID",
1320                  "Another one that ain't"), contextInfo);
1321          assertTrue(luiInfos == null || luiInfos.size() == 0);
1322 
1323          luiInfos = atpService.getLuisByIds(Arrays.asList("LUI-1", "LUI-4"), contextInfo);
1324          Collections.sort(luiInfos, new Comparator<LuiInfo>() {
1325              @Override
1326              public int compare(LuiInfo o1, LuiInfo o2) {
1327                  return o1.getId().compareTo(o2.getId());
1328              }
1329          });
1330          assertEquals("CLU-1", luiInfos.get(0).getCluId());
1331          assertEquals("CLU-2", luiInfos.get(1).getCluId());
1332      }
1333 
1334      @Test
1335      public void test11LuiCrud() throws AlreadyExistsException,
1336              DataValidationErrorException, DoesNotExistException,
1337              InvalidParameterException, MissingParameterException,
1338              OperationFailedException, PermissionDeniedException,
1339              ParseException, DependentObjectsExistException {
1340 
1341          ContextInfo contextInfo = ContextInfoTestUtility.getEnglishContextInfo();
1342 
1343          LuiInfo luiInfo;
1344 
1345          // Read
1346          try {
1347              luiInfo = atpService.getLui("notARealLui", contextInfo);
1348              fail("CluService.getLui() did not throw DoesNotExistException for non-existent Lui");
1349          } catch (DoesNotExistException dnee) {
1350          } catch (Exception e) {
1351              fail("CluService.getLui() threw unexpected "
1352                      + e.getClass().getSimpleName() + " for null Lui ID");
1353          }
1354          try {
1355              luiInfo = atpService.getLui(null, contextInfo);
1356              fail("CluService.getLui() did not throw MissingParameterException for null Lui ID");
1357          } catch (MissingParameterException mpe) {
1358          }
1359          luiInfo = atpService.getLui("LUI-1", contextInfo);
1360          assertEquals("CLU-1", luiInfo.getCluId());
1361 
1362          // Create
1363          luiInfo = new LuiInfo();
1364 
1365          luiInfo.setLuiCode("LUI Test Code");
1366          luiInfo.setMaxSeats(100);
1367          luiInfo.setState("Test Lui State");
1368          luiInfo.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20101203"));
1369          luiInfo.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20801231"));
1370          luiInfo.getAttributes().add(new AttributeInfo("luiAttrKey1", "luiAttrValue1"));
1371          luiInfo.getAttributes().add(new AttributeInfo("luiAttrKey2", "luiAttrValue2"));
1372 
1373          LuiInfo createdLui = atpService.createLui("CLU-2", "ATP-3", luiInfo, contextInfo);
1374 
1375          assertEquals("ATP-3", createdLui.getAtpId());
1376          assertEquals("LUI Test Code", createdLui.getLuiCode());
1377          assertEquals(100L, (long) createdLui.getMaxSeats());
1378          assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20101203"), luiInfo.getEffectiveDate());
1379          assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20801231"), luiInfo.getExpirationDate());
1380          assertEquals("CLU-2", createdLui.getCluId());
1381          assertEquals(2, createdLui.getAttributes().size());
1382          assertEquals("luiAttrValue1", createdLui.getAttributeValue(createdLui.getAttributes(),"luiAttrKey1"));
1383          assertEquals("luiAttrValue2", createdLui.getAttributeValue(createdLui.getAttributes(),"luiAttrKey2"));
1384 
1385          // update
1386          createdLui.setAtpId("ATP-2");
1387          createdLui.setCluId("CLU-1");
1388          createdLui.setLuiCode("LUI Test Code Update");
1389          createdLui.setMaxSeats(75);
1390          createdLui.setState("Test Lui State Update");
1391          createdLui.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20111203"));
1392          createdLui.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20811231"));
1393          createdLui.getAttributes().add(new AttributeInfo("luiAttrKey1", "luiAttrValue1Updated"));
1394          createdLui.getAttributes().add(new AttributeInfo("luiAttrKey2", "luiAttrValue2Updated"));
1395 
1396          LuiInfo updatedLui = null;
1397          try {
1398              updatedLui = atpService.updateLui(createdLui.getId(), createdLui, contextInfo);
1399          } catch (VersionMismatchException vme) {
1400              fail("CluService.updateLui() threw unexpected VersionMismatchException");
1401          }
1402 
1403          // confirm update worked
1404          assertTrue(null != updatedLui);
1405          assertEquals("ATP-2", updatedLui.getAtpId());
1406          assertEquals("CLU-1", updatedLui.getCluId());
1407          assertEquals("LUI Test Code Update", updatedLui.getLuiCode());
1408          assertEquals(75L, (long) createdLui.getMaxSeats());
1409          assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20111203"), updatedLui.getEffectiveDate());
1410          assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20811231"), updatedLui.getExpirationDate());
1411          assertEquals(2, updatedLui.getAttributes().size());
1412          assertEquals("luiAttrValue1Updated", updatedLui.getAttributeValue(updatedLui.getAttributes(),"luiAttrKey1"));
1413          assertEquals("luiAttrValue2Updated", updatedLui.getAttributeValue(updatedLui.getAttributes(),"luiAttrKey2"));
1414 
1415          // optimistic locking working?
1416          try {
1417              atpService.updateLui(createdLui.getId(), createdLui, contextInfo);
1418              fail("CluService.updateLui did not throw expected VersionMismatchException");
1419          } catch (VersionMismatchException e) {
1420          }
1421 
1422          // delete what we created
1423          atpService.deleteLui(createdLui.getId(), contextInfo);
1424          // and try it again
1425          try {
1426              atpService.deleteLui(createdLui.getId(), contextInfo);
1427              fail("CluService.deleteLui() of previously-delete Lui did not throw expected DoesNotExistException");
1428          } catch (DoesNotExistException dnee) {
1429          }
1430      }
1431 
1432      @Test
1433      public void test12GetLuiIdsByCluId() throws DoesNotExistException,
1434              InvalidParameterException, MissingParameterException,
1435              OperationFailedException {
1436 
1437          List<String> luiIds = null;
1438          try {
1439              luiIds = atpService.getLuiIdsByCluId(null, contextInfo);
1440              fail("CluService.getLuiIdsByCluId() did not throw MissingParameterException for null Clu ID");
1441          } catch (MissingParameterException e) {
1442          }
1443          luiIds = atpService.getLuiIdsByCluId("CLU-1", contextInfo);
1444 
1445          Collections.sort(luiIds);
1446 
1447          assertTrue(null != luiIds);
1448          assertEquals(3, luiIds.size());
1449 
1450          assertEquals("LUI-1", luiIds.get(0));
1451          assertEquals("LUI-3", luiIds.get(2));
1452          luiIds = atpService.getLuiIdsByCluId("CLU-2", contextInfo);
1453          assertEquals(1, luiIds.size());
1454          luiIds = atpService.getLuiIdsByCluId("Non-existent Clu", contextInfo);
1455          assertTrue(null == luiIds || luiIds.size() == 0);
1456      }
1457 
1458      @Test
1459      public void test13GetLuiIdsInAtpByCluId() throws DoesNotExistException,
1460              InvalidParameterException, OperationFailedException,
1461              MissingParameterException {
1462 
1463          List<String> luiIds = null;
1464          try {
1465              luiIds = atpService.getLuiIdsInAtpByCluId(null, "ATP-1", contextInfo);
1466              fail("CluService.getLuiIdsInAtpByCluId() did not throw MissingParameterException for null Clu ID");
1467          } catch (MissingParameterException e) {
1468          }
1469          try {
1470              luiIds = atpService.getLuiIdsInAtpByCluId("CLU-1", null, contextInfo);
1471              fail("CluService.getLuiIdsInAtpByCluId() did not throw MissingParameterException for null AtpKey");
1472          } catch (MissingParameterException e) {
1473          }
1474          luiIds = atpService.getLuiIdsInAtpByCluId("CLU-1", "ATP-2", contextInfo);
1475          Collections.sort(luiIds);
1476          assertTrue(null != luiIds);
1477          assertEquals(2, luiIds.size());
1478          assertEquals("LUI-2", luiIds.get(0));
1479          assertEquals("LUI-3", luiIds.get(1));
1480          luiIds = atpService.getLuiIdsInAtpByCluId("CLU-1", "ATP-1", contextInfo);
1481          assertEquals(1, luiIds.size());
1482          luiIds = atpService.getLuiIdsInAtpByCluId("Non-existent Clu", "ATP-2", contextInfo);
1483          assertTrue(null == luiIds || luiIds.size() == 0);
1484          luiIds = atpService.getLuiIdsInAtpByCluId("CLU-2", "Non-existent ATP", contextInfo);
1485          assertTrue(null == luiIds || luiIds.size() == 0);
1486      }*/
1487 
1488     /* KSCM Unsupported in KSCM     @Test
1489      public void test14GetLuLuRelationTypeInfo() throws OperationFailedException,
1490              DoesNotExistException, MissingParameterException, InvalidParameterException, PermissionDeniedException {
1491 
1492          TypeInfo luLuRelTypeInfo;
1493 
1494          try {
1495              atpService.getLuLuRelationType(null, contextInfo);
1496              fail("CluService.getLuLuRelationTypeInfo() did not throw MissingParameterException for null LuLuRelationType key");
1497          } catch (MissingParameterException e) {
1498          }
1499          luLuRelTypeInfo = atpService.getLuLuRelationType("luLuType.type1", contextInfo);
1500          assertEquals("bob", luLuRelTypeInfo.getName());
1501          luLuRelTypeInfo = atpService.getLuLuRelationType("luLuType.type2", contextInfo);
1502          assertEquals("my desc2", luLuRelTypeInfo.getDescr());
1503          assertEquals("rev name2", luLuRelTypeInfo.getName());
1504          assertEquals("rev desc2", luLuRelTypeInfo.getDescr());
1505          try {
1506              atpService.getLuLuRelationType("Non-existent LuLuRelationType", contextInfo);
1507              fail("CluService.getLuLuRelationTypeInfo() did not throw DoesNotExistException when retrieving non-existent LuLuRelationType");
1508          } catch (DoesNotExistException dnee) {
1509          }
1510      }*/
1511 
1512     /* KSCM Unsupported in KSCM    @Test
1513      public void test15GetLuLuRelationTypeInfos() throws OperationFailedException,
1514              DoesNotExistException, MissingParameterException {
1515 
1516          List<TypeInfo> luLuRelTypeInfos;
1517          luLuRelTypeInfos = atpService.getLuLuRelationTypes(contextInfo);
1518          Collections.sort(luLuRelTypeInfos,
1519                  new Comparator<LuLuRelationTypeInfo>() {
1520                      @Override
1521                      public int compare(LuLuRelationTypeInfo o1,
1522                              LuLuRelationTypeInfo o2) {
1523                          return o1.getId().compareTo(o2.getId());
1524                      }
1525                  });
1526          assertEquals(13, luLuRelTypeInfos.size());
1527          assertEquals("kuali.lu.lu.relation.type.hasCoreProgram", luLuRelTypeInfos.get(0).getKey());
1528      }*/
1529 
1530     /* LuiService not used in CM      @Test
1531      public void test16UpdateLuiState() throws DataValidationErrorException,
1532              DoesNotExistException, InvalidParameterException,
1533              OperationFailedException, PermissionDeniedException,
1534              ParseException, AlreadyExistsException, MissingParameterException,
1535              DependentObjectsExistException {
1536 
1537          try {
1538              atpService.updateLuiState(null, "Suspended", contextInfo);
1539              fail("CluService.updateLuiState() did not throw MissingParameterException for null Lui ID");
1540          } catch (MissingParameterException e) {
1541          }
1542          try {
1543              atpService.updateLuiState("LUI-1", null, contextInfo);
1544              fail("CluService.updateLuiState() did not throw MissingParameterException for null state");
1545          } catch (MissingParameterException e) {
1546          }
1547 
1548          // create a Lui whose state we'll update. Create a new one so its
1549          // MetaInfo gets created in prePersist()
1550          LuiInfo luiInfo = new LuiInfo();
1551 
1552          luiInfo.setLuiCode("LUI Test Code");
1553          luiInfo.setMaxSeats(100);
1554          luiInfo.setState("Approved");
1555          luiInfo.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20101203"));
1556          luiInfo.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20801231"));
1557          luiInfo.getAttributes().add(new AttributeInfo("luiAttrKey1", "luiAttrValue1"));
1558          luiInfo.getAttributes().add(new AttributeInfo("luiAttrKey2", "luiAttrValue2"));
1559 
1560          LuiInfo createdLui = atpService.createLui("CLU-2", "ATP-3", luiInfo, contextInfo);
1561          // make sure the db's in the state we expect
1562          assertEquals("Approved", createdLui.getState());
1563 
1564          // update and confirm it was updated
1565          LuiInfo updatedLui = atpService.updateLuiState(createdLui.getId(),
1566                  "Active", contextInfo);
1567          assertEquals("Active", updatedLui.getState());
1568 
1569          // and now explicitly retrieve it without a call to updateLuiState and
1570          // confirm same
1571          updatedLui = atpService.getLui(createdLui.getId(), contextInfo);
1572          assertEquals("Active", updatedLui.getState());
1573 
1574          // and delete it to keep db consistent for other tests
1575          atpService.deleteLui(updatedLui.getId(), contextInfo);
1576      }
1577 
1578      @Test
1579      public void test17GetLuisByRelation() throws DoesNotExistException,
1580              InvalidParameterException, MissingParameterException,
1581              OperationFailedException {
1582 
1583          List<LuiInfo> luis = atpService.getLuisByRelation("LUI-1", "luLuType.type1", contextInfo);
1584          assertTrue(luis == null || luis.size() == 0);
1585          luis = atpService.getLuisByRelation("LUI-2", "luLuType.type1", contextInfo);
1586          Collections.sort(luis, new Comparator<LuiInfo>() {
1587              @Override
1588              public int compare(LuiInfo o1, LuiInfo o2) {
1589                  return o1.getId().compareTo(o2.getId());
1590              }
1591          });
1592          assertEquals(1, luis.size());
1593          assertEquals("LUI-1", luis.get(0).getId());
1594      }
1595 
1596      @Test
1597      public void test18GetLuiIdsByRelation() throws DoesNotExistException,
1598              InvalidParameterException, MissingParameterException,
1599              OperationFailedException {
1600 
1601          List<String> luis = atpService.getLuiIdsByRelation("LUI-1",	"luLuType.type1", contextInfo);
1602          assertTrue(luis == null || luis.size() == 0);
1603          luis = atpService.getLuiIdsByRelation("LUI-2", "luLuType.type1", contextInfo);
1604          Collections.sort(luis);
1605          assertEquals(1, luis.size());
1606          assertEquals("LUI-1", luis.get(0));
1607      }*/
1608 
1609     @Test
1610     public void test19OutcomeLO() throws AlreadyExistsException,
1611             DoesNotExistException, InvalidParameterException,
1612             MissingParameterException, OperationFailedException,
1613             PermissionDeniedException, DependentObjectsExistException,
1614             ParseException, DataValidationErrorException,
1615             VersionMismatchException, ReadOnlyException {
1616 
1617         CluLoRelationInfo reltnInfo = new CluLoRelationInfo();
1618         reltnInfo.setCluId("CLU-1");
1619         reltnInfo.setLoId("LO-1");
1620         reltnInfo.setStateKey("FINAL");
1621         reltnInfo.setTypeKey("kuali.lu.lo.relation.type.includes");
1622         reltnInfo.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20101203"));
1623         reltnInfo.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20801231"));
1624 
1625         CluLoRelationInfo crReltnInfo = client.createCluLoRelation("CLU-1",
1626                 "LO-1", "kuali.lu.lo.relation.type.includes", reltnInfo, contextInfo);
1627 
1628         assertEquals(crReltnInfo.getCluId(), "CLU-1");
1629         assertEquals(crReltnInfo.getLoId(), "LO-1");
1630         assertEquals(crReltnInfo.getStateKey(), "FINAL");
1631         assertEquals(crReltnInfo.getTypeKey(), "kuali.lu.lo.relation.type.includes");
1632 
1633         try {
1634             reltnInfo.setCluId("MISSING CLU");
1635             client.createCluLoRelation("MISSING CLU", "LO-1", "kuali.lu.lo.relation.type.includes",
1636                     reltnInfo, contextInfo);
1637             fail("Should have thrown DoesNotExistException");
1638         } catch (DoesNotExistException e) {
1639 
1640         }
1641 
1642         CluLoRelationInfo gtReltnInfo = client.getCluLoRelation(crReltnInfo
1643                 .getId(), contextInfo);
1644 
1645         assertEquals(gtReltnInfo.getCluId(), "CLU-1");
1646         assertEquals(gtReltnInfo.getLoId(), "LO-1");
1647         assertEquals(gtReltnInfo.getStateKey(), "FINAL");
1648         assertEquals(gtReltnInfo.getTypeKey(), "kuali.lu.lo.relation.type.includes");
1649 
1650         CluLoRelationInfo reltnInfo1 = new CluLoRelationInfo();
1651         reltnInfo1.setCluId("CLU-1");
1652         reltnInfo1.setLoId("LO-2");
1653         reltnInfo1.setStateKey("FINAL");
1654         reltnInfo1.setTypeKey("kuali.lu.lo.relation.type.includes");
1655         reltnInfo1.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20101203"));
1656         reltnInfo1.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20801231"));
1657 
1658         CluLoRelationInfo crReltnInfo1 = client.createCluLoRelation("CLU-1",
1659                 "LO-2", "kuali.lu.lo.relation.type.includes", reltnInfo1, contextInfo);
1660 
1661         List<CluLoRelationInfo> reltns = client.getCluLoRelationsByClu("CLU-1", contextInfo);
1662         assertEquals(2, reltns.size());
1663 
1664         List<CluLoRelationInfo> reltns1 = client.getCluLoRelationsByLo("LO-1", contextInfo);
1665         assertEquals(1, reltns1.size());
1666         assertEquals(reltns1.get(0).getCluId(), "CLU-1");
1667 
1668         // Test update relation
1669         crReltnInfo1.setStateKey("NEW");
1670         CluLoRelationInfo updateReltn = client.updateCluLoRelation(crReltnInfo1
1671                 .getId(), crReltnInfo1, contextInfo);
1672         assertEquals("NEW", updateReltn.getStateKey());
1673 
1674         StatusInfo status = client.deleteCluLoRelation(crReltnInfo.getId(), contextInfo);
1675         assertTrue(status.getIsSuccess());
1676 
1677         status = client.deleteCluLoRelation(updateReltn.getId(), contextInfo);
1678         assertTrue(status.getIsSuccess());
1679 
1680     }
1681 
1682     /* KSCM Unsupported in KSCM     @Test
1683      public void test20ResultUsageType() throws DoesNotExistException,
1684              InvalidParameterException, MissingParameterException,
1685              OperationFailedException, PermissionDeniedException {
1686 
1687          TypeInfo lrType = atpService.getResultUsageType("lrType.finalGrade", contextInfo);
1688          assertEquals("Final Grade", lrType.getName());
1689          List<TypeInfo> lrTypes = atpService.getResultUsageTypes(contextInfo);
1690          assertEquals(2, lrTypes.size());
1691 
1692      }*/
1693 
1694     @Test
1695     public void test21GetClusByRelation() throws AlreadyExistsException,
1696             DataValidationErrorException, DoesNotExistException,
1697             InvalidParameterException, MissingParameterException,
1698             OperationFailedException, PermissionDeniedException,
1699             ParseException, VersionMismatchException {
1700         List<CluInfo> clus = client
1701                 .getClusByRelatedCluAndRelationType("CLU-1", "luLuType.type1", contextInfo);
1702         assertNotNull(clus);
1703         assertEquals(2, clus.size());
1704 
1705         clus = client.getClusByRelatedCluAndRelationType("CLUXX-2", "luLuType.type1", contextInfo);
1706         assertTrue(clus == null || clus.size() == 0);
1707 
1708         clus = client.getClusByRelatedCluAndRelationType("CLU-2", "luLuType.type1XX", contextInfo);
1709         assertTrue(clus == null || clus.size() == 0);
1710 
1711         try {
1712             clus = client.getClusByRelatedCluAndRelationType(null, "luLuType.type1XX", contextInfo);
1713             assertTrue(false);
1714         } catch (MissingParameterException e) {
1715             assertTrue(true);
1716         }
1717         try {
1718             clus = client.getClusByRelatedCluAndRelationType("CLU-2", null, contextInfo);
1719             assertTrue(false);
1720         } catch (MissingParameterException e) {
1721             assertTrue(true);
1722         }
1723 
1724         List<String> ids = client.getCluIdsByRelatedCluAndRelationType("CLU-2", "luLuType.type1", contextInfo);
1725         assertNotNull(ids);
1726         assertEquals(1, ids.size());
1727 
1728         ids = client.getCluIdsByRelatedCluAndRelationType("CLUXX-2", "luLuType.type1", contextInfo);
1729         assertTrue(null == ids || ids.size() == 0);
1730 
1731         ids = client.getCluIdsByRelatedCluAndRelationType("CLU-2", "luLuType.type1XX", contextInfo);
1732         assertTrue(null == ids || ids.size() == 0);
1733 
1734         try {
1735             ids = client.getCluIdsByRelatedCluAndRelationType(null, "luLuType.type1XX", contextInfo);
1736             assertTrue(false);
1737         } catch (MissingParameterException e) {
1738             assertTrue(true);
1739         }
1740         try {
1741             ids = client.getCluIdsByRelatedCluAndRelationType("CLU-2", null, contextInfo);
1742             assertTrue(false);
1743         } catch (MissingParameterException e) {
1744             assertTrue(true);
1745         }
1746     }
1747 
1748     @Test
1749     public void test22SearchForResults() throws AlreadyExistsException,
1750             DataValidationErrorException, DoesNotExistException,
1751             InvalidParameterException, MissingParameterException,
1752             OperationFailedException, PermissionDeniedException,
1753             ParseException, VersionMismatchException {
1754         List<SearchParamInfo> queryParamValueList = new ArrayList<SearchParamInfo>(
1755                 0);
1756         SearchRequestInfo searchRequest = new SearchRequestInfo();
1757         searchRequest.setSearchKey("lu.search.clus");
1758         searchRequest.setParams(queryParamValueList);
1759         SearchResultInfo clus = client.search(searchRequest, ContextInfoTestUtility.getEnglishContextInfo());
1760         Collections.sort(clus.getRows(), new Comparator<SearchResultRowInfo>() {
1761             @Override
1762             public int compare(SearchResultRowInfo o1, SearchResultRowInfo o2) {
1763                 return o1.getCells().get(0).getValue().compareTo(
1764                         o2.getCells().get(0).getValue());
1765             }
1766         });
1767         assertNotNull(clus);
1768         assertEquals(111, clus.getRows().size());
1769         SearchResultRowInfo result = clus.getRows().get(0);
1770         assertNotNull(result);
1771 
1772         List<SearchResultCellInfo> resultCells = result.getCells();
1773         assertNotNull(resultCells);
1774         assertEquals(3, resultCells.size());
1775 
1776         SearchResultCellInfo resultCell = resultCells.get(0);
1777         assertEquals("lu.resultColumn.cluId", resultCell.getKey());
1778         assertEquals("00000000-a389-4fd0-b349-1e649c20fd08", resultCell
1779                 .getValue());
1780         resultCell = resultCells.get(1);
1781         assertEquals("lu.resultColumn.cluOfficialIdentifier.longName",
1782                 resultCell.getKey());
1783         assertEquals("Advanced Applied Linear Algebra", resultCell.getValue());
1784     }
1785 
1786 
1787     @Test
1788     public void test23SearchForClus() throws AlreadyExistsException,
1789             DataValidationErrorException, DoesNotExistException,
1790             InvalidParameterException, MissingParameterException,
1791             OperationFailedException, PermissionDeniedException,
1792             ParseException, VersionMismatchException {
1793 
1794         List<SearchParamInfo> queryParamValueList = new ArrayList<SearchParamInfo>();
1795         SearchParamInfo typeParm = new SearchParamInfo();
1796         typeParm.setKey("lu.queryParam.luOptionalType");
1797         typeParm.getValues().add("kuali.lu.type.CreditCourse");
1798         queryParamValueList.add(typeParm);
1799         SearchParamInfo stateParm = new SearchParamInfo();
1800         stateParm.setKey("lu.queryParam.luOptionalState");
1801         stateParm.getValues().add("Approved");
1802         stateParm.getValues().add("Active");
1803         stateParm.getValues().add("Retired");
1804         queryParamValueList.add(stateParm);
1805 
1806         SearchRequestInfo searchRequest = new SearchRequestInfo();
1807         searchRequest.setSearchKey("lu.search.current");
1808         searchRequest.setParams(queryParamValueList);
1809         SearchResultInfo clus = client.search(searchRequest, ContextInfoTestUtility.getEnglishContextInfo());
1810         assertEquals(98, clus.getRows().size());
1811     }
1812 
1813     @Test
1814     public void test24SearchCourseLevelRanges() throws MissingParameterException, PermissionDeniedException, OperationFailedException, InvalidParameterException {
1815         List<SearchParamInfo> queryParamValueList = new ArrayList<SearchParamInfo>();
1816         SearchParamInfo courseLevelsParam = new SearchParamInfo();
1817         courseLevelsParam.setKey("lu.queryParam.luOptionalCrsNoRange");
1818         courseLevelsParam.getValues().add("100 -200");
1819         queryParamValueList.add(courseLevelsParam);
1820         SearchRequestInfo searchRequest = new SearchRequestInfo();
1821         searchRequest.setSearchKey("lu.search.generic");
1822         searchRequest.setParams(queryParamValueList);
1823         SearchResultInfo clus = client.search(searchRequest, ContextInfoTestUtility.getEnglishContextInfo());
1824         Collections.sort(clus.getRows(), new Comparator<SearchResultRowInfo>() {
1825             @Override
1826             public int compare(SearchResultRowInfo o1, SearchResultRowInfo o2) {
1827                 return o1.getCells().get(0).getValue().compareTo(
1828                         o2.getCells().get(0).getValue());
1829             }
1830         });
1831         assertNotNull(clus);
1832     }
1833 
1834     @Test
1835     public void test25CluValidation() throws ParseException, AlreadyExistsException,
1836             DataValidationErrorException, DoesNotExistException,
1837             InvalidParameterException, MissingParameterException,
1838             OperationFailedException, PermissionDeniedException,
1839             VersionMismatchException, DependentObjectsExistException {
1840 
1841         CluInfo clu = new CluInfo();
1842 
1843         CluAccountingInfo accountingInfo = new CluAccountingInfo();
1844         accountingInfo.getAttributes().add(new AttributeInfo("AccountingAttrKey1", "AccountingAttrValue1"));
1845         accountingInfo.getAttributes().add(new AttributeInfo("AccountingAttrKey2", "AccountingAttrValue2"));
1846         clu.setAccountingInfo(accountingInfo);
1847 
1848         CluIdentifierInfo officialIdentifier = new CluIdentifierInfo();
1849         officialIdentifier.setTypeKey("kuali.lu.type.CreditCourse.identifier.official");
1850         officialIdentifier.setStateKey("active");
1851         officialIdentifier.setCode("offIdcode");
1852         officialIdentifier.setDivision("offIddivision");
1853         officialIdentifier.setLevel("offIdlevel");
1854         officialIdentifier.setLongName("offIdlongName");
1855         // ERROR: Short name should be less than 20 chars
1856         officialIdentifier.setShortName("offId-shortName-should-be-longer-than-twenty-characters");
1857         officialIdentifier.setVariation("offIdvariation");
1858         officialIdentifier.setSuffixCode("offIdsuffixcode");
1859         officialIdentifier.setOrgId("offIdorgid");
1860         clu.setOfficialIdentifier(officialIdentifier);
1861 
1862         CluIdentifierInfo cluId1 = new CluIdentifierInfo();
1863         cluId1.setTypeKey("kuali.lu.type.CreditCourse.identifier.cross-listed");
1864         cluId1.setStateKey("Sctive");
1865         cluId1.setCode("cluIdonecode");
1866         cluId1.setDivision("cluIdonedivision");
1867         cluId1.setLevel("cluIdonelevel");
1868         cluId1.setLongName("cluIdonelongName");
1869         cluId1.setShortName("cluIdoneshortName");
1870         // ERROR: Min length 3
1871         // ERROR: Only numbers allowed
1872         cluId1.setSuffixCode("cl");
1873         cluId1.setOrgId("cluIdoneorgid");
1874 
1875         clu.getAlternateIdentifiers().add(cluId1);
1876 
1877         CluIdentifierInfo cluId2 = new CluIdentifierInfo();
1878         // Check for different type validations
1879         cluId2.setTypeKey("kuali.lu.type.CreditCourse.identifier.version");
1880         cluId2.setStateKey("Sctive");
1881         cluId2.setCode("cluIdtwocode");
1882         cluId2.setDivision("cluIdtwodivision");
1883         cluId2.setLevel("cluIdtwolevel");
1884         cluId2.setLongName("cluIdtwolongName");
1885         cluId2.setShortName("cluIdtwoshortName");
1886         // ERROR: Should be uppper case
1887         // ERROR: should be of size 1
1888         cluId2.setVariation("ab");
1889         cluId2.setSuffixCode("cluIdtwosuffixcode");
1890         // ERROR OrgId required
1891         // cluId.setOrgId();
1892         clu.getAlternateIdentifiers().add(cluId2);
1893 
1894         clu.getAttributes().add(new AttributeInfo("cluAttrKey1", "cluAttrValue1"));
1895         clu.getAttributes().add(new AttributeInfo("cluAttrKey2", "cluAttrValue2"));
1896 
1897         clu.setCanCreateLui(true);
1898 
1899         // ERROR non negative integer
1900         clu.setDefaultEnrollmentEstimate(-545);
1901         clu.setDefaultMaximumEnrollment(999);
1902 
1903         RichTextInfo desc = new RichTextInfo();
1904         desc.setFormatted("<p>DESC FORMATTED</p>");
1905         desc.setPlain("DESC PLAIN");
1906         clu.setDescr(desc);
1907 
1908         clu.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20100203"));
1909         clu.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21001231"));
1910 
1911         clu.setIsEnrollable(true);
1912 
1913         AffiliatedOrgInfo aforg = new AffiliatedOrgInfo();
1914         aforg.setOrgId("AFFORGone");
1915         aforg.setPercentage(35l);
1916 
1917         AffiliatedOrgInfo aforg1 = new AffiliatedOrgInfo();
1918         aforg1.setOrgId("AFForgtwo");
1919         aforg1.setPercentage(65l);
1920 
1921         List<AffiliatedOrgInfo> affiliatedOrgs = new ArrayList<AffiliatedOrgInfo>();
1922         affiliatedOrgs.add(aforg);
1923         affiliatedOrgs.add(aforg1);
1924 
1925         CurrencyAmountInfo ca = new CurrencyAmountInfo();
1926         ca.setCurrencyQuantity(100);
1927         ca.setCurrencyTypeKey("DLLR");
1928 
1929         CurrencyAmountInfo ca1 = new CurrencyAmountInfo();
1930         ca.setCurrencyQuantity(200);
1931         ca.setCurrencyTypeKey("DLLR");
1932 
1933         List<CurrencyAmountInfo> caList = new ArrayList<CurrencyAmountInfo>();
1934         caList.add(ca);
1935 
1936         List<CurrencyAmountInfo> caList1 = new ArrayList<CurrencyAmountInfo>();
1937         caList.add(ca);
1938         caList.add(ca1);
1939 
1940         RichTextInfo cfRecDesc = new RichTextInfo();
1941         cfRecDesc.setPlain("Clu Fee Record");
1942 
1943         CluFeeRecordInfo feeRec = new CluFeeRecordInfo();
1944         feeRec.setAffiliatedOrgs(affiliatedOrgs);
1945         feeRec.setFeeAmounts(caList);
1946         feeRec.setFeeType("FEE-TYPE-X");
1947         feeRec.setRateType("RATE-TYPE-X");
1948         feeRec.setDescr(cfRecDesc);
1949 
1950         CluFeeRecordInfo feeRec1 = new CluFeeRecordInfo();
1951         feeRec1.setAffiliatedOrgs(affiliatedOrgs);
1952         feeRec1.setFeeAmounts(caList1);
1953         feeRec1.setFeeType("FEE-TYPE-Y");
1954         feeRec1.setRateType("RATE-TYPE-Y");
1955 
1956         List<CluFeeRecordInfo> feeRecList = new ArrayList<CluFeeRecordInfo>();
1957         feeRecList.add(feeRec);
1958         feeRecList.add(feeRec1);
1959 
1960         RichTextInfo cfDesc = new RichTextInfo();
1961         cfDesc.setPlain("Clu Fee");
1962 
1963         CluFeeInfo feeInfo = new CluFeeInfo();
1964         feeInfo.getAttributes().add(new AttributeInfo("FeeAttrKey1", "FeeAttrValue1"));
1965         feeInfo.getAttributes().add(new AttributeInfo("FeeAttrKey2", "FeeAttrValue2"));
1966         feeInfo.setCluFeeRecords(feeRecList);
1967         feeInfo.setDescr(cfDesc);
1968         clu.setFeeInfo(feeInfo);
1969 
1970         clu.setIsHasEarlyDropDeadline(true);
1971 
1972         clu.setIsHazardousForDisabledStudents(true);
1973 
1974         CluInstructorInfo primaryInstructor = new CluInstructorInfo();
1975         primaryInstructor.setOrgId("EXTorgIdone");
1976         primaryInstructor.setPersonId("EXTpersonIdone");
1977         primaryInstructor.getAttributes().add(new AttributeInfo("PrimaryInstAttrKey1", "PrimaryInstAttrValue1"));
1978         primaryInstructor.getAttributes().add(new AttributeInfo("PrimaryInstAttrKey2", "PrimaryInstAttrValue2"));
1979         clu.setPrimaryInstructor(primaryInstructor);
1980 
1981         CluInstructorInfo instructor1 = new CluInstructorInfo();
1982         instructor1.setOrgId("EXTorgIdtwo");
1983         instructor1.setPersonId("EXTpersonIdtwo");
1984         instructor1.getAttributes().add(new AttributeInfo("Inst1AttrKey1", "Inst1AttrValue1"));
1985         instructor1.getAttributes().add(new AttributeInfo("Inst1AttrKey2", "Inst1AttrValue2"));
1986         clu.getInstructors().add(instructor1);
1987 
1988         CluInstructorInfo instructor2 = new CluInstructorInfo();
1989         instructor2.setOrgId("EXTorgIdthree");
1990         instructor2.setPersonId("EXTpersonIdthree");
1991         instructor2.getAttributes().add(new AttributeInfo("Inst2AttrKey1", "Inst2AttrValue1"));
1992         instructor2.getAttributes().add(new AttributeInfo("Inst2AttrKey2", "Inst2AttrValue2"));
1993         clu.getInstructors().add(instructor2);
1994 
1995         LuCodeInfo luCode1 = new LuCodeInfo();
1996         luCode1.setId("luCode1.key");
1997         RichTextInfo luCode1Desc = new RichTextInfo();
1998         luCode1Desc.setPlain("luCode1desc");
1999         luCode1.setDescr(luCode1Desc);
2000         luCode1.setValue("luCode1value");
2001         luCode1.getAttributes().add(new AttributeInfo("luCode1AttrKey1", "luCode1AttrValue1"));
2002         luCode1.getAttributes().add(new AttributeInfo("luCode1AttrKey2", "luCode1AttrValue2"));
2003         clu.getLuCodes().add(luCode1);
2004 
2005         LuCodeInfo luCode2 = new LuCodeInfo();
2006         luCode2.setId("luCode2.key");
2007         RichTextInfo luCodetwodesc = new RichTextInfo();
2008         luCodetwodesc.setPlain("luCodetwodesc");
2009         luCode2.setDescr(luCodetwodesc);
2010         luCode2.setValue("luCodetwovalue");
2011         luCode2.getAttributes().add(new AttributeInfo("luCode2AttrKey1", "luCode2AttrValue1"));
2012         luCode2.getAttributes().add(new AttributeInfo("luCode2AttrKey2", "luCode2AttrValue2"));
2013         clu.getLuCodes().add(luCode2);
2014 
2015         RichTextInfo marketingDesc = new RichTextInfo();
2016         marketingDesc.setFormatted("<p>marketingDesc FORMATTED</p>");
2017         marketingDesc.setPlain("marketingDesc PLAIN");
2018 
2019         clu.setNextReviewPeriod("nextReviewPeriod");
2020 
2021         clu.getOfferedAtpTypes().add("offeredAtpType1");
2022         clu.getOfferedAtpTypes().add("offeredAtpType2");
2023 
2024 
2025         CluInstructorInfo pubPrimaryInstructor = new CluInstructorInfo();
2026         pubPrimaryInstructor.setOrgId("EXTorgId");
2027         pubPrimaryInstructor.setPersonId("EXTpersonId");
2028         pubPrimaryInstructor.getAttributes().add(new AttributeInfo("PubPrimaryInstAttrKey1", "PubPrimaryInstAttrValue1"));
2029         pubPrimaryInstructor.getAttributes().add(new AttributeInfo("PubPrimaryInstAttrKey2", "PubPrimaryInstAttrValue2"));
2030 
2031         CluInstructorInfo pubInstructor1 = new CluInstructorInfo();
2032         pubInstructor1.setOrgId("EXTorgIdtwo");
2033         pubInstructor1.setPersonId("EXT-personId-two");
2034         pubInstructor1.getAttributes().add(new AttributeInfo("PubInst1AttrKey1", "PubInst1AttrValue1"));
2035         pubInstructor1.getAttributes().add(new AttributeInfo("PubInst1AttrKey2", "PubInst1AttrValue2"));
2036 
2037         CluInstructorInfo pubInstructor2 = new CluInstructorInfo();
2038         pubInstructor2.setOrgId("EXTorgIdthree");
2039         pubInstructor2.setPersonId("EXTpersonIdthree");
2040         pubInstructor2.getAttributes().add(new AttributeInfo("PubInst2AttrKey1", "PubInst2AttrValue1"));
2041         pubInstructor2.getAttributes().add(new AttributeInfo("PubInst2AttrKey2", "PubInst2AttrValue2"));
2042 
2043         clu.setReferenceURL("http://student.kuali.org/clus");
2044 
2045         TimeAmountInfo stdDuration = new TimeAmountInfo();
2046         stdDuration.setAtpDurationTypeKey("EXTstdDurationId");
2047         stdDuration.setTimeQuantity(new Integer(7867));
2048         clu.setStdDuration(stdDuration);
2049 
2050         createCampusLocationList(clu);
2051 
2052         createIntensity(clu);
2053 
2054         createAccreditationList(clu);
2055 
2056         createAdminOrgs(clu);
2057 
2058         clu.setTypeKey("kuali.lu.type.CreditCourse");
2059         clu.setStateKey("template");
2060 
2061         List<ValidationResultInfo> valerros = client.validateClu("SYSTEM", clu, contextInfo);
2062 
2063         assertEquals(2, valerros.size());
2064     }
2065 
2066     @Test
2067     public void test26AddCluToCluSet() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
2068         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2069 
2070         StatusInfo status = client.addCluToCluSet("CLU-1", createdCluSet.getId(), contextInfo);
2071         CluSetInfo getCluSetInfo = client.getCluSet(createdCluSet.getId(), contextInfo);
2072 
2073         assertTrue(status.getIsSuccess());
2074         assertEquals(1, getCluSetInfo.getCluIds().size());
2075         assertEquals("CLU-1", getCluSetInfo.getCluIds().get(0));
2076     }
2077 
2078     @Test
2079     public void test27AddCluToCluSet_DuplicateCluId() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
2080         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2081 
2082         StatusInfo status = client.addCluToCluSet("CLU-1", createdCluSet.getId(), contextInfo);
2083         assertTrue(status.getIsSuccess());
2084 
2085         status = client.addCluToCluSet("CLU-1", createdCluSet.getId(), contextInfo);
2086         assertFalse(status.getIsSuccess());
2087     }
2088 
2089     @Test
2090     public void test28AddClusToCluSet() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
2091         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2092 
2093         // Somehow cannot add 2 CLUs in sequence (JTA rollback exception) but adding a single CLU works
2094         //CluInfo clu1 = createCluInfo();
2095         //CluInfo clu2 = createCluInfo();
2096         //CluInfo createdClu1 = atpService.createClu("luType.shell.course", clu1);
2097         //CluInfo createdClu2 = atpService.createClu("luType.shell.course", clu2);
2098         //List<String> cluIdList = Arrays.asList(new String[] {createdClu1.getId(), createdClu2.getId()});
2099 
2100         List<String> cluIdList = Arrays.asList(new String[]{"CLU-1", "CLU-2", "CLU-3", "CLU-4"});
2101 
2102         StatusInfo status = client.addClusToCluSet(cluIdList, createdCluSet.getId(), contextInfo);
2103         CluSetInfo getCluSetInfo = client.getCluSet(createdCluSet.getId(), contextInfo);
2104         assertTrue(status.getIsSuccess());
2105         assertEquals(4, getCluSetInfo.getCluIds().size());
2106         assertTrue(getCluSetInfo.getCluIds().contains("CLU-1"));
2107         assertTrue(getCluSetInfo.getCluIds().contains("CLU-2"));
2108         assertTrue(getCluSetInfo.getCluIds().contains("CLU-3"));
2109         assertTrue(getCluSetInfo.getCluIds().contains("CLU-4"));
2110     }
2111 
2112     @Test
2113     public void test29AddClusToCluSet_InvalidCluId() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
2114         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2115 
2116         List<String> cluIdList = Arrays.asList(new String[]{"CLU-1", "CLU-2", "CLU-INVALID-ID", "CLU-4"});
2117 
2118         try {
2119             client.addClusToCluSet(cluIdList, createdCluSet.getId(), contextInfo);
2120             fail("Adding a non-existent CLU (id='CLU-INVALID-ID') to CluSet should have failed");
2121         } catch (DoesNotExistException e) {
2122             assertTrue(true);
2123         }
2124     }
2125 
2126     @Test
2127     public void test30AddClusToCluSet_DuplicateCluId() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
2128         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2129 
2130         List<String> cluIdList = Arrays.asList(new String[]{"CLU-1", "CLU-2", "CLU-2", "CLU-4"});
2131 
2132         StatusInfo status = client.addClusToCluSet(cluIdList, createdCluSet.getId(), contextInfo);
2133         assertEquals("CluSet already contains Clu (id='CLU-2')", status.getMessage());
2134     }
2135 
2136     @Test
2137     public void test31AddClusToCluSet_InvalidCluSetId() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException {
2138         List<String> cluIdList = Arrays.asList(new String[]{"CLU-1", "CLU-2", "CLU-3", "CLU-4"});
2139 
2140         try {
2141             client.addClusToCluSet(cluIdList, "CLUSET-INVALID-ID", contextInfo);
2142             fail("Adding CLUs to a non-existent CluSet (id='CLUSET-INVALID-ID') should have failed");
2143         } catch (DoesNotExistException e) {
2144             assertTrue(true);
2145         }
2146     }
2147 
2148     @Test
2149     public void test32AddCluSetToCluSet() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, CircularRelationshipException, ReadOnlyException {
2150         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2151 
2152         StatusInfo status = client.addCluSetToCluSet(createdCluSet.getId(), "CLUSET-1", contextInfo);
2153         CluSetInfo getCluSetInfo = client.getCluSet(createdCluSet.getId(), contextInfo);
2154 
2155         assertTrue(status.getIsSuccess());
2156         assertEquals(1, getCluSetInfo.getCluSetIds().size());
2157         assertTrue(getCluSetInfo.getCluSetIds().contains("CLUSET-1"));
2158     }
2159 
2160     @Test
2161     public void test33AddCluSetToCluSet_CircularRelationshipException() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, CircularRelationshipException, ReadOnlyException {
2162         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2163 
2164         try {
2165             client.addCluSetToCluSet(createdCluSet.getId(), createdCluSet.getId(), contextInfo);
2166             fail("Adding a CluSet to itself should have failed");
2167         } catch (CircularRelationshipException e) {
2168             assertTrue(true);
2169         }
2170     }
2171 
2172     @Test
2173     public void test34AddCluSetToCluSet_NestedCircularRelationshipException() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, CircularRelationshipException, ReadOnlyException {
2174         CluSetInfo createdCluSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2175         CluSetInfo createdCluSet2 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2176         CluSetInfo createdCluSet3 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2177 
2178         client.addCluSetToCluSet(createdCluSet3.getId(), createdCluSet1.getId(), contextInfo);
2179         client.addCluSetToCluSet(createdCluSet2.getId(), createdCluSet3.getId(), contextInfo);
2180 
2181         try {
2182             client.addCluSetToCluSet(createdCluSet1.getId(), createdCluSet2.getId(), contextInfo);
2183             fail("Adding CluSet should have thrown a CircularRelationshipException");
2184         } catch (CircularRelationshipException e) {
2185             assertTrue(true);
2186         }
2187     }
2188 
2189     @Test
2190     public void test35AddCluSetToCluSet_DuplicateCluSetId() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, CircularRelationshipException, ReadOnlyException {
2191 
2192         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2193 
2194         StatusInfo status = client.addCluSetToCluSet(createdCluSet.getId(), "CLUSET-1", contextInfo);
2195         assertTrue(status.getIsSuccess());
2196 
2197         try {
2198             client.addCluSetToCluSet(createdCluSet.getId(), "CLUSET-1", contextInfo);
2199             fail("Adding a duplicate CluSet (id='CLUSET-1') to CluSet should have failed");
2200         } catch (OperationFailedException e) {
2201             assertTrue(true);
2202         }
2203     }
2204 
2205     @Test
2206     public void test36AddCluSetToCluSet_InvalidCluSetId() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, CircularRelationshipException, ReadOnlyException {
2207 
2208         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2209 
2210         try {
2211             client.addCluSetToCluSet(createdCluSet.getId(), "CLUSET-INVALID-ID", contextInfo);
2212             fail("Adding a non-existent CluSet (id='CLUSET-INVALID-ID') to CluSet should have failed");
2213         } catch (DoesNotExistException e) {
2214             assertTrue(true);
2215         }
2216     }
2217 
2218     @Test
2219     public void test37AddCluSetsToCluSet() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, CircularRelationshipException, ReadOnlyException {
2220 
2221         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2222 
2223         List<String> cluIdList = Arrays.asList(new String[]{"CLUSET-1", "CLUSET-2", "CLUSET-3", "CLUSET-4"});
2224 
2225         StatusInfo status = client.addCluSetsToCluSet(createdCluSet.getId(), cluIdList, contextInfo);
2226         CluSetInfo getCluSetInfo = client.getCluSet(createdCluSet.getId(), contextInfo);
2227 
2228         assertTrue(status.getIsSuccess());
2229         assertEquals(4, getCluSetInfo.getCluSetIds().size());
2230         assertTrue(getCluSetInfo.getCluSetIds().contains("CLUSET-1"));
2231         assertTrue(getCluSetInfo.getCluSetIds().contains("CLUSET-2"));
2232         assertTrue(getCluSetInfo.getCluSetIds().contains("CLUSET-3"));
2233         assertTrue(getCluSetInfo.getCluSetIds().contains("CLUSET-4"));
2234     }
2235 
2236     @Test
2237     public void test38AddCluSetsToCluSet_InvalidCluSetId() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, CircularRelationshipException, ReadOnlyException {
2238 
2239         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2240 
2241         List<String> cluIdList = Arrays.asList(new String[]{"CLUSET-1", "CLUSET-INVALID-ID", "CLUSET-3", "CLUSET-4"});
2242 
2243         try {
2244             client.addCluSetsToCluSet(createdCluSet.getId(), cluIdList, contextInfo);
2245             fail("Adding a non-existent CluSet (id='CLUSET-INVALID-ID') to CluSet should have failed");
2246         } catch (DoesNotExistException e) {
2247             assertTrue(true);
2248         }
2249     }
2250 
2251     @Test
2252     public void test39AddCluSetsToCluSet_DuplicateCluSetId() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, CircularRelationshipException, ReadOnlyException {
2253 
2254         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2255 
2256         List<String> cluIdList = Arrays.asList(new String[]{"CLUSET-1", "CLUSET-2", "CLUSET-3", "CLUSET-2"});
2257 
2258         try {
2259             client.addCluSetsToCluSet(createdCluSet.getId(), cluIdList, contextInfo);
2260             fail("Adding a duplicate CluSet (id='CLUSET-2') to CluSet should have failed");
2261         } catch (OperationFailedException e) {
2262             assertTrue(true);
2263         }
2264     }
2265 
2266     @Test
2267     public void test40AddCluSetsToCluSet_CircularRelationshipException() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, CircularRelationshipException, ReadOnlyException {
2268 
2269         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2270         // Adding createdCluSet to itself
2271         List<String> cluIdList = Arrays.asList(new String[]{"CLUSET-1", "CLUSET-2", createdCluSet.getId(), "CLUSET-4"});
2272 
2273         try {
2274             client.addCluSetsToCluSet(createdCluSet.getId(), cluIdList, contextInfo);
2275             fail("Adding a CluSet to itself should have failed");
2276         } catch (CircularRelationshipException e) {
2277             assertTrue(true);
2278         }
2279     }
2280 
2281     @Test
2282     public void test41AddCluSetsToCluSet_NestedCircularRelationshipException() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, CircularRelationshipException, ReadOnlyException {
2283 
2284         CluSetInfo createdCluSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2285         CluSetInfo createdCluSet2 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2286         CluSetInfo createdCluSet3 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSetInfo(), contextInfo);
2287 
2288         List<String> cluIdList1 = Arrays.asList(new String[]{"CLUSET-1", "CLUSET-2", createdCluSet1.getId()});
2289         client.addCluSetsToCluSet(createdCluSet3.getId(), cluIdList1, contextInfo);
2290 
2291         // Adding createdCluSet to itself
2292         List<String> cluIdList2 = Arrays.asList(new String[]{"CLUSET-1", createdCluSet3.getId()});
2293         client.addCluSetsToCluSet(createdCluSet2.getId(), cluIdList2, contextInfo);
2294 
2295         try {
2296             List<String> cluIdList3 = Arrays.asList(new String[]{createdCluSet2.getId(),});
2297             client.addCluSetsToCluSet(createdCluSet1.getId(), cluIdList3, contextInfo);
2298             fail("Adding CluSet should have thrown a CircularRelationshipException");
2299         } catch (CircularRelationshipException e) {
2300             assertTrue(true);
2301         }
2302     }
2303 
2304 
2305     @Test
2306     public void test42CreateDynamicCluSet_Simple() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
2307 
2308         CluSetInfo cluSet = createCluSetInfo();
2309 
2310         MembershipQueryInfo query = new MembershipQueryInfo();
2311         query.setSearchTypeKey("lu.search.clus");
2312 
2313         cluSet.setMembershipQuery(query);
2314         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", cluSet, contextInfo);
2315 
2316         assertNotNull(createdCluSet);
2317         assertNotNull(createdCluSet.getMembershipQuery());
2318         assertNotNull(createdCluSet.getMembershipQuery().getId());
2319         assertNotNull(createdCluSet.getMembershipQuery().getSearchTypeKey());
2320         assertEquals(query.getSearchTypeKey(), createdCluSet.getMembershipQuery().getSearchTypeKey());
2321         assertNotNull(createdCluSet.getMembershipQuery().getQueryParamValues());
2322         assertNotNull(createdCluSet.getCluIds());
2323         assertEquals(107, createdCluSet.getCluIds().size());
2324     }
2325 
2326     private MembershipQueryInfo getMembershipQueryInfo() {
2327         List<org.kuali.student.r2.core.search.dto.SearchParamInfo> queryParamValueList = new ArrayList<org.kuali.student.r2.core.search.dto.SearchParamInfo>();
2328         org.kuali.student.r2.core.search.dto.SearchParamInfo sp1 = new org.kuali.student.r2.core.search.dto.SearchParamInfo();
2329         sp1.setKey("lu.queryParam.startsWith.cluCode");
2330         sp1.setValues(Arrays.asList("AAST"));
2331         queryParamValueList.add(sp1);
2332         org.kuali.student.r2.core.search.dto.SearchParamInfo sp2 = new org.kuali.student.r2.core.search.dto.SearchParamInfo();
2333         sp2.setKey("lu.queryParam.cluState");
2334         sp2.setValues(Arrays.asList("Active"));
2335         queryParamValueList.add(sp2);
2336 
2337         MembershipQueryInfo query = new MembershipQueryInfo();
2338         query.setSearchTypeKey("lu.search.cluByCodeAndState");
2339         query.setQueryParamValues(queryParamValueList);
2340 
2341         return query;
2342     }
2343 
2344     // KSCM-626 TODO SearchParamInfo mismatch between MembershipInfoQuery and SearchRequestInfo
2345     @Test
2346     public void test43CreateDynamicCluSet() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
2347 
2348         CluSetInfo cluSet = createCluSetInfo();
2349 
2350         MembershipQueryInfo query = getMembershipQueryInfo();
2351         cluSet.setMembershipQuery(query);
2352 
2353         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", cluSet, contextInfo);
2354 
2355         assertNotNull(createdCluSet);
2356         assertNotNull(createdCluSet.getMembershipQuery());
2357         assertNotNull(createdCluSet.getMembershipQuery().getId());
2358         assertNotNull(createdCluSet.getMembershipQuery().getSearchTypeKey());
2359         assertEquals(query.getSearchTypeKey(), createdCluSet.getMembershipQuery().getSearchTypeKey());
2360         assertNotNull(createdCluSet.getMembershipQuery().getQueryParamValues());
2361         assertEquals(query.getQueryParamValues().size(), createdCluSet.getMembershipQuery().getQueryParamValues().size());
2362         assertNotNull(createdCluSet.getCluIds());
2363         assertEquals(10, createdCluSet.getCluIds().size());
2364 
2365         CluSetInfo getCluSet = client.getCluSet(createdCluSet.getId(), contextInfo);
2366 
2367         assertNotNull(getCluSet);
2368         assertNotNull(getCluSet.getMembershipQuery());
2369         assertNotNull(getCluSet.getMembershipQuery().getId());
2370         assertNotNull(getCluSet.getMembershipQuery().getSearchTypeKey());
2371         assertEquals(query.getSearchTypeKey(), getCluSet.getMembershipQuery().getSearchTypeKey());
2372         assertNotNull(getCluSet.getMembershipQuery().getQueryParamValues());
2373         assertEquals(query.getQueryParamValues().size(), getCluSet.getMembershipQuery().getQueryParamValues().size());
2374         assertNotNull(getCluSet.getCluIds());
2375         assertEquals(10, getCluSet.getCluIds().size());
2376     }
2377 
2378     @Test
2379     public void test44CreateCluSet_InvalidCluSet1() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
2380 
2381         CluSetInfo cluSet = createCluSetInfo();
2382         cluSet.getCluIds().add("CLU-1");
2383 
2384         MembershipQueryInfo query = new MembershipQueryInfo();
2385         query.setSearchTypeKey("lu.search.clus");
2386 
2387         cluSet.setMembershipQuery(query);
2388 
2389         try {
2390             client.createCluSet("kuali.cluSet.type.CreditCourse", cluSet, contextInfo);
2391             fail("Creating CluSet should have thrown an UnsupportedActionException. Cannot add CLUs and Dynamic CluSets into one CluSet");
2392         } catch (UnsupportedActionException e) {
2393             assertTrue(true);
2394         }
2395 
2396     }
2397 
2398     @Test
2399     public void test45CreateCluSet_InvalidCluSet2() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
2400 
2401         CluSetInfo cluSet = createCluSetInfo();
2402         cluSet.getCluSetIds().add("CLUSET-1");
2403 
2404         MembershipQueryInfo query = new MembershipQueryInfo();
2405         query.setSearchTypeKey("lu.search.clus");
2406 
2407         cluSet.setMembershipQuery(query);
2408 
2409         try {
2410             client.createCluSet("kuali.cluSet.type.CreditCourse", cluSet, contextInfo);
2411             fail("Creating CluSet should have thrown an UnsupportedActionException. Cannot add CluSets and Dynamic CluSets into one CluSet");
2412         } catch (UnsupportedActionException e) {
2413             assertTrue(true);
2414         }
2415 
2416     }
2417 
2418     @Test
2419     public void test46CreateCluSet_InvalidCluSet3() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
2420 
2421         CluSetInfo cluSet = createCluSetInfo();
2422         cluSet.getCluIds().add("CLU-1");
2423         cluSet.getCluSetIds().add("CLUSET-1");
2424 
2425         try {
2426             client.createCluSet("kuali.cluSet.type.CreditCourse", cluSet, contextInfo);
2427             fail("Creating CluSet should have thrown an UnsupportedActionException. Cannot add CLUs and CluSets into one CluSet");
2428         } catch (UnsupportedActionException e) {
2429             assertTrue(true);
2430         }
2431 
2432     }
2433 
2434     // KSCM-626 TODO SearchParamInfo mismatch between MembershipInfoQuery and SearchRequestInfo
2435     @Test
2436     public void test47GetDynamicCluSet() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
2437 
2438         CluSetInfo cluSet = createCluSetInfo();
2439 
2440         MembershipQueryInfo query = getMembershipQueryInfo();
2441         cluSet.setMembershipQuery(query);
2442         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", cluSet, contextInfo);
2443         assertNotNull(createdCluSet);
2444         assertNotNull(createdCluSet.getCluIds());
2445 
2446         CluSetInfo getCluSet = client.getCluSet(createdCluSet.getId(), contextInfo);
2447 
2448         assertNotNull(getCluSet);
2449         assertNotNull(getCluSet.getMembershipQuery());
2450         assertNotNull(getCluSet.getMembershipQuery().getId());
2451         assertNotNull(getCluSet.getMembershipQuery().getSearchTypeKey());
2452         assertEquals(query.getSearchTypeKey(), getCluSet.getMembershipQuery().getSearchTypeKey());
2453         assertNotNull(getCluSet.getMembershipQuery().getQueryParamValues());
2454         assertEquals(query.getQueryParamValues().size(), getCluSet.getMembershipQuery().getQueryParamValues().size());
2455         assertEquals(createdCluSet.getCluIds().size(), getCluSet.getCluIds().size());
2456         assertNotNull(getCluSet.getCluIds());
2457         assertEquals(10, getCluSet.getCluIds().size());
2458     }
2459 
2460     @Test
2461     public void test48GetDynamicCluSet_Simple() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, ReadOnlyException {
2462 
2463         CluSetInfo cluSet = createCluSetInfo();
2464 
2465         MembershipQueryInfo query = new MembershipQueryInfo();
2466         query.setSearchTypeKey("lu.search.clus");
2467 
2468         cluSet.setMembershipQuery(query);
2469         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", cluSet, contextInfo);
2470         assertNotNull(createdCluSet);
2471         assertNotNull(createdCluSet.getCluIds());
2472 
2473         CluSetInfo getCluSet = client.getCluSet(createdCluSet.getId(), contextInfo);
2474         assertNotNull(getCluSet);
2475         assertNotNull(getCluSet.getCluIds());
2476         assertEquals(createdCluSet.getCluIds().size(), getCluSet.getCluIds().size());
2477     }
2478 
2479     @Test
2480     public void test49GetCluSetTreeView() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
2481 
2482         CluSetTreeViewInfo treeView = client.getCluSetTreeView("CLUSET-2", contextInfo);
2483         assertNotNull(treeView);
2484         assertEquals(2, treeView.getCluSets().size());
2485 
2486         CluSetTreeViewInfo cluSet = treeView.getCluSets().get(1);
2487         assertNotNull(cluSet);
2488         assertEquals("CLUSET-4", cluSet.getId());
2489         assertEquals(2, cluSet.getClus().size());
2490 
2491         CluInfo clu = cluSet.getClus().get(1);
2492         assertNotNull(clu);
2493         assertEquals("CLU-3", clu.getId());
2494     }
2495 
2496     @Test
2497     public void test50GetCluSetTreeView_dynamicCluSet() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, UnsupportedActionException, DoesNotExistException, ReadOnlyException {
2498 
2499         CluSetInfo cluSet = createCluSetInfo();
2500 
2501         MembershipQueryInfo query = new MembershipQueryInfo();
2502         query.setSearchTypeKey("lu.search.clus");
2503 
2504         cluSet.setMembershipQuery(query);
2505         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", cluSet, contextInfo);
2506         assertNotNull(createdCluSet);
2507         assertNotNull(createdCluSet.getCluIds());
2508 
2509         CluSetTreeViewInfo treeView = client.getCluSetTreeView(createdCluSet.getId(), contextInfo);
2510         assertNotNull(treeView);
2511         assertEquals(createdCluSet.getCluIds().size(), treeView.getClus().size());
2512     }
2513 
2514     @Test
2515     public void test51GetCluSetTreeView_invalidCluSet()
2516             throws InvalidParameterException, MissingParameterException,
2517             OperationFailedException, PermissionDeniedException {
2518 
2519         try {
2520             client.getCluSetTreeView("CLUSET-XX", contextInfo);
2521             assertTrue(false);
2522         } catch (DoesNotExistException e) {
2523             assertTrue(true);
2524         }
2525     }
2526 
2527     @Test
2528     public void test52GetCluSetTreeView_nullCluSet()
2529             throws DoesNotExistException, InvalidParameterException,
2530             OperationFailedException, PermissionDeniedException {
2531 
2532         try {
2533             client.getCluSetTreeView(null, contextInfo);
2534             assertTrue(false);
2535         } catch (MissingParameterException e) {
2536             assertTrue(true);
2537         }
2538     }
2539 
2540     // KSCM-626 TODO SearchParamInfo mismatch between MembershipInfoQuery and SearchRequestInfo
2541     @Test
2542     public void test53UpdateDynamicCluSet() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, VersionMismatchException, UnsupportedActionException, CircularRelationshipException, ReadOnlyException {
2543 
2544         CluSetInfo cluSet1 = createCluSetInfo();
2545 
2546         //Create clu set
2547         ArrayList<org.kuali.student.r2.core.search.dto.SearchParamInfo> queryParamValueList = new ArrayList<org.kuali.student.r2.core.search.dto.SearchParamInfo>();
2548         MembershipQueryInfo query1 = new MembershipQueryInfo();
2549         query1.setSearchTypeKey("lu.search.clus");
2550         query1.setQueryParamValues(queryParamValueList);
2551 
2552         cluSet1.setMembershipQuery(query1);
2553         // Version 0
2554         CluSetInfo createdCluSet = client.createCluSet("kuali.cluSet.type.CreditCourse", cluSet1, contextInfo);
2555         // createdCluSet should be version 1 but is 0
2556 
2557         //Update clu set
2558         MembershipQueryInfo query2 = getMembershipQueryInfo();
2559 
2560         createdCluSet.setMembershipQuery(query2);
2561 
2562         // Dynamic CluSet so we can't have any CluSet ids or Clu ids
2563         createdCluSet.getCluSetIds().clear();
2564         createdCluSet.getCluIds().clear();
2565         CluSetInfo updatedCluSet = client.updateCluSet(createdCluSet.getId(), createdCluSet, contextInfo);
2566 
2567         assertNotNull(updatedCluSet);
2568         assertNotNull(updatedCluSet.getCluIds());
2569         assertEquals(10, updatedCluSet.getCluIds().size());
2570         assertTrue(updatedCluSet.getCluSetIds().isEmpty());
2571     }
2572 
2573     @Test
2574     public void test54UpdateCluSet_VersionMismatch() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, VersionMismatchException, CircularRelationshipException, ReadOnlyException {
2575 
2576         CluSetInfo createCluSet = createCluSetInfo();
2577 
2578         CluSetInfo createdCluSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSet, contextInfo);
2579         createdCluSet1.getCluSetIds().add("CLUSET-1");
2580         createdCluSet1.getCluSetIds().add("CLUSET-2");
2581 
2582         CluSetInfo updatedCluSet1 = client.updateCluSet(createdCluSet1.getId(), createdCluSet1, contextInfo);
2583         assertEquals(2, updatedCluSet1.getCluSetIds().size());
2584 
2585         try {
2586             client.updateCluSet(updatedCluSet1.getId(), createdCluSet1, contextInfo);
2587             fail("Should have thrown VersionMismatchException.");
2588         } catch (VersionMismatchException e) {
2589             assertTrue(true);
2590         }
2591     }
2592 
2593     @Test
2594     public void test55UpdateCluSet_ClearCluSets() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, VersionMismatchException, CircularRelationshipException, ReadOnlyException {
2595 
2596         CluSetInfo createCluSet = createCluSetInfo();
2597         createCluSet.getCluSetIds().add("CLUSET-1");
2598         createCluSet.getCluSetIds().add("CLUSET-2");
2599         createCluSet.getCluSetIds().add("CLUSET-3");
2600 
2601         CluSetInfo createdCluSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSet, contextInfo);
2602         assertEquals(3, createdCluSet1.getCluSetIds().size());
2603 
2604         createdCluSet1.getCluSetIds().clear();
2605 
2606         CluSetInfo updatedCluSet1 = client.updateCluSet(createdCluSet1.getId(), createdCluSet1, contextInfo);
2607         assertEquals(0, updatedCluSet1.getCluSetIds().size());
2608 
2609         CluSetInfo getCluSet1 = client.getCluSet(updatedCluSet1.getId(), contextInfo);
2610         assertEquals(0, getCluSet1.getCluSetIds().size());
2611     }
2612 
2613     @Test
2614     public void test56UpdateCluSet_AddCluSets() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, VersionMismatchException, CircularRelationshipException, ReadOnlyException {
2615 
2616         CluSetInfo createCluSet = createCluSetInfo();
2617 
2618         CluSetInfo createdCluSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSet, contextInfo);
2619         assertEquals(0, createdCluSet1.getCluSetIds().size());
2620 
2621         createdCluSet1.getCluSetIds().add("CLUSET-1");
2622         createdCluSet1.getCluSetIds().add("CLUSET-2");
2623 
2624         CluSetInfo updatedCluSet1 = client.updateCluSet(createdCluSet1.getId(), createdCluSet1, contextInfo);
2625         assertEquals(2, updatedCluSet1.getCluSetIds().size());
2626 
2627         CluSetInfo getCluSet1 = client.getCluSet(updatedCluSet1.getId(), contextInfo);
2628         assertEquals(2, getCluSet1.getCluSetIds().size());
2629         assertTrue(getCluSet1.getCluSetIds().contains("CLUSET-1"));
2630         assertTrue(getCluSet1.getCluSetIds().contains("CLUSET-2"));
2631     }
2632 
2633     @Test
2634     public void test57UpdateCluSet_removeCluSets() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, VersionMismatchException, CircularRelationshipException, ReadOnlyException {
2635 
2636         CluSetInfo createCluSet = createCluSetInfo();
2637         createCluSet.getCluSetIds().add("CLUSET-1");
2638         createCluSet.getCluSetIds().add("CLUSET-2");
2639         createCluSet.getCluSetIds().add("CLUSET-3");
2640 
2641         CluSetInfo createdCluSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSet, contextInfo);
2642         assertEquals(3, createdCluSet1.getCluSetIds().size());
2643 
2644         createdCluSet1.getCluSetIds().remove("CLUSET-2");
2645 
2646         CluSetInfo updatedCluSet1 = client.updateCluSet(createdCluSet1.getId(), createdCluSet1, contextInfo);
2647         assertEquals(2, updatedCluSet1.getCluSetIds().size());
2648 
2649         CluSetInfo getCluSet1 = client.getCluSet(updatedCluSet1.getId(), contextInfo);
2650         assertEquals(2, getCluSet1.getCluSetIds().size());
2651         assertTrue(getCluSet1.getCluSetIds().contains("CLUSET-1"));
2652         assertTrue(getCluSet1.getCluSetIds().contains("CLUSET-3"));
2653     }
2654 
2655     @Test
2656     public void test58UpdateCluSet_ClearClus() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, VersionMismatchException, CircularRelationshipException, ReadOnlyException {
2657 
2658         CluSetInfo createCluSet = createCluSetInfo();
2659         createCluSet.getCluIds().add("CLU-1");
2660         createCluSet.getCluIds().add("CLU-2");
2661         assertEquals(2, createCluSet.getCluIds().size());
2662 
2663         CluSetInfo createdCluSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSet, contextInfo);
2664         assertEquals(2, createdCluSet1.getCluIds().size());
2665 
2666         assertNotNull(createdCluSet1);
2667         assertNotNull(createdCluSet1.getCluIds());
2668         assertEquals(2, createdCluSet1.getCluIds().size());
2669 
2670         // Remove all CLUs
2671         createdCluSet1.getCluIds().clear();
2672 
2673         CluSetInfo updatedCluSet1 = client.updateCluSet(createdCluSet1.getId(), createdCluSet1, contextInfo);
2674 
2675         assertNotNull(updatedCluSet1);
2676         assertNotNull(updatedCluSet1.getCluIds());
2677         assertEquals(0, updatedCluSet1.getCluIds().size());
2678 
2679         CluSetInfo getCluSet1 = client.getCluSet(updatedCluSet1.getId(), contextInfo);
2680 
2681         assertNotNull(getCluSet1);
2682         assertNotNull(getCluSet1.getCluIds());
2683         assertEquals(0, getCluSet1.getCluIds().size());
2684     }
2685 
2686     @Test
2687     public void test59UpdateCluSet_AddClu() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, VersionMismatchException, CircularRelationshipException, ReadOnlyException {
2688 
2689         CluSetInfo createCluSet = createCluSetInfo();
2690         createCluSet.getCluIds().add("CLU-1");
2691         createCluSet.getCluIds().add("CLU-2");
2692         assertEquals(2, createCluSet.getCluIds().size());
2693 
2694         CluSetInfo createdCluSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSet, contextInfo);
2695         assertEquals(2, createdCluSet1.getCluIds().size());
2696 
2697         createdCluSet1.getCluIds().add("CLU-3");
2698 
2699         assertNotNull(createdCluSet1);
2700         assertNotNull(createdCluSet1.getCluIds());
2701         assertEquals(3, createdCluSet1.getCluIds().size());
2702 
2703         CluSetInfo updatedCluSet1 = client.updateCluSet(createdCluSet1.getId(), createdCluSet1, contextInfo);
2704 
2705         assertNotNull(updatedCluSet1);
2706         assertNotNull(updatedCluSet1.getCluIds());
2707         assertEquals(3, updatedCluSet1.getCluIds().size());
2708 
2709         CluSetInfo getCluSet1 = client.getCluSet(updatedCluSet1.getId(), contextInfo);
2710 
2711         assertNotNull(getCluSet1);
2712         assertNotNull(getCluSet1.getCluIds());
2713         assertEquals(3, getCluSet1.getCluIds().size());
2714     }
2715 
2716     @Test
2717     public void test60UpdateCluSet_RemoveClu() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, UnsupportedActionException, VersionMismatchException, CircularRelationshipException, ReadOnlyException {
2718 
2719         CluSetInfo createCluSet = createCluSetInfo();
2720         createCluSet.getCluIds().add("CLU-1");
2721         createCluSet.getCluIds().add("CLU-2");
2722         assertEquals(2, createCluSet.getCluIds().size());
2723 
2724         CluSetInfo createdCluSet1 = client.createCluSet("kuali.cluSet.type.CreditCourse", createCluSet, contextInfo);
2725         assertEquals(2, createdCluSet1.getCluIds().size());
2726 
2727         createdCluSet1.getCluIds().remove("CLU-1");
2728 
2729         assertNotNull(createdCluSet1);
2730         assertNotNull(createdCluSet1.getCluIds());
2731         assertEquals(1, createdCluSet1.getCluIds().size());
2732 
2733         CluSetInfo updatedCluSet1 = client.updateCluSet(createdCluSet1.getId(), createdCluSet1, contextInfo);
2734 
2735         assertNotNull(updatedCluSet1);
2736         assertNotNull(updatedCluSet1.getCluIds());
2737         assertEquals(1, updatedCluSet1.getCluIds().size());
2738         assertTrue(updatedCluSet1.getCluIds().contains("CLU-2"));
2739 
2740         CluSetInfo getCluSet1 = client.getCluSet(updatedCluSet1.getId(), contextInfo);
2741 
2742         assertNotNull(getCluSet1);
2743         assertNotNull(getCluSet1.getCluIds());
2744         assertEquals(1, getCluSet1.getCluIds().size());
2745     }
2746 
2747     @Test
2748     public void test61CreateCluResult() throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, ReadOnlyException {
2749 
2750         contextInfo.setPrincipalId("123");
2751 
2752         CluResultInfo dto = new CluResultInfo();
2753         RichTextInfo desc = new RichTextInfo();
2754         desc.setPlain("Plain description");
2755         dto.setDescr(desc);
2756         dto.setCluId("CLU-1");
2757         dto.setStateKey("active");
2758         dto.setTypeKey("kuali.resultType.gradeCourseResult");
2759         dto.setEffectiveDate(new Date());
2760         dto.setExpirationDate(new Date());
2761 
2762         CluResultInfo cluResult = client.createCluResult("CLU-1", "kuali.resultType.gradeCourseResult", dto, contextInfo);
2763 
2764         assertNotNull(cluResult);
2765         assertNotNull(cluResult.getDescr());
2766         assertEquals(dto.getDescr().getPlain(), cluResult.getDescr().getPlain());
2767         assertNotNull(cluResult.getId());
2768         assertNotNull(cluResult.getCluId());
2769         assertEquals(dto.getCluId(), cluResult.getCluId());
2770         assertNotNull(cluResult.getTypeKey());
2771         assertEquals(dto.getTypeKey(), cluResult.getTypeKey());
2772         assertEquals(dto.getEffectiveDate(), cluResult.getEffectiveDate());
2773         assertEquals(dto.getExpirationDate(), cluResult.getExpirationDate());
2774     }
2775 
2776     @Test
2777     public void test62UpdateCluResult() throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, VersionMismatchException, ReadOnlyException {
2778 
2779         contextInfo.setPrincipalId("123");
2780 
2781         CluResultInfo dto = new CluResultInfo();
2782         RichTextInfo desc1 = new RichTextInfo();
2783         desc1.setPlain("Plain description");
2784         dto.setDescr(desc1);
2785         dto.setCluId("CLU-1");
2786         dto.setStateKey("Suspended");
2787         dto.setTypeKey("kuali.resultType.gradeCourseResult");
2788         dto.setEffectiveDate(new Date());
2789         dto.setExpirationDate(new Date());
2790 
2791         List<ResultOptionInfo> resultOptions = new ArrayList<ResultOptionInfo>();
2792         ResultOptionInfo option = new ResultOptionInfo();
2793         RichTextInfo desc2 = new RichTextInfo();
2794         desc2.setPlain("Plain description");
2795         option.setDescr(desc2);
2796         option.setEffectiveDate(new Date());
2797         option.setExpirationDate(new Date());
2798         option.setResultComponentId("kuali.resultComponent.grade.letter");
2799         option.setResultUsageTypeKey(null);
2800         option.setStateKey("Suspended");
2801         resultOptions.add(option);
2802 
2803         dto.setResultOptions(resultOptions);
2804 
2805         CluResultInfo createCluResult = client.createCluResult("CLU-1", "kuali.resultType.gradeCourseResult", dto, contextInfo);
2806         createCluResult = client.getCluResult(createCluResult.getId(), contextInfo);
2807 
2808         assertNotNull(createCluResult);
2809 
2810         createCluResult.setCluId("CLU-2");
2811         RichTextInfo desc3 = new RichTextInfo();
2812         desc3.setPlain("Plain description again");
2813         createCluResult.setDescr(desc3);
2814         createCluResult.setEffectiveDate(new Date());
2815         createCluResult.setExpirationDate(new Date());
2816         createCluResult.setStateKey("active");
2817         createCluResult.setTypeKey("kuali.resultType.creditCourseResult");
2818 
2819         RichTextInfo desc4 = new RichTextInfo();
2820         desc4.setPlain("Some more plain description");
2821         createCluResult.getResultOptions().get(0).setDescr(desc4);
2822         createCluResult.getResultOptions().get(0).setEffectiveDate(new Date());
2823         createCluResult.getResultOptions().get(0).setExpirationDate(new Date());
2824         createCluResult.getResultOptions().get(0).setResultComponentId("kuali.resultComponent.grade.passFail");
2825         createCluResult.getResultOptions().get(0).setResultUsageTypeKey("lrType.finalGrade");
2826         createCluResult.getResultOptions().get(0).setStateKey("active");
2827 
2828         CluResultInfo updateCluResult = client.updateCluResult(createCluResult.getId(), createCluResult, contextInfo);
2829         updateCluResult = client.getCluResult(updateCluResult.getId(), contextInfo);
2830 
2831         assertNotNull(updateCluResult);
2832         assertEquals(createCluResult.getId(), updateCluResult.getId());
2833         assertEquals(createCluResult.getDescr().getPlain(), updateCluResult.getDescr().getPlain());
2834         assertEquals(createCluResult.getEffectiveDate(), updateCluResult.getEffectiveDate());
2835         assertEquals(createCluResult.getExpirationDate(), updateCluResult.getExpirationDate());
2836         assertEquals(createCluResult.getStateKey(), updateCluResult.getStateKey());
2837         assertEquals(createCluResult.getTypeKey(), updateCluResult.getTypeKey());
2838         assertEquals(createCluResult.getResultOptions().get(0).getId(), updateCluResult.getResultOptions().get(0).getId());
2839         assertEquals(createCluResult.getResultOptions().get(0).getDescr().getPlain(), updateCluResult.getResultOptions().get(0).getDescr().getPlain());
2840         assertEquals(createCluResult.getResultOptions().get(0).getEffectiveDate(), updateCluResult.getResultOptions().get(0).getEffectiveDate());
2841         assertEquals(createCluResult.getResultOptions().get(0).getExpirationDate(), updateCluResult.getResultOptions().get(0).getExpirationDate());
2842         assertEquals(createCluResult.getResultOptions().get(0).getResultComponentId(), updateCluResult.getResultOptions().get(0).getResultComponentId());
2843         assertEquals(createCluResult.getResultOptions().get(0).getResultUsageTypeKey(), updateCluResult.getResultOptions().get(0).getResultUsageTypeKey());
2844         assertEquals(createCluResult.getResultOptions().get(0).getStateKey(), updateCluResult.getResultOptions().get(0).getStateKey());
2845     }
2846 
2847     @Test
2848     public void test63UpdateCluResult_RemoveAllCluResultOptions() throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, VersionMismatchException, ReadOnlyException {
2849 
2850         CluResultInfo createCluResult = client.createCluResult("CLU-1", "kuali.resultType.gradeCourseResult", dto, contextInfo);
2851         createCluResult = client.getCluResult(createCluResult.getId(), contextInfo);
2852 
2853         assertNotNull(createCluResult);
2854 
2855         // Clear all cluResultOptions
2856         createCluResult.getResultOptions().clear();
2857 
2858         CluResultInfo updateCluResult = client.updateCluResult(createCluResult.getId(), createCluResult, contextInfo);
2859         updateCluResult = client.getCluResult(updateCluResult.getId(), contextInfo);
2860 
2861         assertNotNull(updateCluResult);
2862         assertEquals(createCluResult.getId(), updateCluResult.getId());
2863         assertEquals(createCluResult.getResultOptions().isEmpty(), updateCluResult.getResultOptions().isEmpty());
2864     }
2865 
2866     @Test
2867     public void test64Versioning() throws ParseException, AlreadyExistsException, DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException, IllegalVersionSequencingException, ReadOnlyException, DependentObjectsExistException {
2868 
2869         CluInfo clu = createCluInfo();
2870         clu.setTypeKey("luType.shell.course");
2871         CluInfo cluV1 = client.createClu(clu.getTypeKey(), clu, contextInfo);
2872 
2873         try {
2874             //Try to set the start date in the past
2875             client.setCurrentCluVersion(cluV1.getId(),
2876                     DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("19000101"), contextInfo);
2877             assertTrue(false);
2878         } catch (Exception e) {
2879         }
2880 
2881 
2882 
2883         CluInfo justMadeCurrentClu = client.getClu(cluV1.getId(), contextInfo);
2884         assertTrue(justMadeCurrentClu.getVersion().getCurrentVersionStart().compareTo(new Date()) < 1);
2885         VersionDisplayInfo versionDisplayInfo = client.getCurrentVersion(CluServiceConstants.CLU_NAMESPACE_URI, justMadeCurrentClu.getVersion().getVersionIndId(), contextInfo);
2886         //Try to make a new versions from the current version
2887         CluInfo cluV2 = client.createNewCluVersion(cluV1.getVersion().getVersionIndId(), "CommentA", contextInfo);
2888         CluInfo cluV3 = client.createNewCluVersion(cluV1.getVersion().getVersionIndId(), "CommentB", contextInfo);
2889         versionDisplayInfo = client.getCurrentVersion(CluServiceConstants.CLU_NAMESPACE_URI, cluV1.getVersion().getVersionIndId(), contextInfo);
2890         assertEquals(cluV1.getId(), versionDisplayInfo.getId());
2891         assertEquals(cluV1.getVersion().getVersionIndId(), cluV2.getVersion().getVersionIndId());
2892         assertEquals(cluV1.getVersion().getVersionIndId(), cluV3.getVersion().getVersionIndId());
2893         client.setCurrentCluVersion(cluV3.getId(), null, contextInfo);
2894         versionDisplayInfo = client.getCurrentVersion(CluServiceConstants.CLU_NAMESPACE_URI, cluV1.getVersion().getVersionIndId(), contextInfo);
2895         assertEquals(versionDisplayInfo.getId(), cluV3.getId());
2896 
2897 
2898         SearchRequestInfo searchRequest = new SearchRequestInfo();
2899         SearchParamInfo param = new SearchParamInfo();
2900         param.setKey("lu.queryParam.cluVersionIndId");
2901         param.getValues().add(versionDisplayInfo.getVersionIndId());
2902         searchRequest.getParams().add(param);
2903         searchRequest.setSearchKey("lu.search.clu.versions");
2904         SearchResultInfo searchResult = client.search(searchRequest, ContextInfoTestUtility.getEnglishContextInfo());
2905         assertEquals(3, searchResult.getRows().size());
2906 
2907         StatusInfo status = client.deleteClu(cluV1.getId(), contextInfo);
2908         assertTrue(status.getIsSuccess());
2909         status = client.deleteClu(cluV2.getId(), contextInfo);
2910         assertTrue(status.getIsSuccess());
2911         status = client.deleteClu(cluV3.getId(), contextInfo);
2912         assertTrue(status.getIsSuccess());
2913 
2914     }
2915 
2916     private CluSetInfo createCluSetInfo() throws ParseException {
2917         CluSetInfo cluSetInfo = new CluSetInfo();
2918 
2919         RichTextInfo desc = new RichTextInfo();
2920         desc.setFormatted("<p>Formatted Desc</p>");
2921         desc.setPlain("plain");
2922         cluSetInfo.setDescr(desc);
2923         cluSetInfo.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20080101"));
2924         cluSetInfo.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20180101"));
2925         cluSetInfo.setName("Clu set name");
2926         cluSetInfo.setStateKey("draft");
2927         cluSetInfo.setTypeKey("kuali.cluset.course");
2928         return cluSetInfo;
2929     }
2930 
2931     private CluInfo createCluInfo() throws ParseException {
2932         CluInfo clu = new CluInfo();
2933 
2934         CluAccountingInfo accountingInfo = new CluAccountingInfo();
2935 
2936         if (accountingInfo.getAttributes() == null) {
2937             accountingInfo.setAttributes(new ArrayList<AttributeInfo>());
2938         }
2939         accountingInfo.getAttributes().add(new AttributeInfo("AccountingAttrKey1", "AccountingAttrValue1"));
2940         accountingInfo.getAttributes().add(new AttributeInfo("AccountingAttrKey2", "AccountingAttrValue2"));
2941         clu.setAccountingInfo(accountingInfo);
2942 
2943         CluIdentifierInfo officialIdentifier = new CluIdentifierInfo();
2944         officialIdentifier.setCode("offId-code");
2945         officialIdentifier.setDivision("offId-division");
2946         officialIdentifier.setLevel("offId-level");
2947         officialIdentifier.setLongName("offId-longName");
2948         officialIdentifier.setShortName("offId-shortName");
2949         officialIdentifier.setStateKey("offId-state");
2950         officialIdentifier.setTypeKey("offId-type");
2951         officialIdentifier.setVariation("offId-variation");
2952         officialIdentifier.setSuffixCode("offId-suffixcode");
2953         officialIdentifier.setOrgId("offId-orgid");
2954         clu.setOfficialIdentifier(officialIdentifier);
2955 
2956         CluIdentifierInfo cluId1 = new CluIdentifierInfo();
2957         cluId1.setCode("cluId1-code");
2958         cluId1.setDivision("cluId1-division");
2959         cluId1.setLevel("cluId1-level");
2960         cluId1.setLongName("cluId1-longName");
2961         cluId1.setShortName("cluId1-shortName");
2962         cluId1.setStateKey("cluId1-state");
2963         cluId1.setTypeKey("cluId1-type");
2964         cluId1.setVariation("cluId1-variation");
2965         cluId1.setSuffixCode("cluId1-suffixcode");
2966         cluId1.setOrgId("cluId1-orgid");
2967         clu.getAlternateIdentifiers().add(cluId1);
2968 
2969         CluIdentifierInfo cluId2 = new CluIdentifierInfo();
2970         cluId2.setCode("cluId2-code");
2971         cluId2.setDivision("cluId2-division");
2972         cluId2.setLevel("cluId2-level");
2973         cluId2.setLongName("cluId2-longName");
2974         cluId2.setShortName("cluId2-shortName");
2975         cluId2.setStateKey("cluId2-state");
2976         cluId2.setTypeKey("cluId2-type");
2977         cluId2.setVariation("cluId2-variation");
2978         cluId2.setSuffixCode("cluId2-suffixcode");
2979         cluId2.setOrgId("cluId2-orgid");
2980         clu.getAlternateIdentifiers().add(cluId2);
2981 
2982         if (clu.getAttributes() == null) {
2983             clu.setAttributes(new ArrayList<AttributeInfo>());
2984         }
2985         clu.getAttributes().add(new AttributeInfo("cluAttrKey1", "cluAttrValue1"));
2986         clu.getAttributes().add(new AttributeInfo("cluAttrKey2", "cluAttrValue2"));
2987 
2988         clu.setCanCreateLui(true);
2989 
2990         clu.setDefaultEnrollmentEstimate(545);
2991         clu.setDefaultMaximumEnrollment(999);
2992 
2993         RichTextInfo desc = new RichTextInfo();
2994         desc.setFormatted("<p>DESC FORMATTED</p>");
2995         desc.setPlain("DESC PLAIN");
2996         clu.setDescr(desc);
2997 
2998         clu.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20100203"));
2999         clu.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21001231"));
3000 
3001         clu.setIsEnrollable(true);
3002         clu.setIsHazardousForDisabledStudents(true);
3003 
3004         AffiliatedOrgInfo aforg = new AffiliatedOrgInfo();
3005         aforg.setOrgId("AFF-ORG1");
3006         aforg.setPercentage(35l);
3007 
3008         AffiliatedOrgInfo aforg1 = new AffiliatedOrgInfo();
3009         aforg1.setOrgId("AFF-ORG2");
3010         aforg1.setPercentage(65l);
3011 
3012         List<AffiliatedOrgInfo> affiliatedOrgs = new ArrayList<AffiliatedOrgInfo>();
3013         affiliatedOrgs.add(aforg);
3014         affiliatedOrgs.add(aforg1);
3015 
3016         CurrencyAmountInfo ca = new CurrencyAmountInfo();
3017         ca.setCurrencyQuantity(100);
3018         ca.setCurrencyTypeKey("DLLR");
3019 
3020         CurrencyAmountInfo ca1 = new CurrencyAmountInfo();
3021         ca.setCurrencyQuantity(200);
3022         ca.setCurrencyTypeKey("DLLR");
3023 
3024         List<CurrencyAmountInfo> caList = new ArrayList<CurrencyAmountInfo>();
3025         caList.add(ca);
3026 
3027         List<CurrencyAmountInfo> caList1 = new ArrayList<CurrencyAmountInfo>();
3028         caList.add(ca);
3029         caList.add(ca1);
3030 
3031         RichTextInfo cfRecDesc = new RichTextInfo();
3032         cfRecDesc.setPlain("Clu Fee Record");
3033 
3034         CluFeeRecordInfo feeRec = new CluFeeRecordInfo();
3035         feeRec.setAffiliatedOrgs(affiliatedOrgs);
3036         feeRec.setFeeAmounts(caList);
3037         feeRec.setFeeType("FEE-TYPE-X");
3038         feeRec.setRateType("RATE-TYPE-X");
3039         feeRec.setDescr(cfRecDesc);
3040 
3041         CluFeeRecordInfo feeRec1 = new CluFeeRecordInfo();
3042         feeRec1.setAffiliatedOrgs(affiliatedOrgs);
3043         feeRec1.setFeeAmounts(caList1);
3044         feeRec1.setFeeType("FEE-TYPE-Y");
3045         feeRec1.setRateType("RATE-TYPE-Y");
3046 
3047         List<CluFeeRecordInfo> feeRecList = new ArrayList<CluFeeRecordInfo>();
3048         feeRecList.add(feeRec);
3049         feeRecList.add(feeRec1);
3050 
3051         RichTextInfo cfDesc = new RichTextInfo();
3052         cfDesc.setPlain("Clu Fee");
3053 
3054         CluFeeInfo feeInfo = new CluFeeInfo();
3055         feeInfo.getAttributes().add(new AttributeInfo("FeeAttrKey1", "FeeAttrValue1"));
3056         feeInfo.getAttributes().add(new AttributeInfo("FeeAttrKey2", "FeeAttrValue2"));
3057         feeInfo.setCluFeeRecords(feeRecList);
3058         feeInfo.setDescr(cfDesc);
3059         clu.setFeeInfo(feeInfo);
3060 
3061         clu.setIsHasEarlyDropDeadline(true);
3062 
3063         clu.setIsHazardousForDisabledStudents(true);
3064 
3065         CluInstructorInfo primaryInstructor = new CluInstructorInfo();
3066         primaryInstructor.setOrgId("EXT-orgId-1");
3067         primaryInstructor.setPersonId("EXT-personId-1");
3068         primaryInstructor.getAttributes().add(new AttributeInfo("PrimaryInstAttrKey1", "PrimaryInstAttrValue1"));
3069         primaryInstructor.getAttributes().add(new AttributeInfo("PrimaryInstAttrKey2", "PrimaryInstAttrValue2"));
3070         clu.setPrimaryInstructor(primaryInstructor);
3071 
3072         CluInstructorInfo instructor1 = new CluInstructorInfo();
3073         instructor1.setOrgId("EXT-orgId-2");
3074         instructor1.setPersonId("EXT-personId-2");
3075         instructor1.getAttributes().add(new AttributeInfo("Inst1AttrKey1", "Inst1AttrValue1"));
3076         instructor1.getAttributes().add(new AttributeInfo("Inst1AttrKey2", "Inst1AttrValue2"));
3077         clu.getInstructors().add(instructor1);
3078 
3079         CluInstructorInfo instructor2 = new CluInstructorInfo();
3080         instructor2.setOrgId("EXT-orgId-3");
3081         instructor2.setPersonId("EXT-personId-3");
3082         instructor2.getAttributes().add(new AttributeInfo("Inst2AttrKey1", "Inst2AttrValue1"));
3083         instructor2.getAttributes().add(new AttributeInfo("Inst2AttrKey2", "Inst2AttrValue2"));
3084         clu.getInstructors().add(instructor2);
3085 
3086         LuCodeInfo luCode1 = new LuCodeInfo();
3087         luCode1.setId("luCode1.key");
3088         RichTextInfo loCode1desc = new RichTextInfo();
3089         loCode1desc.setPlain("luCode1-desc");
3090         luCode1.setDescr(loCode1desc);
3091         luCode1.setValue("luCode1-value");
3092         luCode1.getAttributes().add(new AttributeInfo("luCode1AttrKey1", "luCode1AttrValue1"));
3093         luCode1.getAttributes().add(new AttributeInfo("luCode1AttrKey2", "luCode1AttrValue2"));
3094         luCode1.setType("kuali.someKindOfLuCode");
3095         clu.getLuCodes().add(luCode1);
3096 
3097         LuCodeInfo luCode2 = new LuCodeInfo();
3098         luCode2.setId("luCode2.key");
3099         RichTextInfo loCode2desc = new RichTextInfo();
3100         loCode2desc.setPlain("luCode2-desc");
3101         luCode2.setDescr(loCode2desc);
3102         luCode2.setValue("luCode2-value");
3103         luCode2.getAttributes().add(new AttributeInfo("luCode2AttrKey1", "luCode2AttrValue1"));
3104         luCode2.getAttributes().add(new AttributeInfo("luCode2AttrKey2", "luCode2AttrValue2"));
3105         luCode2.setType("kuali.someKindOfLuCode");
3106         clu.getLuCodes().add(luCode2);
3107 
3108         RichTextInfo marketingDesc = new RichTextInfo();
3109         marketingDesc.setFormatted("<p>marketingDesc FORMATTED</p>");
3110         marketingDesc.setPlain("marketingDesc PLAIN");
3111 
3112         clu.setNextReviewPeriod("nextReviewPeriod");
3113 
3114         clu.getOfferedAtpTypes().add("offeredAtpType1");
3115         clu.getOfferedAtpTypes().add("offeredAtpType2");
3116 
3117 
3118         CluInstructorInfo pubPrimaryInstructor = new CluInstructorInfo();
3119         pubPrimaryInstructor.setOrgId("EXT-orgId-234");
3120         pubPrimaryInstructor.setPersonId("EXT-personId-2451");
3121         pubPrimaryInstructor.getAttributes().add(new AttributeInfo("PubPrimaryInstAttrKey1", "PubPrimaryInstAttrValue1"));
3122         pubPrimaryInstructor.getAttributes().add(new AttributeInfo("PubPrimaryInstAttrKey2", "PubPrimaryInstAttrValue2"));
3123 
3124         CluInstructorInfo pubInstructor1 = new CluInstructorInfo();
3125         pubInstructor1.setOrgId("EXT-orgId-2");
3126         pubInstructor1.setPersonId("EXT-personId-2");
3127         pubInstructor1.getAttributes().add(new AttributeInfo("PubInst1AttrKey1", "PubInst1AttrValue1"));
3128         pubInstructor1.getAttributes().add(new AttributeInfo("PubInst1AttrKey2", "PubInst1AttrValue2"));
3129 
3130         CluInstructorInfo pubInstructor2 = new CluInstructorInfo();
3131         pubInstructor2.setOrgId("EXT-orgId-3");
3132         pubInstructor2.setPersonId("EXT-personId-3");
3133         pubInstructor2.getAttributes().add(new AttributeInfo("PubInst2AttrKey1", "PubInst2AttrValue1"));
3134         pubInstructor2.getAttributes().add(new AttributeInfo("PubInst2AttrKey2", "PubInst2AttrValue2"));
3135 
3136         clu.setReferenceURL("http://student.kuali.org/clus");
3137 
3138         clu.setStateKey("Clu-state");
3139 
3140         TimeAmountInfo stdDuration = new TimeAmountInfo();
3141         stdDuration.setAtpDurationTypeKey("EXT-stdDuration-Id1");
3142         stdDuration.setTimeQuantity(new Integer(7867));
3143         clu.setStdDuration(stdDuration);
3144 
3145         clu.setTypeKey("kuali.SomeKindOfClu");
3146 
3147         createCampusLocationList(clu);
3148 
3149         createIntensity(clu);
3150 
3151         createAccreditationList(clu);
3152 
3153         createAdminOrgs(clu);
3154 
3155         return clu;
3156     }
3157 
3158     private void createAdminOrgs(CluInfo clu) {
3159         AdminOrgInfo adminOrg = new AdminOrgInfo();
3160         adminOrg.setOrgId("PRIMARY-ADMIN-ORG-ID");
3161         adminOrg.getAttributes().add(new AttributeInfo("PrimaryAdminOrgAttrKey1", "PrimaryAdminOrgAttrValue1"));
3162         adminOrg.getAttributes().add(new AttributeInfo("PrimaryAdminOrgAttrKey2", "PrimaryAdminOrgAttrValue2"));
3163         adminOrg.setTypeKey("kuali.altadminType1");
3164         adminOrg.setStateKey("kuali.altAdminState1");
3165 
3166         clu.getAdminOrgs().add(adminOrg);
3167         AdminOrgInfo altAdminOrg1 = new AdminOrgInfo();
3168         altAdminOrg1.setOrgId("ALT-ADMIN-ORG-ID1");
3169         altAdminOrg1.getAttributes().add(new AttributeInfo("AltAdminOrg1AttrKey1", "AltAdminOrg1AttrValue1"));
3170         altAdminOrg1.getAttributes().add(new AttributeInfo("AltAdminOrg1AttrKey2", "AltAdminOrg1AttrValue2"));
3171         altAdminOrg1.getAttributes().add(new AttributeInfo("AltAdminOrg1AttrKey3", "AltAdminOrg1AttrValue3"));
3172         altAdminOrg1.setTypeKey("kuali.altadminType1");
3173         altAdminOrg1.setStateKey("kuali.altadminState1");
3174 
3175         AdminOrgInfo altAdminOrg2 = new AdminOrgInfo();
3176         altAdminOrg2.setOrgId("ALT-ADMIN-ORG-ID2");
3177         altAdminOrg2.getAttributes().add(new AttributeInfo("AltAdminOrg2AttrKey1", "AltAdminOrg2AttrValue1"));
3178         altAdminOrg2.getAttributes().add(new AttributeInfo("AltAdminOrg2AttrKey2", "AltAdminOrg2AttrValue2"));
3179         altAdminOrg2.setTypeKey("kuali.altadminType1");
3180         altAdminOrg2.setStateKey("kuali.altadminState1");
3181 
3182         clu.getAdminOrgs().add(altAdminOrg1);
3183         clu.getAdminOrgs().add(altAdminOrg2);
3184 
3185     }
3186 
3187     private void checkAdminOrgsCreate(CluInfo clu) {
3188 
3189         assertEquals("PRIMARY-ADMIN-ORG-ID", clu.getAdminOrgs().get(0)
3190                 .getOrgId());
3191         assertEquals(2, clu.getAdminOrgs().get(0).getAttributes().size());
3192         assertEquals("PrimaryAdminOrgAttrValue1", clu.getAdminOrgs().get(0).getAttributeValue("PrimaryAdminOrgAttrKey1"));
3193         assertEquals("PrimaryAdminOrgAttrValue2", clu.getAdminOrgs().get(0).getAttributeValue("PrimaryAdminOrgAttrKey2"));
3194 
3195         assertEquals("ALT-ADMIN-ORG-ID1", clu.getAdminOrgs().get(1).getOrgId());
3196         assertEquals(3, clu.getAdminOrgs().get(1).getAttributes().size());
3197         assertEquals("AltAdminOrg1AttrValue1", clu.getAdminOrgs().get(1).getAttributeValue("AltAdminOrg1AttrKey1"));
3198         assertEquals("AltAdminOrg1AttrValue2", clu.getAdminOrgs().get(1).getAttributeValue("AltAdminOrg1AttrKey2"));
3199         assertEquals("AltAdminOrg1AttrValue3", clu.getAdminOrgs().get(1).getAttributeValue("AltAdminOrg1AttrKey3"));
3200 
3201         assertEquals("ALT-ADMIN-ORG-ID2", clu.getAdminOrgs().get(2).getOrgId());
3202         assertEquals(2, clu.getAdminOrgs().get(2).getAttributes().size());
3203         assertEquals("AltAdminOrg2AttrValue1", clu.getAdminOrgs().get(2).getAttributeValue("AltAdminOrg2AttrKey1"));
3204         assertEquals("AltAdminOrg2AttrValue2", clu.getAdminOrgs().get(2).getAttributeValue("AltAdminOrg2AttrKey2"));
3205     }
3206 
3207     private void updateAdminOrgs(CluInfo clu) {
3208         clu.getAdminOrgs().get(0).setId("adminOrg121");
3209         clu.getAdminOrgs().get(0).setOrgId("UPD-PRIMARY-ADMIN-ORG-ID");
3210         clu.getAdminOrgs().get(0).getAttributes().add(new AttributeInfo("PrimaryAdminOrgAttrKey3", "PrimaryAdminOrgAttrValue3"));
3211         clu.getAdminOrgs().get(0).getAttributes().remove(1);
3212         clu.getAdminOrgs().get(0).getAttributes().add(new AttributeInfo("PrimaryAdminOrgAttrKey4", "PrimaryAdminOrgAttrValue4"));
3213 
3214         AdminOrgInfo altAdminOrg3 = new AdminOrgInfo();
3215         altAdminOrg3.setOrgId("UPD-ADMIN-ORG-ID3");
3216         altAdminOrg3.getAttributes().add(new AttributeInfo("UPDAdminOrg3AttrKey1", "UPDAdminOrg3AttrKey1"));
3217         altAdminOrg3.getAttributes().add(new AttributeInfo("UPDAdminOrg3AttrKey2", "UPDAdminOrg3AttrKey1"));
3218         altAdminOrg3.setTypeKey("kuali.testType");
3219 
3220         clu.getAdminOrgs().remove(1);
3221         clu.getAdminOrgs().add(altAdminOrg3);
3222     }
3223 
3224     private void checkAdminOrgUpdate(CluInfo clu) {
3225 
3226         assertEquals("UPD-PRIMARY-ADMIN-ORG-ID", clu.getAdminOrgs().get(0)
3227                 .getOrgId());
3228         assertEquals(3, clu.getAdminOrgs().get(0).getAttributes().size());
3229         assertEquals("PrimaryAdminOrgAttrValue4", clu.getAdminOrgs().get(0).getAttributeValue("PrimaryAdminOrgAttrKey4"));
3230         assertNull(clu.getAdminOrgs().get(0).getAttributeValue("PrimaryAdminOrgAttrKey2"));
3231         assertEquals(3, clu.getAdminOrgs().size());
3232         assertEquals("UPD-PRIMARY-ADMIN-ORG-ID", clu.getAdminOrgs().get(0)
3233                 .getOrgId());
3234         assertEquals(3, clu.getAdminOrgs().get(0).getAttributes()
3235                 .size());
3236         assertEquals("PrimaryAdminOrgAttrValue1", clu.getAdminOrgs().get(0).getAttributeValue("PrimaryAdminOrgAttrKey1"));
3237         assertEquals("PrimaryAdminOrgAttrValue4", clu.getAdminOrgs().get(0).getAttributeValue("PrimaryAdminOrgAttrKey4"));
3238         assertEquals("PrimaryAdminOrgAttrValue3", clu.getAdminOrgs().get(0).getAttributeValue("PrimaryAdminOrgAttrKey3"));
3239         assertEquals("ALT-ADMIN-ORG-ID2", clu.getAdminOrgs().get(1)
3240                 .getOrgId());
3241         assertEquals(2, clu.getAdminOrgs().get(1).getAttributes()
3242                 .size());
3243         assertEquals("AltAdminOrg2AttrValue2", clu.getAdminOrgs().get(1).getAttributeValue("AltAdminOrg2AttrKey2"));
3244         assertEquals("AltAdminOrg2AttrValue1", clu.getAdminOrgs().get(1).getAttributeValue("AltAdminOrg2AttrKey1"));
3245     }
3246 
3247     private void createAccreditationList(CluInfo clu) throws ParseException {
3248         AccreditationInfo accreditationOrg1 = new AccreditationInfo();
3249         accreditationOrg1.setOrgId("EXT-orgId-1");
3250         accreditationOrg1.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20100203"));
3251         accreditationOrg1.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21001231"));
3252         accreditationOrg1.getAttributes().add(new AttributeInfo("Accred1AttrKey1", "Accred1AttrValue1"));
3253         accreditationOrg1.getAttributes().add(new AttributeInfo("Accred1AttrKey2", "Accred1AttrValue2"));
3254 
3255         AccreditationInfo accreditationOrg2 = new AccreditationInfo();
3256         accreditationOrg2.setOrgId("EXT-orgId-2");
3257         accreditationOrg2.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20110203"));
3258         accreditationOrg2.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21011231"));
3259         accreditationOrg2.getAttributes().add(new AttributeInfo("Accred2AttrKey1", "Accred2AttrValue1"));
3260         accreditationOrg2.getAttributes().add(new AttributeInfo("Accred2AttrKey2", "Accred2AttrValue2"));
3261 
3262         clu.getAccreditations().add(accreditationOrg1);
3263         clu.getAccreditations().add(accreditationOrg2);
3264     }
3265 
3266     private void checkAccreditationListCreate(CluInfo clu)
3267             throws ParseException {
3268 
3269         assertEquals(2, clu.getAccreditations().size());
3270 
3271         assertEquals("EXT-orgId-1", clu.getAccreditations().get(0)
3272                 .getOrgId());
3273         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20100203"), clu.getAccreditations().get(0)
3274                 .getEffectiveDate());
3275         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21001231"), clu.getAccreditations().get(0)
3276                 .getExpirationDate());
3277         assertEquals(2, clu.getAccreditations().get(0).getAttributes()
3278                 .size());
3279         assertEquals("Accred1AttrValue1", clu.getAccreditations().get(0).getAttributeValue("Accred1AttrKey1"));
3280         assertEquals("Accred1AttrValue2", clu.getAccreditations().get(0).getAttributeValue("Accred1AttrKey2"));
3281 
3282         assertEquals("EXT-orgId-2", clu.getAccreditations().get(1)
3283                 .getOrgId());
3284         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20110203"), clu.getAccreditations().get(1)
3285                 .getEffectiveDate());
3286         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21011231"), clu.getAccreditations().get(1)
3287                 .getExpirationDate());
3288         assertEquals(2, clu.getAccreditations().get(1).getAttributes()
3289                 .size());
3290         assertEquals("Accred2AttrValue1", clu.getAccreditations().get(1).getAttributeValue("Accred2AttrKey1"));
3291         assertEquals("Accred2AttrValue2", clu.getAccreditations().get(1).getAttributeValue("Accred2AttrKey2"));
3292     }
3293 
3294     private void updateAccreditationList(CluInfo clu) throws ParseException {
3295 
3296         AccreditationInfo accreditationOrg3 = new AccreditationInfo();
3297         accreditationOrg3.setOrgId("EXT-orgId-3");
3298         accreditationOrg3.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20120203"));
3299         accreditationOrg3.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21021231"));
3300 
3301         AccreditationInfo accreditationOrg4 = new AccreditationInfo();
3302         accreditationOrg4.setOrgId("EXT-orgId-4");
3303         accreditationOrg4.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20130203"));
3304         accreditationOrg4.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21031231"));
3305         accreditationOrg4.getAttributes().add(new AttributeInfo("Accred4AttrKey1", "Accred4AttrValue1"));
3306 
3307         clu.getAccreditations().add(accreditationOrg3);
3308         clu.getAccreditations().add(accreditationOrg4);
3309 
3310         for (int i = 0; i < clu.getAccreditations().get(0).getAttributes().size(); i++) {
3311             String attributeKey = clu.getAccreditations().get(0).getAttributes().get(i).getKey();
3312             if (attributeKey.equals("Accred1AttrKey1")) {
3313                 clu.getAccreditations().get(0).getAttributes().set(i, new AttributeInfo("Accred1AttrKey1", "Accred1AttrValue1-UPD"));
3314             } else if (attributeKey.equals("Accred1AttrKey2")) {
3315                 clu.getAccreditations().get(0).getAttributes().remove(i);
3316             }
3317         }
3318 
3319         clu.getAccreditations().remove(1);
3320     }
3321 
3322     private void checkAccreditationListUpdate(CluInfo clu)
3323             throws ParseException {
3324 
3325         assertEquals(3, clu.getAccreditations().size());
3326 
3327         assertEquals("EXT-orgId-1", clu.getAccreditations().get(0)
3328                 .getOrgId());
3329         assertEquals(1, clu.getAccreditations().get(0).getAttributes()
3330                 .size());
3331         assertEquals("Accred1AttrValue1-UPD", clu.getAccreditations().get(0).getAttributeValue("Accred1AttrKey1"));
3332 
3333         assertEquals("EXT-orgId-3", clu.getAccreditations().get(1)
3334                 .getOrgId());
3335         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20120203"), clu.getAccreditations().get(1)
3336                 .getEffectiveDate());
3337         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21021231"), clu.getAccreditations().get(1)
3338                 .getExpirationDate());
3339         assertEquals(0, clu.getAccreditations().get(1).getAttributes()
3340                 .size());
3341 
3342         assertEquals("EXT-orgId-4", clu.getAccreditations().get(2)
3343                 .getOrgId());
3344         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20130203"), clu.getAccreditations().get(2)
3345                 .getEffectiveDate());
3346         assertEquals(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("21031231"), clu.getAccreditations().get(2)
3347                 .getExpirationDate());
3348         assertEquals(1, clu.getAccreditations().get(2).getAttributes()
3349                 .size());
3350         assertEquals("Accred4AttrValue1", clu.getAccreditations().get(2).getAttributeValue("Accred4AttrKey1"));
3351 
3352     }
3353 
3354     private void createIntensity(CluInfo clu) {
3355         AmountInfo intensity = new AmountInfo();
3356         intensity.setUnitTypeKey("EXT-intensity-Id1");
3357         intensity.setUnitQuantity("123");
3358         clu.setIntensity(intensity);
3359     }
3360 
3361     private void checkIntensityCreate(CluInfo clu) {
3362         assertEquals("EXT-intensity-Id1", clu.getIntensity()
3363                 .getUnitTypeKey());
3364         assertEquals("123", clu.getIntensity().getUnitQuantity());
3365     }
3366 
3367     private void updateIntensity(CluInfo clu) {
3368         clu.getIntensity().setUnitTypeKey("UPD-intensity-Id1");
3369         clu.getIntensity().setUnitQuantity("456");
3370     }
3371 
3372     private void checkIntensityUpdate(CluInfo clu) {
3373         assertEquals("UPD-intensity-Id1", clu.getIntensity()
3374                 .getUnitTypeKey());
3375         assertEquals("456", clu.getIntensity().getUnitQuantity());
3376 
3377     }
3378 
3379     private void createCampusLocationList(CluInfo clu) {
3380         clu.getCampusLocations().add("EXT-Campus-Location-1");
3381         clu.getCampusLocations().add("EXT-Campus-Location-2");
3382     }
3383 
3384     private void checkCampusLocationCreate(CluInfo clu) {
3385         assertEquals(2, clu.getCampusLocations().size());
3386         assertEquals("EXT-Campus-Location-1", clu.getCampusLocations()
3387                 .get(0));
3388         assertEquals("EXT-Campus-Location-2", clu.getCampusLocations()
3389                 .get(1));
3390     }
3391 
3392     private void updateCampusLocationList(CluInfo clu) {
3393         clu.getCampusLocations().add("EXT-Campus-Location-3");
3394         clu.getCampusLocations().add("EXT-Campus-Location-4");
3395         clu.getCampusLocations().remove(0);
3396     }
3397 
3398     private void checkCampusLocationUpdate(CluInfo clu) {
3399         assertEquals(3, clu.getCampusLocations().size());
3400         assertEquals("EXT-Campus-Location-2", clu.getCampusLocations()
3401                 .get(0));
3402         assertEquals("EXT-Campus-Location-3", clu.getCampusLocations()
3403                 .get(1));
3404         assertEquals("EXT-Campus-Location-4", clu.getCampusLocations()
3405                 .get(2));
3406     }
3407 
3408     @Test
3409     public void test65SearchForCluInCluSets() throws Exception {
3410         SearchRequestInfo searchRequest = new SearchRequestInfo();
3411         searchRequest.setSearchKey("cluset.search.generic");
3412 
3413         List<SearchParamInfo> queryParamValueList = new ArrayList<SearchParamInfo>();
3414         SearchParamInfo searchParam = new SearchParamInfo();
3415         searchParam.setKey("cluset.queryParam.luOptionalId");
3416         searchParam.getValues().add("CLU-5");
3417         queryParamValueList.add(searchParam);
3418 
3419         searchRequest.setParams(queryParamValueList);
3420         SearchResultInfo cluSets = client.search(searchRequest, ContextInfoTestUtility.getEnglishContextInfo());
3421 
3422         Assert.assertEquals(2, cluSets.getRows().size());
3423     }
3424 
3425     @Test
3426     public void test66SearchForCluInCluSets_EmptyResult() throws Exception {
3427         SearchRequestInfo searchRequest = new SearchRequestInfo();
3428         searchRequest.setSearchKey("cluset.search.generic");
3429 
3430         List<SearchParamInfo> queryParamValueList = new ArrayList<SearchParamInfo>();
3431         SearchParamInfo searchParam = new SearchParamInfo();
3432         searchParam.setKey("lu.queryParam.luOptionalId");
3433         searchParam.getValues().add("XXX");
3434         queryParamValueList.add(searchParam);
3435 
3436         searchRequest.setParams(queryParamValueList);
3437         SearchResultInfo cluSets = client.search(searchRequest, ContextInfoTestUtility.getEnglishContextInfo());
3438 
3439         Assert.assertEquals(0, cluSets.getRows().size());
3440     }
3441 
3442     @Test
3443     public void test67SearchForCluInCluRelations() throws Exception {
3444         SearchRequestInfo searchRequest = new SearchRequestInfo();
3445         searchRequest.setSearchKey("lu.search.cluCluRelation");
3446 
3447         List<SearchParamInfo> queryParamValueList = new ArrayList<SearchParamInfo>();
3448         SearchParamInfo searchParam = new SearchParamInfo();
3449         searchParam.setKey("lu.queryParam.luOptionalId");
3450         searchParam.getValues().add("CLU-1");
3451         queryParamValueList.add(searchParam);
3452 
3453         searchRequest.setParams(queryParamValueList);
3454         SearchResultInfo clus = client.search(searchRequest, ContextInfoTestUtility.getEnglishContextInfo());
3455 
3456         Assert.assertEquals(2, clus.getRows().size());
3457     }
3458 
3459     @Test
3460     public void test68SearchForCluInCluRelations_EmptyResult() throws Exception {
3461         SearchRequestInfo searchRequest = new SearchRequestInfo();
3462         searchRequest.setSearchKey("lu.search.cluCluRelation");
3463 
3464         List<SearchParamInfo> queryParamValueList = new ArrayList<SearchParamInfo>();
3465         SearchParamInfo searchParam = new SearchParamInfo();
3466         searchParam.setKey("lu.queryParam.luOptionalId");
3467         searchParam.getValues().add("XXX");
3468         queryParamValueList.add(searchParam);
3469 
3470         searchRequest.setParams(queryParamValueList);
3471         SearchResultInfo clus = client.search(searchRequest, ContextInfoTestUtility.getEnglishContextInfo());
3472 
3473         Assert.assertEquals(0, clus.getRows().size());
3474     }
3475 
3476     @Test
3477     public void test69CluPublicationCrud() throws ParseException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DoesNotExistException, VersionMismatchException, ReadOnlyException {
3478         //Setup
3479 
3480         FieldInfo variant;
3481 
3482         CluPublicationInfo cluPublication1 = new CluPublicationInfo();
3483         cluPublication1.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20120203"));
3484         cluPublication1.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20130203"));
3485         cluPublication1.setStartCycle("StartCycle1");
3486         cluPublication1.setEndCycle("EndCycle1");
3487         cluPublication1.setStateKey("clupubState1");
3488         cluPublication1.setTypeKey("cluPublication.Test.Type.1");
3489         cluPublication1.setCluId("CLU-1");
3490         variant = new FieldInfo();
3491         variant.setId("field1.one");
3492         variant.setValue("value1.one");
3493         cluPublication1.getVariants().add(variant);
3494         variant = new FieldInfo();
3495         variant.setId("field1.two");
3496         variant.setValue("value1.two");
3497         cluPublication1.getVariants().add(variant);
3498 
3499         CluPublicationInfo cluPublication2 = new CluPublicationInfo();
3500         cluPublication2.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20120203"));
3501         cluPublication2.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20130203"));
3502         cluPublication2.setStartCycle("StartCycle2");
3503         cluPublication2.setEndCycle("EndCycle2");
3504         cluPublication2.setStateKey("clupubState2");
3505         cluPublication2.setTypeKey("cluPublication.Test.Type.1");
3506         cluPublication2.setCluId("CLU-2");
3507         variant = new FieldInfo();
3508         variant.setId("field2.one");
3509         variant.setValue("value2.one");
3510         cluPublication2.getVariants().add(variant);
3511         variant = new FieldInfo();
3512         variant.setId("field2.two");
3513         variant.setValue("value2.two");
3514         cluPublication2.getVariants().add(variant);
3515 
3516         CluPublicationInfo cluPublication3 = new CluPublicationInfo();
3517         cluPublication3.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20120203"));
3518         cluPublication3.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20130203"));
3519         cluPublication3.setStartCycle("StartCycle3");
3520         cluPublication3.setEndCycle("EndCycle3");
3521         cluPublication3.setStateKey("clupubState3");
3522         cluPublication3.setTypeKey("cluPublication.Test.Type.2");
3523         cluPublication3.setCluId("CLU-2");
3524         variant = new FieldInfo();
3525         variant.setId("field3.one");
3526         variant.setValue("value3.one");
3527         cluPublication3.getVariants().add(variant);
3528         variant = new FieldInfo();
3529         variant.setId("field3.two");
3530         variant.setValue("value3.two");
3531         cluPublication3.getVariants().add(variant);
3532 
3533 
3534         CluPublicationInfo createdCluPub1 = client.createCluPublication(cluPublication1.getCluId(), cluPublication1.getTypeKey(), cluPublication1, contextInfo);
3535         CluPublicationInfo createdCluPub2 = client.createCluPublication(cluPublication2.getCluId(), cluPublication2.getTypeKey(), cluPublication2, contextInfo);
3536         CluPublicationInfo createdCluPub3 = client.createCluPublication(cluPublication3.getCluId(), cluPublication3.getTypeKey(), cluPublication3, contextInfo);
3537 
3538 
3539         assertNotNull(createdCluPub1.getId());
3540         assertEquals(cluPublication1.getEffectiveDate(), createdCluPub1.getEffectiveDate());
3541         assertEquals(cluPublication1.getExpirationDate(), createdCluPub1.getExpirationDate());
3542         assertEquals(cluPublication1.getStartCycle(), createdCluPub1.getStartCycle());
3543         assertEquals(cluPublication1.getEndCycle(), createdCluPub1.getEndCycle());
3544         assertEquals(cluPublication1.getStateKey(), createdCluPub1.getStateKey());
3545         assertEquals(cluPublication1.getTypeKey(), createdCluPub1.getTypeKey());
3546         assertEquals(cluPublication1.getCluId(), createdCluPub1.getCluId());
3547         assertNotNull(createdCluPub3);
3548 
3549         //Test gets
3550         CluPublicationInfo gotCluPub1 = client.getCluPublication(createdCluPub1.getId(), contextInfo);
3551         assertEquals(createdCluPub1.getId(), gotCluPub1.getId());
3552 
3553         List<CluPublicationInfo> gotCluPubsByType = client.getCluPublicationsByType("cluPublication.Test.Type.1", contextInfo);
3554         assertEquals(2, gotCluPubsByType.size());
3555 
3556         List<CluPublicationInfo> gotCluPubsByClu = client.getCluPublicationsByClu("CLU-2", contextInfo);
3557         assertEquals(2, gotCluPubsByClu.size());
3558 
3559         //Change some values
3560         createdCluPub2.setEffectiveDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20020203"));
3561         createdCluPub2.setExpirationDate(DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20030203"));
3562         createdCluPub2.setStartCycle("StartCycle2U");
3563         createdCluPub2.setEndCycle("EndCycle2U");
3564         createdCluPub2.setStateKey("clupubState2U");
3565         createdCluPub2.setTypeKey("cluPublication.Test.Type.2");
3566         createdCluPub2.setCluId("CLU-1");
3567         createdCluPub2.getVariants().clear();
3568         variant = new FieldInfo();
3569         variant.setId("field2.oneU");
3570         variant.setValue("value2.oneU");
3571         createdCluPub2.getVariants().add(variant);
3572         variant = new FieldInfo();
3573         variant.setId("field2.twoU");
3574         variant.setValue("value2.twoU");
3575         createdCluPub2.getVariants().add(variant);
3576 
3577         CluPublicationInfo updated = client.updateCluPublication(createdCluPub2.getId(), createdCluPub2, contextInfo);
3578         //Test version mismatch
3579         try {
3580             client.updateCluPublication(createdCluPub2.getId(), createdCluPub2, contextInfo);
3581             assertTrue(false);
3582         } catch (VersionMismatchException e) {
3583             assertTrue(true);
3584         }
3585 
3586 
3587         //check that updated has correct values
3588         assertEquals(createdCluPub2.getId(), updated.getId());
3589         assertEquals(createdCluPub2.getEffectiveDate(), updated.getEffectiveDate());
3590         assertEquals(createdCluPub2.getExpirationDate(), updated.getExpirationDate());
3591         assertEquals(createdCluPub2.getStartCycle(), updated.getStartCycle());
3592         assertEquals(createdCluPub2.getEndCycle(), updated.getEndCycle());
3593         assertEquals(createdCluPub2.getStateKey(), updated.getStateKey());
3594         assertEquals(createdCluPub2.getTypeKey(), updated.getTypeKey());
3595         assertEquals(createdCluPub2.getCluId(), updated.getCluId());
3596 
3597         assertEquals(2, updated.getVariants().size());
3598         assertTrue(("field2.oneU".equals(updated.getVariants().get(0).getId())
3599                 && "value2.oneU".equals(updated.getVariants().get(0).getValue()))
3600                 ||
3601                 ("field2.twoU".equals(updated.getVariants().get(0).getId())
3602                         && "value2.twoU".equals(updated.getVariants().get(0).getValue())));
3603     }
3604 
3605     @Test
3606     public void SearchForClus() throws AlreadyExistsException,
3607             DataValidationErrorException, DoesNotExistException,
3608             InvalidParameterException, MissingParameterException,
3609             OperationFailedException, PermissionDeniedException,
3610             ParseException, VersionMismatchException {
3611 
3612         String id ="83e46ae9-875e-4970-811f-0719a6b260a2";
3613 
3614         QueryByCriteria.Builder qbcBuilder = QueryByCriteria.Builder.create();
3615         qbcBuilder.setPredicates(PredicateFactory.equal("id", id));
3616 
3617         List<CluInfo> cluInfos = this.searchForClus(qbcBuilder.build());
3618         assertEquals(1, cluInfos.size());
3619 
3620         Date firstDate = DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20010101");
3621         Date secondDate = DateFormatters.YEAR_MONTH_DAY_CONCAT_DATE_FORMATTER.parse("20020201");
3622 
3623         qbcBuilder = QueryByCriteria.Builder.create();
3624         qbcBuilder.setPredicates(PredicateFactory.greaterThanOrEqual("effectiveDate", firstDate),
3625                 PredicateFactory.lessThanOrEqual("effectiveDate", secondDate));
3626 
3627         cluInfos = this.searchForClus(qbcBuilder.build());
3628         assertEquals(37, cluInfos.size());
3629     }
3630 
3631     private List<CluInfo> searchForClus(QueryByCriteria qbc) {
3632         try {
3633             return client.searchForClus(qbc, ContextUtils.getContextInfo());
3634         } catch (Exception e) {
3635             throw new RuntimeException(e);
3636         }
3637     }
3638 
3639 
3640     @Test
3641     public void test70GetCluResultsByClus() throws VersionMismatchException,DataValidationErrorException,ReadOnlyException,MissingParameterException, InvalidParameterException, OperationFailedException, DoesNotExistException, PermissionDeniedException {
3642         List<String> cluIds = new ArrayList<String>();
3643         cluIds.add("CLU-1");
3644         cluIds.add("CLU-2");
3645         cluIds.add("CLU-5");
3646 
3647         CluResultInfo createCluResult = client.createCluResult("CLU-1", "kuali.resultType.gradeCourseResult", dto, contextInfo);
3648         createCluResult = client.getCluResult(createCluResult.getId(), contextInfo);
3649 
3650         assertNotNull(createCluResult);
3651 
3652         List<CluResultInfo> cluResultInfos = client.getCluResultsByClus(cluIds, ContextInfoTestUtility.getEnglishContextInfo());
3653         assertNotNull(cluResultInfos);
3654         boolean bool = false;
3655         for(CluResultInfo cluResultInfo : cluResultInfos) {
3656             if(cluResultInfo.getCluId().equals("CLU-1"))
3657                 bool = true;
3658         }
3659         assertTrue(bool);
3660     }
3661 
3662 }