001 package org.kuali.student.lum.statement.config.context;
002
003 import java.util.ArrayList;
004 import java.util.HashMap;
005 import java.util.List;
006 import java.util.Map;
007
008 import org.junit.Assert;
009 import org.junit.Before;
010 import org.junit.Test;
011 import org.kuali.student.common.dictionary.old.dto.ObjectStructure;
012 import org.kuali.student.common.dto.StatusInfo;
013 import org.kuali.student.common.exceptions.AlreadyExistsException;
014 import org.kuali.student.common.exceptions.DataValidationErrorException;
015 import org.kuali.student.common.exceptions.DoesNotExistException;
016 import org.kuali.student.common.exceptions.InvalidParameterException;
017 import org.kuali.student.common.exceptions.MissingParameterException;
018 import org.kuali.student.common.exceptions.OperationFailedException;
019 import org.kuali.student.common.exceptions.PermissionDeniedException;
020 import org.kuali.student.common.exceptions.VersionMismatchException;
021 import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo;
022 import org.kuali.student.common.search.dto.SearchRequest;
023 import org.kuali.student.common.search.dto.SearchResult;
024 import org.kuali.student.common.search.dto.SearchResultTypeInfo;
025 import org.kuali.student.common.search.dto.SearchTypeInfo;
026 import org.kuali.student.common.validation.dto.ValidationResultInfo;
027 import org.kuali.student.core.organization.dto.OrgHierarchyInfo;
028 import org.kuali.student.core.organization.dto.OrgInfo;
029 import org.kuali.student.core.organization.dto.OrgOrgRelationInfo;
030 import org.kuali.student.core.organization.dto.OrgOrgRelationTypeInfo;
031 import org.kuali.student.core.organization.dto.OrgPersonRelationInfo;
032 import org.kuali.student.core.organization.dto.OrgPersonRelationTypeInfo;
033 import org.kuali.student.core.organization.dto.OrgPositionRestrictionInfo;
034 import org.kuali.student.core.organization.dto.OrgTreeInfo;
035 import org.kuali.student.core.organization.dto.OrgTypeInfo;
036 import org.kuali.student.core.organization.service.OrganizationService;
037 import org.kuali.student.core.statement.dto.ReqCompFieldInfo;
038 import org.kuali.student.core.statement.dto.ReqComponentInfo;
039 import org.kuali.student.lum.statement.typekey.ReqComponentFieldTypes;
040
041 public class OrganizationContextImplTest {
042
043 private OrganizationService organizationService = new OrganizationServiceMock();
044 private OrganizationContextImpl organizationContext = new OrganizationContextImpl();
045
046 private ReqComponentInfo reqComponent1;
047 private ReqComponentInfo reqComponent2;
048
049 private void setupReqComponent1() {
050 reqComponent1 = new ReqComponentInfo();
051 List<ReqCompFieldInfo> reqCompFieldList = new ArrayList<ReqCompFieldInfo>();
052 ReqCompFieldInfo reqCompField1 = new ReqCompFieldInfo();
053 reqCompField1.setType(ReqComponentFieldTypes.ORGANIZATION_KEY.getId());
054 reqCompField1.setValue("59");
055 reqCompFieldList.add(reqCompField1);
056 reqComponent1.setReqCompFields(reqCompFieldList);
057 }
058
059 private void setupReqComponent2() {
060 reqComponent2 = new ReqComponentInfo();
061 List<ReqCompFieldInfo> reqCompFieldList = new ArrayList<ReqCompFieldInfo>();
062 ReqCompFieldInfo reqCompField1 = new ReqCompFieldInfo();
063 reqCompField1.setType(ReqComponentFieldTypes.ORGANIZATION_KEY.getId());
064 reqCompField1.setValue(null);
065 reqCompFieldList.add(reqCompField1);
066 reqComponent2.setReqCompFields(reqCompFieldList);
067 }
068
069 @Before
070 public void beforeMethod() {
071 organizationContext.setOrganizationService(organizationService);
072 setupReqComponent1();
073 setupReqComponent2();
074 }
075
076 @Test
077 public void testCreateContextMap() throws OperationFailedException {
078 Map<String, Object> contextMap = organizationContext.createContextMap(reqComponent1);
079 OrgInfo org = (OrgInfo) contextMap.get(OrganizationContextImpl.ORG_TOKEN);
080
081 Assert.assertNotNull(contextMap);
082 Assert.assertEquals("kuali.org.Department", org.getType());
083 Assert.assertEquals("Sociology", org.getShortName());
084 Assert.assertEquals("Sociology Dept", org.getLongName());
085 }
086
087 @Test
088 public void testCreateContextMap_NullTokenValues() throws OperationFailedException {
089 Map<String, Object> contextMap = organizationContext.createContextMap(reqComponent2);
090 OrgInfo org = (OrgInfo) contextMap.get(OrganizationContextImpl.ORG_TOKEN);
091
092 Assert.assertNotNull(contextMap);
093 Assert.assertEquals(null, org);
094 }
095
096 private static class OrganizationServiceMock implements OrganizationService {
097
098 private Map<String, OrgInfo> orgMap = new HashMap<String, OrgInfo>();
099
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
158 return null;
159 }
160
161 @Override
162 public StatusInfo deleteOrganization(String orgId)
163 throws DoesNotExistException, InvalidParameterException,
164 MissingParameterException, OperationFailedException,
165 PermissionDeniedException {
166 // TODO Auto-generated method stub
167 return null;
168 }
169
170 @Override
171 public List<String> getAllAncestors(String orgId, String orgHierarchy)
172 throws InvalidParameterException, MissingParameterException,
173 OperationFailedException, PermissionDeniedException {
174 // TODO Auto-generated method stub
175 return null;
176 }
177
178 @Override
179 public List<String> getAllDescendants(String orgId, String orgHierarchy)
180 throws InvalidParameterException, MissingParameterException,
181 OperationFailedException, PermissionDeniedException {
182 // TODO Auto-generated method stub
183 return null;
184 }
185
186 @Override
187 public List<OrgPersonRelationInfo> getAllOrgPersonRelationsByOrg(
188 String orgId) throws DoesNotExistException,
189 InvalidParameterException, MissingParameterException,
190 OperationFailedException, PermissionDeniedException {
191 // TODO Auto-generated method stub
192 return null;
193 }
194
195 @Override
196 public List<OrgPersonRelationInfo> getAllOrgPersonRelationsByPerson(
197 String personId) throws DoesNotExistException,
198 InvalidParameterException, MissingParameterException,
199 OperationFailedException, PermissionDeniedException {
200 // TODO Auto-generated method stub
201 return null;
202 }
203
204 @Override
205 public List<OrgHierarchyInfo> getOrgHierarchies()
206 throws OperationFailedException {
207 // TODO Auto-generated method stub
208 return null;
209 }
210
211 @Override
212 public OrgHierarchyInfo getOrgHierarchy(String orgHierarchyKey)
213 throws DoesNotExistException, InvalidParameterException,
214 MissingParameterException, OperationFailedException {
215 // TODO Auto-generated method stub
216 return null;
217 }
218
219 @Override
220 public OrgOrgRelationInfo getOrgOrgRelation(String orgOrgRelationId)
221 throws DoesNotExistException, InvalidParameterException,
222 MissingParameterException, OperationFailedException,
223 PermissionDeniedException {
224 // TODO Auto-generated method stub
225 return null;
226 }
227
228 @Override
229 public OrgOrgRelationTypeInfo getOrgOrgRelationType(
230 String orgOrgRelationTypeKey) throws DoesNotExistException,
231 InvalidParameterException, MissingParameterException,
232 OperationFailedException {
233 // TODO Auto-generated method stub
234 return null;
235 }
236
237 @Override
238 public List<OrgOrgRelationTypeInfo> getOrgOrgRelationTypes()
239 throws OperationFailedException {
240 // TODO Auto-generated method stub
241 return null;
242 }
243
244 @Override
245 public List<OrgOrgRelationTypeInfo> getOrgOrgRelationTypesForOrgHierarchy(
246 String orgHierarchyKey) throws DoesNotExistException,
247 InvalidParameterException, MissingParameterException,
248 OperationFailedException {
249 // TODO Auto-generated method stub
250 return null;
251 }
252
253 @Override
254 public List<OrgOrgRelationTypeInfo> getOrgOrgRelationTypesForOrgType(
255 String orgTypeKey) throws DoesNotExistException,
256 InvalidParameterException, MissingParameterException,
257 OperationFailedException {
258 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
269 return null;
270 }
271
272 @Override
273 public List<OrgOrgRelationInfo> getOrgOrgRelationsByOrg(String orgId)
274 throws DoesNotExistException, InvalidParameterException,
275 MissingParameterException, OperationFailedException,
276 PermissionDeniedException {
277 // TODO Auto-generated method stub
278 return null;
279 }
280
281 @Override
282 public List<OrgOrgRelationInfo> getOrgOrgRelationsByRelatedOrg(
283 String relatedOrgId) throws DoesNotExistException,
284 InvalidParameterException, MissingParameterException,
285 OperationFailedException, PermissionDeniedException {
286 // TODO Auto-generated method stub
287 return null;
288 }
289
290 @Override
291 public OrgPersonRelationInfo getOrgPersonRelation(
292 String orgPersonRelationId) throws DoesNotExistException,
293 InvalidParameterException, MissingParameterException,
294 OperationFailedException, PermissionDeniedException {
295 // TODO Auto-generated method stub
296 return null;
297 }
298
299 @Override
300 public OrgPersonRelationTypeInfo getOrgPersonRelationType(
301 String orgPersonRelationTypeKey) throws DoesNotExistException,
302 InvalidParameterException, MissingParameterException,
303 OperationFailedException {
304 // TODO Auto-generated method stub
305 return null;
306 }
307
308 @Override
309 public List<OrgPersonRelationTypeInfo> getOrgPersonRelationTypes()
310 throws OperationFailedException {
311 // TODO Auto-generated method stub
312 return null;
313 }
314
315 @Override
316 public List<OrgPersonRelationTypeInfo> getOrgPersonRelationTypesForOrgType(
317 String orgTypeKey) throws DoesNotExistException,
318 InvalidParameterException, MissingParameterException,
319 OperationFailedException {
320 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
331 return null;
332 }
333
334 @Override
335 public List<OrgPersonRelationInfo> getOrgPersonRelationsByOrg(
336 String orgId) throws DoesNotExistException,
337 InvalidParameterException, MissingParameterException,
338 OperationFailedException, PermissionDeniedException {
339 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
359 return null;
360 }
361
362 @Override
363 public OrgTypeInfo getOrgType(String orgTypeKey)
364 throws DoesNotExistException, InvalidParameterException,
365 MissingParameterException, OperationFailedException {
366 // TODO Auto-generated method stub
367 return null;
368 }
369
370 @Override
371 public List<OrgTypeInfo> getOrgTypes() throws OperationFailedException {
372 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
436 return null;
437 }
438
439 @Override
440 public StatusInfo removeOrgOrgRelation(String orgOrgRelationId)
441 throws DoesNotExistException, InvalidParameterException,
442 MissingParameterException, OperationFailedException,
443 PermissionDeniedException {
444 // TODO Auto-generated method stub
445 return null;
446 }
447
448 @Override
449 public StatusInfo removeOrgPersonRelation(String orgPersonRelationId)
450 throws DoesNotExistException, InvalidParameterException,
451 MissingParameterException, OperationFailedException,
452 PermissionDeniedException {
453 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
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 // TODO Auto-generated method stub
546 return null;
547 }
548
549 @Override
550 public ObjectStructure getObjectStructure(String objectTypeKey) {
551 // TODO Auto-generated method stub
552 return null;
553 }
554
555 @Override
556 public List<String> getObjectTypes() {
557 // TODO Auto-generated method stub
558 return null;
559 }
560
561 @Override
562 public SearchCriteriaTypeInfo getSearchCriteriaType(
563 String searchCriteriaTypeKey) throws DoesNotExistException,
564 InvalidParameterException, MissingParameterException,
565 OperationFailedException {
566 // TODO Auto-generated method stub
567 return null;
568 }
569
570 @Override
571 public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes()
572 throws OperationFailedException {
573 // TODO Auto-generated method stub
574 return null;
575 }
576
577 @Override
578 public SearchResultTypeInfo getSearchResultType(
579 String searchResultTypeKey) throws DoesNotExistException,
580 InvalidParameterException, MissingParameterException,
581 OperationFailedException {
582 // TODO Auto-generated method stub
583 return null;
584 }
585
586 @Override
587 public List<SearchResultTypeInfo> getSearchResultTypes()
588 throws OperationFailedException {
589 // TODO Auto-generated method stub
590 return null;
591 }
592
593 @Override
594 public SearchTypeInfo getSearchType(String searchTypeKey)
595 throws DoesNotExistException, InvalidParameterException,
596 MissingParameterException, OperationFailedException {
597 // TODO Auto-generated method stub
598 return null;
599 }
600
601 @Override
602 public List<SearchTypeInfo> getSearchTypes()
603 throws OperationFailedException {
604 // TODO Auto-generated method stub
605 return null;
606 }
607
608 @Override
609 public List<SearchTypeInfo> getSearchTypesByCriteria(
610 String searchCriteriaTypeKey) throws DoesNotExistException,
611 InvalidParameterException, MissingParameterException,
612 OperationFailedException {
613 // TODO Auto-generated method stub
614 return null;
615 }
616
617 @Override
618 public List<SearchTypeInfo> getSearchTypesByResult(
619 String searchResultTypeKey) throws DoesNotExistException,
620 InvalidParameterException, MissingParameterException,
621 OperationFailedException {
622 // TODO Auto-generated method stub
623 return null;
624 }
625
626 @Override
627 public SearchResult search(SearchRequest searchRequest)
628 throws MissingParameterException {
629 // TODO Auto-generated method stub
630 return null;
631 }
632
633 }
634 }