Clover Coverage Report - KS LUM 1.1.0-M10-SNAPSHOT (Aggregated)
Coverage timestamp: Fri Dec 17 2010 06:40:47 EST
404   794   63   17.57
4   584   0.16   23
23     2.74  
1    
 
  TestLearningObjectiveServiceImpl       Line # 66 404 0% 63 50 88.4% 0.8839907
 
  (22)
 
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.lo.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.assertTrue;
22    import static org.junit.Assert.fail;
23   
24    import java.util.ArrayList;
25    import java.util.Arrays;
26    import java.util.Date;
27    import java.util.HashMap;
28    import java.util.List;
29    import java.util.Map;
30   
31    import org.junit.Test;
32    import org.kuali.student.common.test.spring.AbstractServiceTest;
33    import org.kuali.student.common.test.spring.Client;
34    import org.kuali.student.common.test.spring.Dao;
35    import org.kuali.student.common.test.spring.Daos;
36    import org.kuali.student.common.test.spring.PersistenceFileLocation;
37    import org.kuali.student.core.dto.RichTextInfo;
38    import org.kuali.student.core.dto.StatusInfo;
39    import org.kuali.student.core.exceptions.AlreadyExistsException;
40    import org.kuali.student.core.exceptions.CircularReferenceException;
41    import org.kuali.student.core.exceptions.CircularRelationshipException;
42    import org.kuali.student.core.exceptions.DataValidationErrorException;
43    import org.kuali.student.core.exceptions.DependentObjectsExistException;
44    import org.kuali.student.core.exceptions.DoesNotExistException;
45    import org.kuali.student.core.exceptions.InvalidParameterException;
46    import org.kuali.student.core.exceptions.MissingParameterException;
47    import org.kuali.student.core.exceptions.OperationFailedException;
48    import org.kuali.student.core.exceptions.PermissionDeniedException;
49    import org.kuali.student.core.exceptions.UnsupportedActionException;
50    import org.kuali.student.core.exceptions.VersionMismatchException;
51    import org.kuali.student.core.search.dto.SearchParam;
52    import org.kuali.student.core.search.dto.SearchRequest;
53    import org.kuali.student.core.search.dto.SearchResult;
54    import org.kuali.student.core.search.dto.SearchResultCell;
55    import org.kuali.student.lum.lo.dto.LoCategoryInfo;
56    import org.kuali.student.lum.lo.dto.LoCategoryTypeInfo;
57    import org.kuali.student.lum.lo.dto.LoInfo;
58    import org.kuali.student.lum.lo.dto.LoLoRelationInfo;
59    import org.kuali.student.lum.lo.dto.LoLoRelationTypeInfo;
60    import org.kuali.student.lum.lo.dto.LoRepositoryInfo;
61    import org.kuali.student.lum.lo.dto.LoTypeInfo;
62    import org.kuali.student.lum.lo.service.LearningObjectiveService;
63   
64    @Daos({@Dao(value = "org.kuali.student.lum.lo.dao.impl.LoDaoImpl", testSqlFile = "classpath:ks-lo.sql")})
65    @PersistenceFileLocation("classpath:META-INF/lo-persistence.xml")
 
66    public class TestLearningObjectiveServiceImpl extends AbstractServiceTest {
67    @Client(value = "org.kuali.student.lum.lo.service.impl.LearningObjectiveServiceImpl", additionalContextFile = "classpath:lo-additional-context.xml")
68    public LearningObjectiveService client;
69   
 
70  1 toggle @Test
71    public void testLo() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, DataValidationErrorException, PermissionDeniedException, VersionMismatchException, DependentObjectsExistException, AlreadyExistsException, CircularRelationshipException {
72  1 LoInfo loInfo = new LoInfo();
73  1 loInfo.setName("How Lo Can You Go");
74  1 RichTextInfo richText = new RichTextInfo();
75  1 richText.setFormatted("<p>New ResultComponent</p>");
76  1 richText.setPlain("New ResultComponent");
77  1 loInfo.setDesc(richText);
78  1 Date date = new Date();
79  1 loInfo.setEffectiveDate(date);
80  1 loInfo.setExpirationDate(date);
81  1 loInfo.setLoRepositoryKey("kuali.loRepository.key.singleUse");
82  1 Map<String, String> attributes = new HashMap<String, String>();
83  1 attributes.put("attrKey", "attrValue");
84  1 loInfo.setAttributes(attributes);
85  1 loInfo.setType("kuali.lo.type.singleUse");
86  1 loInfo.setState("draft");
87   
88  1 LoInfo created = client.createLo("kuali.loRepository.key.singleUse", "kuali.lo.type.singleUse", loInfo);
89  1 assertNotNull(created);
90  1 String loId = created.getId();
91  1 assertNotNull(loId);
92   
93  1 created = client.getLo(loId);
94   
95  1 RichTextInfo desc = created.getDesc();
96  1 assertNotNull(desc);
97  1 assertEquals("<p>New ResultComponent</p>", desc.getFormatted());
98  1 assertEquals("New ResultComponent", desc.getPlain());
99  1 assertEquals(date.toString(), created.getEffectiveDate().toString());
100  1 assertEquals(date.toString(), created.getExpirationDate().toString());
101  1 Map<String, String> newAttributes = created.getAttributes();
102  1 assertNotNull(newAttributes);
103  1 assertEquals("attrValue", newAttributes.get("attrKey"));
104  1 assertEquals("kuali.lo.type.singleUse", created.getType());
105  1 assertEquals("draft", created.getState());
106   
107  1 loInfo = client.getLo(loId);
108  1 loInfo.setName("Lo in the mid 30s");
109   
110  1 LoInfo updated = client.updateLo(loId, loInfo);
111  1 assertNotNull(updated);
112  1 assertEquals(loId, updated.getId());
113  1 desc = updated.getDesc();
114  1 assertNotNull(desc);
115  1 assertEquals("<p>New ResultComponent</p>", desc.getFormatted());
116  1 assertEquals("New ResultComponent", desc.getPlain());
117  1 assertEquals(date.toString(), updated.getEffectiveDate().toString());
118  1 assertEquals(date.toString(), updated.getExpirationDate().toString());
119  1 newAttributes = updated.getAttributes();
120  1 assertNotNull(newAttributes);
121  1 assertEquals("attrValue", newAttributes.get("attrKey"));
122  1 assertEquals("kuali.lo.type.singleUse", updated.getType());
123  1 assertEquals("draft", updated.getState());
124   
125  1 try {
126  1 client.updateLo(loId, loInfo);
127  0 fail("VersionMismatchException expected");
128    } catch (VersionMismatchException e) {}
129   
130    // Detecting expected errors
131  1 loInfo = new LoInfo();
132  1 try {
133  1 client.createLo(null, "kuali.lo.type.singleUse", loInfo);
134  0 fail("MissingParameterException expected for loRepositoryId");
135    } catch (MissingParameterException e) {}
136  1 try {
137  1 client.createLo("kuali.loRepository.key.singleUse", null, loInfo);
138  0 fail("MissingParameterException expected for loTypeId");
139    } catch (MissingParameterException e) {}
140  1 try {
141  1 client.createLo("kuali.loRepository.key.singleUse", "kuali.lo.type.singleUse", null);
142  0 fail("MissingParameterException expected for loInfo");
143    } catch (MissingParameterException e) {}
144   
145  1 try {
146  1 client.getLo(null);
147  0 fail("MissingParameterException expected for loId");
148    } catch (MissingParameterException e) {}
149   
150  1 try {
151  1 client.updateLo(null, loInfo);
152  0 fail("MissingParameterException expected for loId");
153    } catch (MissingParameterException e) {}
154  1 try {
155  1 client.updateLo(loId, null);
156  0 fail("MissingParameterException expected for loInfo");
157    } catch (MissingParameterException e) {}
158   
159  1 StatusInfo statusInfo = client.deleteLo(loId);
160  1 assertTrue(statusInfo.getSuccess());
161   
162    // now make sure we can't orphan "included" LO's
163  1 LoLoRelationInfo llrInfo = new LoLoRelationInfo();
164   
165  1 llrInfo = client.createLoLoRelation("7bcd7c0e-3e6b-4527-ac55-254c58cecc22", "91a91860-d796-4a17-976b-a6165b1a0b05", "kuali.lo.relation.type.includes", llrInfo);
166  1 assertNotNull(llrInfo);
167  1 llrInfo = client.getLoLoRelation(llrInfo.getId());
168  1 try {
169  1 client.deleteLo("7bcd7c0e-3e6b-4527-ac55-254c58cecc22");
170  0 fail("Deleted an LO which orphaned included LO(s)");
171    } catch (DependentObjectsExistException doee) {}
172    }
173   
 
174  1 toggle @Test
175    public void testGetLoByIdList() throws DoesNotExistException, InvalidParameterException, OperationFailedException, MissingParameterException {
176  1 List<LoInfo> loInfos = client.getLoByIdList(Arrays.asList("81abea67-3bcc-4088-8348-e265f3670145",
177    "dd0658d2-fdc9-48fa-9578-67a2ce53bf8a",
178    "91a91860-d796-4a17-976b-a6165b1a0b05"));
179  1 assertEquals(3, loInfos.size());
180    }
181   
182    /*
183    * Creating an LoCategory with the same name, type & state
184    */
 
185  1 toggle @Test
186    public void testDisallowLoCategoryDuplication() throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DependentObjectsExistException {
187  1 String catName = "DontDupThisCategory";
188  1 String catState = "active";
189  1 String catType = "loCategoryType.accreditation";
190  1 String catRepo = "kuali.loRepository.key.singleUse";
191   
192  1 LoCategoryInfo newCatInfo = new LoCategoryInfo();
193  1 newCatInfo.setName(catName);
194  1 newCatInfo.setType(catType);
195  1 newCatInfo.setState(catState);
196  1 newCatInfo.setLoRepository(catRepo);
197   
198  1 newCatInfo = client.createLoCategory(catRepo, catType, newCatInfo);
199   
200  1 LoCategoryInfo dupCatInfo = new LoCategoryInfo();
201  1 dupCatInfo.setName(catName);
202  1 dupCatInfo.setType(catType);
203  1 dupCatInfo.setState(catState);
204  1 dupCatInfo.setLoRepository(catRepo);
205   
206   
207  1 try {
208  1 dupCatInfo = client.createLoCategory(catRepo, catType, dupCatInfo);
209    // delete the two (one erroneously) created so as to not mess up other tests
210  0 client.deleteLoCategory(newCatInfo.getId());
211  0 client.deleteLoCategory(dupCatInfo.getId());
212  0 fail("DataValidationErrorException expected when creating LoCategory with the same name, type and state");
213    } catch (DataValidationErrorException e) {
214    // expected result
215    }
216    // delete the one created so as to not mess up other tests
217  1 client.deleteLoCategory(newCatInfo.getId());
218    }
219   
 
220  1 toggle @Test
221    public void testDisallowLoWEmptyDesc() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, DataValidationErrorException, PermissionDeniedException, VersionMismatchException, DependentObjectsExistException, AlreadyExistsException, CircularRelationshipException {
222  1 LoInfo loInfo = new LoInfo();
223  1 loInfo.setName("Lo with Empty Desc");
224  1 RichTextInfo richText = new RichTextInfo();
225  1 richText.setFormatted("<p> </p>");
226  1 richText.setPlain(" ");
227  1 loInfo.setDesc(richText);
228  1 Date date = new Date();
229  1 loInfo.setEffectiveDate(date);
230  1 loInfo.setExpirationDate(date);
231  1 loInfo.setLoRepositoryKey("kuali.loRepository.key.singleUse");
232  1 Map<String, String> attributes = new HashMap<String, String>();
233  1 attributes.put("attrKey", "attrValue");
234  1 loInfo.setAttributes(attributes);
235  1 loInfo.setType("kuali.lo.type.singleUse");
236  1 loInfo.setState("draft");
237   
238  1 try {
239  1 LoInfo created = client.createLo("kuali.loRepository.key.singleUse", "kuali.lo.type.singleUse", loInfo);
240  0 assertNotNull(created);
241   
242    // delete the one erroneously created so as to not mess up other tests
243  0 StatusInfo statusInfo = client.deleteLo(created.getId());
244  0 assertTrue(statusInfo.getSuccess());
245  0 fail("OperationFailedException expected when creating Lo with empty description");
246    } catch (MissingParameterException mpe) {
247    // expected result
248    }
249    }
250   
 
251  1 toggle @Test
252    public void testDisallowLoCategoryWEmptyDesc() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, DataValidationErrorException, PermissionDeniedException, VersionMismatchException, DependentObjectsExistException, AlreadyExistsException, CircularRelationshipException {
253  1 String catName = "DontDupThisCategorytest";
254  1 String catState = "active";
255  1 String catType = "loCategoryType.accreditation";
256  1 String catRepo = "kuali.loRepository.key.singleUse";
257   
258  1 LoCategoryInfo newCatInfo = new LoCategoryInfo();
259  1 newCatInfo.setName(catName);
260  1 newCatInfo.setType(catType);
261  1 newCatInfo.setState(catState);
262  1 newCatInfo.setLoRepository(catRepo);
263   
264    //Testing KSLAB-692
265  1 RichTextInfo richText = new RichTextInfo();
266  1 richText.setFormatted("<p> </p>");
267  1 richText.setPlain(" ");
268  1 newCatInfo.setDesc(richText);
269   
270  1 try{
271  1 newCatInfo = client.createLoCategory(catRepo, catType, newCatInfo);
272  0 assertNotNull(newCatInfo);
273   
274    // delete the one erroneously created so as to not mess up other tests
275  0 StatusInfo statusInfo = client.deleteLoCategory(newCatInfo.getId());
276  0 assertTrue(statusInfo.getSuccess());
277  0 fail("OperationFailedException expected when creating LoCategory with empty description");
278    } catch (MissingParameterException mpe) {
279    // expected result
280    }
281   
282    }
283   
284    /*
285    * Creating an LoCategory with the same name (case insensitive), type & state
286    */
287   
 
288  1 toggle @Test
289    public void testDisallowLoCategoryDuplicationCaseInsensitive() throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DependentObjectsExistException {
290  1 String catName = "DontDupThisCategory";
291  1 String catState = "active";
292  1 String catType = "loCategoryType.accreditation";
293  1 String catRepo = "kuali.loRepository.key.singleUse";
294   
295  1 LoCategoryInfo newCatInfo = new LoCategoryInfo();
296  1 newCatInfo.setName(catName);
297  1 newCatInfo.setType(catType);
298  1 newCatInfo.setState(catState);
299  1 newCatInfo.setLoRepository(catRepo);
300   
301  1 try{
302  1 newCatInfo = client.createLoCategory(catRepo, catType, newCatInfo);
303  1 newCatInfo = client.getLoCategory(newCatInfo.getId());
304  1 newCatInfo.getName();
305  1 catRepo = newCatInfo.getLoRepository();
306    } catch (OperationFailedException ofe) {
307  0 System.err.println(ofe.getMessage());
308    } catch (Exception e){
309  0 System.err.println(e.getMessage());
310    }
311   
312  1 String dupCatName = "dontDupThisCategory";
313  1 LoCategoryInfo dupCatInfo = new LoCategoryInfo();
314  1 dupCatInfo.setName(dupCatName);
315  1 dupCatInfo.setType(catType);
316  1 dupCatInfo.setState(catState);
317  1 dupCatInfo.setLoRepository(catRepo);
318   
319   
320  1 try {
321  1 dupCatInfo = client.createLoCategory(catRepo, catType, dupCatInfo);
322  0 dupCatInfo = client.getLoCategory(dupCatInfo.getId());
323  0 dupCatName = dupCatInfo.getName();
324   
325    // delete the two (one erroneously) created so as to not mess up other tests
326  0 client.deleteLoCategory(newCatInfo.getId());
327  0 client.deleteLoCategory(dupCatInfo.getId());
328  0 fail("DataValidationErrorException expected when creating LoCategory with the same name, type and state");
329    } catch (DataValidationErrorException e) {
330    // expected result
331    }
332    // delete the one created so as to not mess up other tests
333  1 client.deleteLoCategory(newCatInfo.getId());
334    }
335   
336    /*
337    * Updating a LoCategory with checking LoCategory duplication(based on name (case insensitive), type, state & repository
338    */
339   
 
340  1 toggle @Test
341    public void testUpdateLoCategoryDuplicationCaseInsensitive() throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DependentObjectsExistException {
342  1 String catState = "active";
343  1 String catType = "loCategoryType.accreditation";
344  1 String catRepo = "kuali.loRepository.key.singleUse";
345  1 String catId1 = null;
346  1 String catId2 = null;
347   
348  1 LoCategoryInfo catInfo1 = new LoCategoryInfo();
349  1 catInfo1.setName( "DontDupThisCategory");
350  1 catInfo1.setType(catType);
351  1 catInfo1.setState(catState);
352  1 catInfo1.setLoRepository(catRepo);
353   
354  1 LoCategoryInfo catInfo2 = new LoCategoryInfo();
355  1 catInfo2.setName("DontDupThisCategory2");
356  1 catInfo2.setType(catType);
357  1 catInfo2.setState(catState);
358  1 catInfo2.setLoRepository(catRepo);
359   
360  1 try{
361  1 catInfo1 = client.createLoCategory(catRepo, catType, catInfo1);
362  1 catId1 = catInfo1.getId();
363   
364  1 catInfo2 = client.createLoCategory(catRepo, catType, catInfo2);
365  1 catId2 = catInfo2.getId();
366    } catch (OperationFailedException ofe) {
367  0 System.err.println(ofe.getMessage());
368    } catch (Exception e){
369  0 System.err.println(e.getMessage());
370    }
371   
372   
373  1 try {
374  1 catInfo2.setName( "dontDupThisCategory");
375  1 client.updateLoCategory(catId2, catInfo2);
376   
377   
378  0 fail("DataValidationErrorException expected when updating LoCategory with the same name, type and state");
379    } catch (DataValidationErrorException e) {
380    // expected result
381    }catch (VersionMismatchException e){
382    //expected for testing
383    }
384   
385    // delete the two created so as to not mess up other tests
386  1 client.deleteLoCategory(catId1);
387  1 client.deleteLoCategory(catId2);
388    }
389   
 
390  1 toggle @Test
391    public void testGetRelatedLosByLoId() throws DoesNotExistException, InvalidParameterException, OperationFailedException {
392  1 List<LoInfo> relatedLos = null;
393  1 try {
394  1 relatedLos = client.getRelatedLosByLoId("81abea67-3bcc-4088-8348-e265f3670145", "kuali.lo.relation.type.includes");
395    } catch (Exception e) {
396  0 fail("Exception caught when calling LearningObjectiveService.getRelatedLosByLoId(): " + e.getMessage());
397    }
398  1 assertNotNull(relatedLos);
399  1 assertEquals(2, relatedLos.size());
400  1 assertTrue(relatedLos.get(0).getId().equals("e0b456b2-62cb-4bd3-8867-a0d59fd8f2cf") || relatedLos.get(1).getId().equals("e0b456b2-62cb-4bd3-8867-a0d59fd8f2cf"));
401   
402    // Detecting expected errors
403  1 try {
404  1 relatedLos = client.getRelatedLosByLoId(null, "kuali.lo.relation.type.includes");
405  0 fail("MissingParameterException expected for loId");
406    } catch (MissingParameterException e) {}
407  1 try {
408  1 relatedLos = client.getRelatedLosByLoId("81abea67-3bcc-4088-8348-e265f3670145", null);
409  0 fail("MissingParameterException expected for loLoRelationTypeKey");
410    } catch (MissingParameterException e) {}
411    }
412   
 
413  1 toggle @Test
414    public void testGetLoRepositories() throws DoesNotExistException, InvalidParameterException, OperationFailedException {
415  1 List<LoRepositoryInfo> repos = null;
416  1 try {
417  1 repos = client.getLoRepositories();
418    } catch (Exception e) {
419  0 fail("Exception caught when calling LearningObjectiveService.getLoRepositories(): " + e.getMessage());
420    }
421  1 assertNotNull(repos);
422  1 assertEquals(3, repos.size());
423   
424  1 boolean found = false;
425  1 String repoId = "kuali.loRepository.key.state";
426  1 for (LoRepositoryInfo loRInfo : repos) {
427  3 if (loRInfo.getId().equals(repoId)) {
428  1 found = true;
429    }
430    }
431  1 if (!found) {
432  0 fail("Unable to find expected LoRepository with ID == " + repoId);
433    }
434    }
435   
 
436  1 toggle @Test
437    public void testGetLoRepository() throws DoesNotExistException, InvalidParameterException, OperationFailedException {
438  1 LoRepositoryInfo repo = null;
439  1 try {
440  1 repo = client.getLoRepository("kuali.loRepository.key.state");
441    } catch (Exception e) {
442  0 fail("Exception caught when calling LearningObjectiveService.getLoRepository(): " + e.getMessage());
443    }
444  1 assertNotNull(repo);
445  1 assertEquals("Learning objectives mandated by the state", repo.getDesc().getPlain());
446    // Detecting expected errors
447  1 try {
448  1 client.getLoRepository(null);
449  0 fail("MissingParameterException expected for loRepositoryKey");
450    } catch (MissingParameterException e) {}
451    }
452   
 
453  1 toggle @Test
454    public void testGetLoCategoryTypes() throws DoesNotExistException, InvalidParameterException, OperationFailedException {
455  1 List<LoCategoryTypeInfo> loCatTypeInfos = client.getLoCategoryTypes();
456  1 assertEquals(3, loCatTypeInfos.size());
457    }
458   
 
459  1 toggle @Test
460    public void testGetLoTypesAndGetLoType() throws OperationFailedException, DoesNotExistException, InvalidParameterException, MissingParameterException {
461  1 List<LoTypeInfo> loTypes = client.getLoTypes();
462  1 assertNotNull(loTypes);
463  1 assertTrue(!loTypes.isEmpty());
464   
465  1 LoTypeInfo loType = client.getLoType(loTypes.get(0).getId());
466  1 assertEquals(loTypes.get(0).getName(), loType.getName());
467   
468  1 loType = client.getLoType("kuali.lo.type.governed");
469  1 assertEquals("Governed", loType.getName());
470   
471    // Detecting expected errors
472  1 try {
473  1 client.getLoType(null);
474  0 fail("MissingParameterException expected for loTypeKey");
475    } catch (MissingParameterException e) {}
476    }
477   
 
478  1 toggle @Test
479    public void testGetLoLoRelationTypes() {
480  1 List<LoLoRelationTypeInfo> llrtInfos = null;
481  1 try {
482  1 llrtInfos = client.getLoLoRelationTypes();
483    } catch (Exception e) {
484  0 fail("Exception caught when calling LearningObjectiveService.getLoLoRelationTypes(): " + e.getMessage());
485    }
486  1 assertNotNull(llrtInfos);
487  1 assertEquals(2, llrtInfos.size());
488  1 assertTrue(llrtInfos.get(0).getName().equals("inSupportOf") || llrtInfos.get(1).getName().equals("inSupportOf"));
489   
490    }
491   
 
492  1 toggle @Test
493    public void testGetLoLoRelationType() throws OperationFailedException, DoesNotExistException {
494  1 LoLoRelationTypeInfo llrtInfo = null;
495  1 try {
496  1 llrtInfo = client.getLoLoRelationType("kuali.lo.relation.type.includes");
497    } catch (Exception e) {
498  0 fail("Exception caught when calling LearningObjectiveService.getLoLoRelationType(): " + e.getMessage());
499    }
500  1 assertNotNull(llrtInfo);
501  1 assertEquals("includes", llrtInfo.getName());
502    // Detecting expected errors
503  1 try {
504  1 client.getLoLoRelationType(null);
505  0 fail("MissingParameterException expected for loLoRelationTypeKey");
506    } catch (MissingParameterException e) {}
507    }
508   
 
509  1 toggle @Test
510    public void testGetAllowedLoLoRelationTypesForLoType() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
511  1 List<String> allowedTypes = client.getAllowedLoLoRelationTypesForLoType("kuali.lo.type.singleUse", "kuali.lo.type.singleUse");
512  1 assertEquals(1, allowedTypes.size());
513  1 allowedTypes = client.getAllowedLoLoRelationTypesForLoType("kuali.lo.type.governed", "kuali.lo.type.governed");
514  1 assertTrue(null == allowedTypes || allowedTypes.size() == 0);
515    }
516   
 
517  1 toggle @Test
518    public void testGetLoLoRelation() throws OperationFailedException, DoesNotExistException, InvalidParameterException {
519  1 LoLoRelationInfo llrInfo = null;
520  1 try {
521  1 llrInfo = client.getLoLoRelation("61ff5b2c-5d2f-464b-b6d8-082fbf671fcb");
522    } catch (Exception e) {
523  0 fail("Exception caught when calling LearningObjectiveService.getLoLoRelation(): " + e.getMessage());
524    }
525  1 assertNotNull(llrInfo);
526  1 assertEquals("81abea67-3bcc-4088-8348-e265f3670145", llrInfo.getLoId());
527  1 assertEquals("dd0658d2-fdc9-48fa-9578-67a2ce53bf8a", llrInfo.getRelatedLoId());
528  1 assertEquals("kuali.lo.relation.type.includes", llrInfo.getType());
529  1 assertEquals("draft", llrInfo.getState());
530    // Detecting expected errors
531  1 try {
532  1 client.getLoLoRelation(null);
533  0 fail("MissingParameterException expected for loLoRelationId");
534    } catch (MissingParameterException e) {}
535    }
536   
 
537  1 toggle @Test
538    public void testGetLoCategories() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
539  1 List<LoCategoryInfo> categories = client.getLoCategories("kuali.loRepository.key.singleUse");
540  1 assertEquals(5, categories.size());
541  1 categories = client.getLoCategories("kuali.loRepository.key.state");
542  1 assertTrue(null == categories || categories.size() == 0);
543    }
544   
 
545  1 toggle @Test
546    public void testGetLoCategoriesForLo() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
547  1 List<LoCategoryInfo> categories = client.getLoCategoriesForLo("dd0658d2-fdc9-48fa-9578-67a2ce53bf8a");
548  1 assertNotNull(categories);
549  1 assertEquals(2, categories.size());
550  1 categories = client.getLoCategoriesForLo("e0619a90-66d6-4af4-b357-e73ae44f7e88");
551  1 assertEquals(1, categories.size());
552  1 assertEquals("Test Category 3", categories.get(0).getName());
553  1 categories = client.getLoCategoriesForLo("e0b456b2-62cb-4bd3-8867-a0d59fd8f2cf");
554  1 assertTrue(null == categories || categories.size() == 0);
555    }
556   
 
557  1 toggle @Test
558    public void testAddRemoveLoCategoryToFromLo() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, AlreadyExistsException, PermissionDeniedException, UnsupportedActionException {
559  1 List<LoCategoryInfo> categories = client.getLoCategoriesForLo("dd0658d2-fdc9-48fa-9578-67a2ce53bf8a");
560  1 assertEquals(2, categories.size());
561  1 assertTrue(containsLoCatInfo(categories, Arrays.asList("550e8400-e29b-41d4-a716-446655440000", "7114d2a4-f66d-4d3a-9d41-a7aa4299c797")));
562  1 client.addLoCategoryToLo("f2f02922-4e77-4144-aa07-8c2c956370dc", "dd0658d2-fdc9-48fa-9578-67a2ce53bf8a");
563  1 categories = client.getLoCategoriesForLo("dd0658d2-fdc9-48fa-9578-67a2ce53bf8a");
564  1 assertEquals(3, categories.size());
565  1 assertTrue(containsLoCatInfo(categories, Arrays.asList("550e8400-e29b-41d4-a716-446655440000", "7114d2a4-f66d-4d3a-9d41-a7aa4299c797", "f2f02922-4e77-4144-aa07-8c2c956370dc")));
566  1 client.removeLoCategoryFromLo("f2f02922-4e77-4144-aa07-8c2c956370dc", "dd0658d2-fdc9-48fa-9578-67a2ce53bf8a");
567  1 categories = client.getLoCategoriesForLo("dd0658d2-fdc9-48fa-9578-67a2ce53bf8a");
568  1 assertEquals(2, categories.size());
569    }
570   
 
571  2 toggle private boolean containsLoCatInfo(List<LoCategoryInfo> categories, List<String> idList) {
572  2 List<String> ids = new ArrayList<String>();
573   
574  2 for (LoCategoryInfo info : categories) {
575  5 ids.add(info.getId());
576    }
577  2 return ids.containsAll(idList);
578    }
579   
 
580  1 toggle @Test
581    public void testCreateLoLoRelation() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, AlreadyExistsException, CircularReferenceException, DataValidationErrorException, PermissionDeniedException, CircularRelationshipException {
582  1 LoLoRelationInfo llrInfo = new LoLoRelationInfo();
583   
584  1 try {
585  1 llrInfo = client.createLoLoRelation("7bcd7c0e-3e6b-4527-ac55-254c58cecc22", "91a91860-d796-4a17-976b-a6165b1a0b05", "kuali.lo.relation.type.includes", llrInfo);
586    } catch (Exception e) {
587  0 fail("Exception caught when calling LearningObjectiveService.createLoLoRelation(): " + e.getMessage());
588    }
589  1 assertNotNull(llrInfo);
590  1 llrInfo = client.getLoLoRelation(llrInfo.getId());
591  1 assertEquals("7bcd7c0e-3e6b-4527-ac55-254c58cecc22", llrInfo.getLoId());
592  1 assertEquals("91a91860-d796-4a17-976b-a6165b1a0b05", llrInfo.getRelatedLoId());
593  1 assertEquals("kuali.lo.relation.type.includes", llrInfo.getType());
594  1 assertEquals("draft", llrInfo.getState());
595    // Detecting expected errors
596  1 try {
597  1 client.createLoLoRelation(null, "foo", "bar", llrInfo);
598  0 fail("MissingParameterException expected for loId");
599    } catch (MissingParameterException e) {}
600  1 try {
601  1 client.createLoLoRelation("foo", null, "bar", llrInfo);
602  0 fail("MissingParameterException expected for relatedLoId");
603    } catch (MissingParameterException e) {}
604  1 try {
605  1 client.createLoLoRelation("foo", "bar", null, llrInfo);
606  0 fail("MissingParameterException expected for loLoRelationType");
607    } catch (MissingParameterException e) {}
608  1 try {
609  1 client.createLoLoRelation("foo", "bar", "baz", null);
610  0 fail("MissingParameterException expected for loLoRelationInfo");
611    } catch (MissingParameterException e) {}
612    }
613   
614    /*
615    @Test
616    public void testIncludedLo() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, AlreadyExistsException, CircularReferenceException, PermissionDeniedException, UnsupportedActionException, DependentObjectsExistException {
617    List<String> ancestors = client.getAncestors("E0B456B2-62CB-4BD3-8867-A0D59FD8F2CF");
618    assertTrue(!ancestors.contains("ABD8AE21-34E9-4858-A714-B04134F55D68"));
619   
620    StatusInfo result = client.addChildLoToLo("7BCD7C0E-3E6B-4527-AC55-254C58CECC22", "ABD8AE21-34E9-4858-A714-B04134F55D68");
621    assertNotNull(result);
622    assertTrue(result.getSuccess());
623   
624    ancestors = client.getAncestors("7BCD7C0E-3E6B-4527-AC55-254C58CECC22");
625    assertTrue(ancestors.contains("ABD8AE21-34E9-4858-A714-B04134F55D68"));
626   
627    try {
628    result = client.addChildLoToLo("7BCD7C0E-3E6B-4527-AC55-254C58CECC22", "ABD8AE21-34E9-4858-A714-B04134F55D68");
629    fail("relationship should already exists and thus throw AlreadyExistsException");
630    } catch (AlreadyExistsException e) {
631    }
632   
633    List<String> descendants = client.getAllDescendants("ABD8AE21-34E9-4858-A714-B04134F55D68");
634    assertTrue(descendants.contains("7BCD7C0E-3E6B-4527-AC55-254C58CECC22"));
635   
636    assertTrue(client.isDescendant("ABD8AE21-34E9-4858-A714-B04134F55D68", "7BCD7C0E-3E6B-4527-AC55-254C58CECC22"));
637   
638    List<LoInfo> children = client.getLoChildren("ABD8AE21-34E9-4858-A714-B04134F55D68");
639    boolean foundLo = false;
640    for (LoInfo loInfo : children) {
641    if(loInfo.getId().equals("7BCD7C0E-3E6B-4527-AC55-254C58CECC22")) {
642    foundLo = true;
643    break;
644    }
645    }
646    assertTrue(foundLo);
647   
648    List<LoInfo> parents = client.getLoParents("7BCD7C0E-3E6B-4527-AC55-254C58CECC22");
649    foundLo = false;
650    for (LoInfo loInfo : parents) {
651    if(loInfo.getId().equals("ABD8AE21-34E9-4858-A714-B04134F55D68")) {
652    foundLo = true;
653    break;
654    }
655    }
656    assertTrue(foundLo);
657   
658    try { // this would result in "7B..." being orphaned
659    result = client.removeChildLoFromLo("7BCD7C0E-3E6B-4527-AC55-254C58CECC22", "ABD8AE21-34E9-4858-A714-B04134F55D68");
660    fail("LearningObjectiveService.removeChildLoFromLo should have thrown DependentObjectsExistException");
661    } catch (DependentObjectsExistException doee) {}
662   
663    // add it as a child to another parent
664    result = client.addChildLoToLo("7BCD7C0E-3E6B-4527-AC55-254C58CECC22", "DD0658D2-FDC9-48FA-9578-67A2CE53BF8A");
665    assertNotNull(result);
666    assertTrue(result.getSuccess());
667   
668    // and now remove it from "AB..."'s children
669    result = client.removeChildLoFromLo("7BCD7C0E-3E6B-4527-AC55-254C58CECC22", "ABD8AE21-34E9-4858-A714-B04134F55D68");
670    assertNotNull(result);
671    assertTrue(result.getSuccess());
672   
673    assertTrue(!client.isDescendant("ABD8AE21-34E9-4858-A714-B04134F55D68", "7BCD7C0E-3E6B-4527-AC55-254C58CECC22"));
674    }
675    */
676   
 
677  1 toggle @Test
678    public void testLoCategory() throws OperationFailedException, DoesNotExistException, InvalidParameterException, MissingParameterException, DataValidationErrorException, PermissionDeniedException, VersionMismatchException, DependentObjectsExistException, AlreadyExistsException, UnsupportedActionException {
679   
680  1 List<LoCategoryInfo> categories = client.getLoCategories("foo.bar.baz");
681  1 assertTrue(null == categories || categories.isEmpty());
682   
683  1 LoCategoryInfo category = new LoCategoryInfo();
684  1 RichTextInfo richText = new RichTextInfo();
685  1 richText.setFormatted("<p>New Category</p>");
686  1 richText.setPlain("New Category");
687  1 category.setDesc(richText);
688  1 Date date = new Date();
689  1 category.setEffectiveDate(date);
690  1 category.setExpirationDate(date);
691  1 category.setName("BOB, THE AMAAAAAAZING WONDER LLAMA!!");
692  1 Map<String, String> attributes = new HashMap<String, String>();
693  1 attributes.put("attrKey", "attrValue");
694  1 category.setAttributes(attributes);
695   
696   
697  1 String categoryId = "550e8400-e29b-41d4-a716-446655440000";
698   
699  1 category = client.getLoCategory(categoryId);
700  1 assertEquals("Perception", category.getName());
701  1 assertEquals("loCategoryType.skillarea", category.getType());
702  1 category.setName("LENNY, THE LECHEROUS MILK THIEF");
703  1 category.setType("loCategoryType.accreditation");
704   
705  1 List<LoInfo> twoLos = client.getLosByLoCategory(categoryId);
706  1 assertTrue(null != twoLos);
707  1 assertEquals(2, twoLos.size());
708  1 assertTrue(twoLos.get(0).getId().equals("81abea67-3bcc-4088-8348-e265f3670145") ||
709    twoLos.get(0).getId().equals("dd0658d2-fdc9-48fa-9578-67a2ce53bf8a"));
710  1 assertTrue(twoLos.get(1).getId().equals("81abea67-3bcc-4088-8348-e265f3670145") ||
711    twoLos.get(1).getId().equals("dd0658d2-fdc9-48fa-9578-67a2ce53bf8a"));
712   
713  1 LoCategoryInfo updated = client.updateLoCategory(categoryId, category);
714  1 assertNotNull(updated);
715  1 assertNotNull(updated.getId());
716   
717    // make sure it all stuck
718  1 updated = client.getLoCategory(updated.getId());
719  1 assertEquals("LENNY, THE LECHEROUS MILK THIEF", updated.getName());
720  1 assertEquals("loCategoryType.accreditation", updated.getType());
721   
722  1 try {
723  1 client.updateLoCategory(categoryId, category);
724  0 fail("DataValidationErrorException expected: LO Category already exists");
725    } catch (VersionMismatchException e) {}
726    catch (DataValidationErrorException e) {}
727   
728    // switch to new LoCategory id; new one was created when we changed its type
729  1 String newCategoryId = updated.getId();
730   
731    // make sure it's new
732  1 assertFalse(categoryId.equals(newCategoryId));
733   
734    // make sure the LoCategories were cloned
735  1 List<LoInfo> los = client.getLosByLoCategory(newCategoryId);
736  1 assertEquals(2, los.size());
737  1 assertTrue(los.get(0).getId().equals("81abea67-3bcc-4088-8348-e265f3670145") ||
738    los.get(0).getId().equals("dd0658d2-fdc9-48fa-9578-67a2ce53bf8a"));
739  1 assertTrue(los.get(1).getId().equals("81abea67-3bcc-4088-8348-e265f3670145") ||
740    los.get(1).getId().equals("dd0658d2-fdc9-48fa-9578-67a2ce53bf8a"));
741   
742  1 los = client.getLosByLoCategory(categoryId);
743  1 assertTrue(null == los || los.isEmpty());
744   
745    // add one to an LO that didn't have one
746  1 categoryId = "054caa88-c21d-4496-8287-36a311a11d68";
747  1 StatusInfo statusInfo = client.addLoCategoryToLo(categoryId, "91a91860-d796-4a17-976b-a6165b1a0b05");
748  1 assertTrue(statusInfo.getSuccess());
749   
750  1 los = client.getLosByLoCategory(categoryId);
751  1 assertEquals(1, los.size());
752  1 assertEquals("91a91860-d796-4a17-976b-a6165b1a0b05", los.get(0).getId());
753   
754  1 categories = client.getLoCategoriesForLo("91a91860-d796-4a17-976b-a6165b1a0b05");
755  1 assertEquals(1, categories.size());
756   
757  1 try {
758  1 statusInfo = client.deleteLoCategory(categoryId);
759  0 fail("DependentObjectsExistException expected");
760    } catch(DependentObjectsExistException e) {}
761   
762  1 statusInfo = client.removeLoCategoryFromLo(categoryId, "91a91860-d796-4a17-976b-a6165b1a0b05");
763  1 assertTrue(statusInfo.getSuccess());
764   
765  1 los = client.getLosByLoCategory(categoryId);
766  1 assertTrue(null == los || los.size() == 0);
767  1 statusInfo = client.deleteLoCategory(categoryId);
768  1 assertTrue(statusInfo.getSuccess());
769    }
770   
 
771  1 toggle @Test
772    public void testSearchForResults() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException{
773  1 String testLoName = "Navigate Wiki";
774  1 List<SearchParam> queryParamValues = new ArrayList<SearchParam>();
775  1 SearchParam qpv1 = new SearchParam();
776  1 qpv1.setKey("lo.queryParam.loName");
777  1 qpv1.setValue(testLoName);
778  1 queryParamValues.add(qpv1);
779  1 SearchRequest searchRequest = new SearchRequest();
780  1 searchRequest.setParams(queryParamValues);
781  1 searchRequest.setSearchKey("lo.search.loByName");
782  1 SearchResult result = client.search(searchRequest);
783  1 assertEquals(1,result.getRows().size());
784   
785  1 List<SearchResultCell> resultCells = result.getRows().get(0).getCells();
786  1 assertEquals(2, resultCells.size());
787  1 SearchResultCell cell = resultCells.get(0);
788  1 assertEquals("lo.resultColumn.loId", cell.getKey());
789  1 assertEquals("e0b456b2-62cb-4bd3-8867-a0d59fd8f2cf", cell.getValue());
790  1 cell = resultCells.get(1);
791  1 assertEquals("lo.resultColumn.loName", cell.getKey());
792  1 assertEquals(testLoName, cell.getValue());
793    }
794    }