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