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