1 package org.kuali.student.lum.statement.config.context;
2
3 import java.util.ArrayList;
4 import java.util.HashMap;
5 import java.util.List;
6 import java.util.Map;
7
8 import org.junit.Assert;
9 import org.junit.Before;
10 import org.junit.Test;
11 import org.kuali.student.common.dictionary.old.dto.ObjectStructure;
12 import org.kuali.student.common.dto.StatusInfo;
13 import org.kuali.student.common.exceptions.AlreadyExistsException;
14 import org.kuali.student.common.exceptions.DataValidationErrorException;
15 import org.kuali.student.common.exceptions.DoesNotExistException;
16 import org.kuali.student.common.exceptions.InvalidParameterException;
17 import org.kuali.student.common.exceptions.MissingParameterException;
18 import org.kuali.student.common.exceptions.OperationFailedException;
19 import org.kuali.student.common.exceptions.PermissionDeniedException;
20 import org.kuali.student.common.exceptions.VersionMismatchException;
21 import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo;
22 import org.kuali.student.common.search.dto.SearchRequest;
23 import org.kuali.student.common.search.dto.SearchResult;
24 import org.kuali.student.common.search.dto.SearchResultTypeInfo;
25 import org.kuali.student.common.search.dto.SearchTypeInfo;
26 import org.kuali.student.common.validation.dto.ValidationResultInfo;
27 import org.kuali.student.core.organization.dto.OrgHierarchyInfo;
28 import org.kuali.student.core.organization.dto.OrgInfo;
29 import org.kuali.student.core.organization.dto.OrgOrgRelationInfo;
30 import org.kuali.student.core.organization.dto.OrgOrgRelationTypeInfo;
31 import org.kuali.student.core.organization.dto.OrgPersonRelationInfo;
32 import org.kuali.student.core.organization.dto.OrgPersonRelationTypeInfo;
33 import org.kuali.student.core.organization.dto.OrgPositionRestrictionInfo;
34 import org.kuali.student.core.organization.dto.OrgTreeInfo;
35 import org.kuali.student.core.organization.dto.OrgTypeInfo;
36 import org.kuali.student.core.organization.service.OrganizationService;
37 import org.kuali.student.core.statement.dto.ReqCompFieldInfo;
38 import org.kuali.student.core.statement.dto.ReqComponentInfo;
39 import org.kuali.student.lum.statement.typekey.ReqComponentFieldTypes;
40
41 public class OrganizationContextImplTest {
42
43 private OrganizationService organizationService = new OrganizationServiceMock();
44 private OrganizationContextImpl organizationContext = new OrganizationContextImpl();
45
46 private ReqComponentInfo reqComponent1;
47 private ReqComponentInfo reqComponent2;
48
49 private void setupReqComponent1() {
50 reqComponent1 = new ReqComponentInfo();
51 List<ReqCompFieldInfo> reqCompFieldList = new ArrayList<ReqCompFieldInfo>();
52 ReqCompFieldInfo reqCompField1 = new ReqCompFieldInfo();
53 reqCompField1.setType(ReqComponentFieldTypes.ORGANIZATION_KEY.getId());
54 reqCompField1.setValue("59");
55 reqCompFieldList.add(reqCompField1);
56 reqComponent1.setReqCompFields(reqCompFieldList);
57 }
58
59 private void setupReqComponent2() {
60 reqComponent2 = new ReqComponentInfo();
61 List<ReqCompFieldInfo> reqCompFieldList = new ArrayList<ReqCompFieldInfo>();
62 ReqCompFieldInfo reqCompField1 = new ReqCompFieldInfo();
63 reqCompField1.setType(ReqComponentFieldTypes.ORGANIZATION_KEY.getId());
64 reqCompField1.setValue(null);
65 reqCompFieldList.add(reqCompField1);
66 reqComponent2.setReqCompFields(reqCompFieldList);
67 }
68
69 @Before
70 public void beforeMethod() {
71 organizationContext.setOrganizationService(organizationService);
72 setupReqComponent1();
73 setupReqComponent2();
74 }
75
76 @Test
77 public void testCreateContextMap() throws OperationFailedException {
78 Map<String, Object> contextMap = organizationContext.createContextMap(reqComponent1);
79 OrgInfo org = (OrgInfo) contextMap.get(OrganizationContextImpl.ORG_TOKEN);
80
81 Assert.assertNotNull(contextMap);
82 Assert.assertEquals("kuali.org.Department", org.getType());
83 Assert.assertEquals("Sociology", org.getShortName());
84 Assert.assertEquals("Sociology Dept", org.getLongName());
85 }
86
87 @Test
88 public void testCreateContextMap_NullTokenValues() throws OperationFailedException {
89 Map<String, Object> contextMap = organizationContext.createContextMap(reqComponent2);
90 OrgInfo org = (OrgInfo) contextMap.get(OrganizationContextImpl.ORG_TOKEN);
91
92 Assert.assertNotNull(contextMap);
93 Assert.assertEquals(null, org);
94 }
95
96 private static class OrganizationServiceMock implements OrganizationService {
97
98 private Map<String, OrgInfo> orgMap = new HashMap<String, OrgInfo>();
99
100 public OrganizationServiceMock() {
101 OrgInfo org1 = new OrgInfo();
102 org1.setId("59");
103 org1.setLongName("Sociology Dept");
104 org1.setShortName("Sociology");
105 org1.setType("kuali.org.Department");
106 orgMap.put("59", org1);
107
108 OrgInfo org2 = new OrgInfo();
109 org2.setId("60");
110 org2.setLongName("Interdisciplinary Studies in Social Science Program");
111 org2.setShortName("InterdiscBSOS");
112 org2.setType("kuali.org.Office");
113 orgMap.put("60", org2);
114 }
115
116 @Override
117 public OrgPositionRestrictionInfo addPositionRestrictionToOrg(
118 String orgId, String orgPersonRelationTypeKey,
119 OrgPositionRestrictionInfo orgPositionRestrictionInfo)
120 throws AlreadyExistsException, DataValidationErrorException,
121 DoesNotExistException, InvalidParameterException,
122 MissingParameterException, OperationFailedException,
123 PermissionDeniedException {
124
125 return null;
126 }
127
128 @Override
129 public OrgOrgRelationInfo createOrgOrgRelation(String orgId,
130 String relatedOrgId, String orgOrgRelationTypeKey,
131 OrgOrgRelationInfo orgOrgRelationInfo)
132 throws AlreadyExistsException, DataValidationErrorException,
133 DoesNotExistException, InvalidParameterException,
134 MissingParameterException, PermissionDeniedException,
135 OperationFailedException {
136
137 return null;
138 }
139
140 @Override
141 public OrgPersonRelationInfo createOrgPersonRelation(String orgId,
142 String personId, String orgPersonRelationTypeKey,
143 OrgPersonRelationInfo orgPersonRelationInfo)
144 throws AlreadyExistsException, DataValidationErrorException,
145 DoesNotExistException, InvalidParameterException,
146 MissingParameterException, PermissionDeniedException,
147 OperationFailedException {
148
149 return null;
150 }
151
152 @Override
153 public OrgInfo createOrganization(String orgTypeKey, OrgInfo orgInfo)
154 throws AlreadyExistsException, DataValidationErrorException,
155 InvalidParameterException, MissingParameterException,
156 OperationFailedException, PermissionDeniedException {
157
158 return null;
159 }
160
161 @Override
162 public StatusInfo deleteOrganization(String orgId)
163 throws DoesNotExistException, InvalidParameterException,
164 MissingParameterException, OperationFailedException,
165 PermissionDeniedException {
166
167 return null;
168 }
169
170 @Override
171 public List<String> getAllAncestors(String orgId, String orgHierarchy)
172 throws InvalidParameterException, MissingParameterException,
173 OperationFailedException, PermissionDeniedException {
174
175 return null;
176 }
177
178 @Override
179 public List<String> getAllDescendants(String orgId, String orgHierarchy)
180 throws InvalidParameterException, MissingParameterException,
181 OperationFailedException, PermissionDeniedException {
182
183 return null;
184 }
185
186 @Override
187 public List<OrgPersonRelationInfo> getAllOrgPersonRelationsByOrg(
188 String orgId) throws DoesNotExistException,
189 InvalidParameterException, MissingParameterException,
190 OperationFailedException, PermissionDeniedException {
191
192 return null;
193 }
194
195 @Override
196 public List<OrgPersonRelationInfo> getAllOrgPersonRelationsByPerson(
197 String personId) throws DoesNotExistException,
198 InvalidParameterException, MissingParameterException,
199 OperationFailedException, PermissionDeniedException {
200
201 return null;
202 }
203
204 @Override
205 public List<OrgHierarchyInfo> getOrgHierarchies()
206 throws OperationFailedException {
207
208 return null;
209 }
210
211 @Override
212 public OrgHierarchyInfo getOrgHierarchy(String orgHierarchyKey)
213 throws DoesNotExistException, InvalidParameterException,
214 MissingParameterException, OperationFailedException {
215
216 return null;
217 }
218
219 @Override
220 public OrgOrgRelationInfo getOrgOrgRelation(String orgOrgRelationId)
221 throws DoesNotExistException, InvalidParameterException,
222 MissingParameterException, OperationFailedException,
223 PermissionDeniedException {
224
225 return null;
226 }
227
228 @Override
229 public OrgOrgRelationTypeInfo getOrgOrgRelationType(
230 String orgOrgRelationTypeKey) throws DoesNotExistException,
231 InvalidParameterException, MissingParameterException,
232 OperationFailedException {
233
234 return null;
235 }
236
237 @Override
238 public List<OrgOrgRelationTypeInfo> getOrgOrgRelationTypes()
239 throws OperationFailedException {
240
241 return null;
242 }
243
244 @Override
245 public List<OrgOrgRelationTypeInfo> getOrgOrgRelationTypesForOrgHierarchy(
246 String orgHierarchyKey) throws DoesNotExistException,
247 InvalidParameterException, MissingParameterException,
248 OperationFailedException {
249
250 return null;
251 }
252
253 @Override
254 public List<OrgOrgRelationTypeInfo> getOrgOrgRelationTypesForOrgType(
255 String orgTypeKey) throws DoesNotExistException,
256 InvalidParameterException, MissingParameterException,
257 OperationFailedException {
258
259 return null;
260 }
261
262 @Override
263 public List<OrgOrgRelationInfo> getOrgOrgRelationsByIdList(
264 List<String> orgOrgRelationIdList)
265 throws DoesNotExistException, InvalidParameterException,
266 MissingParameterException, OperationFailedException,
267 PermissionDeniedException {
268
269 return null;
270 }
271
272 @Override
273 public List<OrgOrgRelationInfo> getOrgOrgRelationsByOrg(String orgId)
274 throws DoesNotExistException, InvalidParameterException,
275 MissingParameterException, OperationFailedException,
276 PermissionDeniedException {
277
278 return null;
279 }
280
281 @Override
282 public List<OrgOrgRelationInfo> getOrgOrgRelationsByRelatedOrg(
283 String relatedOrgId) throws DoesNotExistException,
284 InvalidParameterException, MissingParameterException,
285 OperationFailedException, PermissionDeniedException {
286
287 return null;
288 }
289
290 @Override
291 public OrgPersonRelationInfo getOrgPersonRelation(
292 String orgPersonRelationId) throws DoesNotExistException,
293 InvalidParameterException, MissingParameterException,
294 OperationFailedException, PermissionDeniedException {
295
296 return null;
297 }
298
299 @Override
300 public OrgPersonRelationTypeInfo getOrgPersonRelationType(
301 String orgPersonRelationTypeKey) throws DoesNotExistException,
302 InvalidParameterException, MissingParameterException,
303 OperationFailedException {
304
305 return null;
306 }
307
308 @Override
309 public List<OrgPersonRelationTypeInfo> getOrgPersonRelationTypes()
310 throws OperationFailedException {
311
312 return null;
313 }
314
315 @Override
316 public List<OrgPersonRelationTypeInfo> getOrgPersonRelationTypesForOrgType(
317 String orgTypeKey) throws DoesNotExistException,
318 InvalidParameterException, MissingParameterException,
319 OperationFailedException {
320
321 return null;
322 }
323
324 @Override
325 public List<OrgPersonRelationInfo> getOrgPersonRelationsByIdList(
326 List<String> orgPersonRelationIdList)
327 throws DoesNotExistException, InvalidParameterException,
328 MissingParameterException, OperationFailedException,
329 PermissionDeniedException {
330
331 return null;
332 }
333
334 @Override
335 public List<OrgPersonRelationInfo> getOrgPersonRelationsByOrg(
336 String orgId) throws DoesNotExistException,
337 InvalidParameterException, MissingParameterException,
338 OperationFailedException, PermissionDeniedException {
339
340 return null;
341 }
342
343 @Override
344 public List<OrgPersonRelationInfo> getOrgPersonRelationsByPerson(
345 String personId, String orgId) throws DoesNotExistException,
346 InvalidParameterException, MissingParameterException,
347 OperationFailedException, PermissionDeniedException {
348
349 return null;
350 }
351
352 @Override
353 public List<OrgTreeInfo> getOrgTree(String rootOrgId,
354 String orgHierarchyId, int maxLevels)
355 throws DoesNotExistException, InvalidParameterException,
356 MissingParameterException, OperationFailedException,
357 PermissionDeniedException {
358
359 return null;
360 }
361
362 @Override
363 public OrgTypeInfo getOrgType(String orgTypeKey)
364 throws DoesNotExistException, InvalidParameterException,
365 MissingParameterException, OperationFailedException {
366
367 return null;
368 }
369
370 @Override
371 public List<OrgTypeInfo> getOrgTypes() throws OperationFailedException {
372
373 return null;
374 }
375
376 @Override
377 public OrgInfo getOrganization(String orgId)
378 throws DoesNotExistException, InvalidParameterException,
379 MissingParameterException, OperationFailedException,
380 PermissionDeniedException {
381 return orgMap.get(orgId);
382 }
383
384 @Override
385 public List<OrgInfo> getOrganizationsByIdList(List<String> orgIdList)
386 throws DoesNotExistException, InvalidParameterException,
387 MissingParameterException, OperationFailedException,
388 PermissionDeniedException {
389
390 return null;
391 }
392
393 @Override
394 public List<String> getPersonIdsForOrgByRelationType(String orgId,
395 String orgPersonRelationTypeKey) throws DoesNotExistException,
396 InvalidParameterException, MissingParameterException,
397 OperationFailedException, PermissionDeniedException {
398
399 return null;
400 }
401
402 @Override
403 public List<OrgPositionRestrictionInfo> getPositionRestrictionsByOrg(
404 String orgId) throws DataValidationErrorException,
405 DoesNotExistException, InvalidParameterException,
406 MissingParameterException, PermissionDeniedException,
407 OperationFailedException {
408
409 return null;
410 }
411
412 @Override
413 public Boolean hasOrgOrgRelation(String orgId, String comparisonOrgId,
414 String orgOrgRelationTypeKey) throws InvalidParameterException,
415 MissingParameterException, OperationFailedException,
416 PermissionDeniedException {
417
418 return null;
419 }
420
421 @Override
422 public Boolean hasOrgPersonRelation(String orgId, String personId,
423 String orgPersonRelationTypeKey)
424 throws InvalidParameterException, MissingParameterException,
425 OperationFailedException, PermissionDeniedException {
426
427 return null;
428 }
429
430 @Override
431 public Boolean isDescendant(String orgId, String descendantOrgId,
432 String orgHierarchy) throws InvalidParameterException,
433 MissingParameterException, OperationFailedException,
434 PermissionDeniedException {
435
436 return null;
437 }
438
439 @Override
440 public StatusInfo removeOrgOrgRelation(String orgOrgRelationId)
441 throws DoesNotExistException, InvalidParameterException,
442 MissingParameterException, OperationFailedException,
443 PermissionDeniedException {
444
445 return null;
446 }
447
448 @Override
449 public StatusInfo removeOrgPersonRelation(String orgPersonRelationId)
450 throws DoesNotExistException, InvalidParameterException,
451 MissingParameterException, OperationFailedException,
452 PermissionDeniedException {
453
454 return null;
455 }
456
457 @Override
458 public StatusInfo removePositionRestrictionFromOrg(String orgId,
459 String orgPersonRelationTypeKey) throws DoesNotExistException,
460 InvalidParameterException, MissingParameterException,
461 OperationFailedException, PermissionDeniedException {
462
463 return null;
464 }
465
466 @Override
467 public OrgOrgRelationInfo updateOrgOrgRelation(String orgOrgRelationId,
468 OrgOrgRelationInfo orgOrgRelationInfo)
469 throws DataValidationErrorException, DoesNotExistException,
470 InvalidParameterException, MissingParameterException,
471 OperationFailedException, PermissionDeniedException,
472 VersionMismatchException {
473
474 return null;
475 }
476
477 @Override
478 public OrgPersonRelationInfo updateOrgPersonRelation(
479 String orgPersonRelationId,
480 OrgPersonRelationInfo orgPersonRelationInfo)
481 throws DataValidationErrorException, DoesNotExistException,
482 InvalidParameterException, MissingParameterException,
483 OperationFailedException, PermissionDeniedException,
484 VersionMismatchException {
485
486 return null;
487 }
488
489 @Override
490 public OrgInfo updateOrganization(String orgId, OrgInfo orgInfo)
491 throws DataValidationErrorException, DoesNotExistException,
492 InvalidParameterException, MissingParameterException,
493 OperationFailedException, PermissionDeniedException,
494 VersionMismatchException {
495
496 return null;
497 }
498
499 @Override
500 public OrgPositionRestrictionInfo updatePositionRestrictionForOrg(
501 String orgId, String orgPersonRelationTypeKey,
502 OrgPositionRestrictionInfo orgPositionRestrictionInfo)
503 throws DataValidationErrorException, DoesNotExistException,
504 InvalidParameterException, MissingParameterException,
505 OperationFailedException, PermissionDeniedException,
506 VersionMismatchException {
507
508 return null;
509 }
510
511 @Override
512 public List<ValidationResultInfo> validateOrg(String validationType,
513 OrgInfo orgInfo) throws DoesNotExistException,
514 InvalidParameterException, MissingParameterException,
515 OperationFailedException {
516
517 return null;
518 }
519
520 @Override
521 public List<ValidationResultInfo> validateOrgOrgRelation(
522 String validationType, OrgOrgRelationInfo orgOrgRelationInfo)
523 throws DoesNotExistException, InvalidParameterException,
524 MissingParameterException, OperationFailedException {
525
526 return null;
527 }
528
529 @Override
530 public List<ValidationResultInfo> validateOrgPersonRelation(
531 String validationType,
532 OrgPersonRelationInfo orgPersonRelationInfo)
533 throws DoesNotExistException, InvalidParameterException,
534 MissingParameterException, OperationFailedException {
535
536 return null;
537 }
538
539 @Override
540 public List<ValidationResultInfo> validateOrgPositionRestriction(
541 String validationType,
542 OrgPositionRestrictionInfo orgPositionRestrictionInfo)
543 throws DoesNotExistException, InvalidParameterException,
544 MissingParameterException, OperationFailedException {
545
546 return null;
547 }
548
549 @Override
550 public ObjectStructure getObjectStructure(String objectTypeKey) {
551
552 return null;
553 }
554
555 @Override
556 public List<String> getObjectTypes() {
557
558 return null;
559 }
560
561 @Override
562 public SearchCriteriaTypeInfo getSearchCriteriaType(
563 String searchCriteriaTypeKey) throws DoesNotExistException,
564 InvalidParameterException, MissingParameterException,
565 OperationFailedException {
566
567 return null;
568 }
569
570 @Override
571 public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes()
572 throws OperationFailedException {
573
574 return null;
575 }
576
577 @Override
578 public SearchResultTypeInfo getSearchResultType(
579 String searchResultTypeKey) throws DoesNotExistException,
580 InvalidParameterException, MissingParameterException,
581 OperationFailedException {
582
583 return null;
584 }
585
586 @Override
587 public List<SearchResultTypeInfo> getSearchResultTypes()
588 throws OperationFailedException {
589
590 return null;
591 }
592
593 @Override
594 public SearchTypeInfo getSearchType(String searchTypeKey)
595 throws DoesNotExistException, InvalidParameterException,
596 MissingParameterException, OperationFailedException {
597
598 return null;
599 }
600
601 @Override
602 public List<SearchTypeInfo> getSearchTypes()
603 throws OperationFailedException {
604
605 return null;
606 }
607
608 @Override
609 public List<SearchTypeInfo> getSearchTypesByCriteria(
610 String searchCriteriaTypeKey) throws DoesNotExistException,
611 InvalidParameterException, MissingParameterException,
612 OperationFailedException {
613
614 return null;
615 }
616
617 @Override
618 public List<SearchTypeInfo> getSearchTypesByResult(
619 String searchResultTypeKey) throws DoesNotExistException,
620 InvalidParameterException, MissingParameterException,
621 OperationFailedException {
622
623 return null;
624 }
625
626 @Override
627 public SearchResult search(SearchRequest searchRequest)
628 throws MissingParameterException {
629
630 return null;
631 }
632
633 }
634 }