001 package org.kuali.student.lum.statement.config.context; 002 003 import java.util.ArrayList; 004 import java.util.Date; 005 import java.util.HashMap; 006 import java.util.List; 007 import java.util.Map; 008 009 import org.junit.Assert; 010 import org.junit.Before; 011 import org.junit.Test; 012 import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition; 013 import org.kuali.student.common.dto.StatusInfo; 014 import org.kuali.student.common.exceptions.AlreadyExistsException; 015 import org.kuali.student.common.exceptions.DataValidationErrorException; 016 import org.kuali.student.common.exceptions.DoesNotExistException; 017 import org.kuali.student.common.exceptions.InvalidParameterException; 018 import org.kuali.student.common.exceptions.MissingParameterException; 019 import org.kuali.student.common.exceptions.OperationFailedException; 020 import org.kuali.student.common.exceptions.PermissionDeniedException; 021 import org.kuali.student.common.exceptions.VersionMismatchException; 022 import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo; 023 import org.kuali.student.common.search.dto.SearchRequest; 024 import org.kuali.student.common.search.dto.SearchResult; 025 import org.kuali.student.common.search.dto.SearchResultTypeInfo; 026 import org.kuali.student.common.search.dto.SearchTypeInfo; 027 import org.kuali.student.common.validation.dto.ValidationResultInfo; 028 import org.kuali.student.core.atp.dto.AtpDurationTypeInfo; 029 import org.kuali.student.core.atp.dto.AtpInfo; 030 import org.kuali.student.core.atp.dto.AtpSeasonalTypeInfo; 031 import org.kuali.student.core.atp.dto.AtpTypeInfo; 032 import org.kuali.student.core.atp.dto.DateRangeInfo; 033 import org.kuali.student.core.atp.dto.DateRangeTypeInfo; 034 import org.kuali.student.core.atp.dto.MilestoneInfo; 035 import org.kuali.student.core.atp.dto.MilestoneTypeInfo; 036 import org.kuali.student.core.atp.service.AtpService; 037 import org.kuali.student.core.statement.dto.ReqCompFieldInfo; 038 import org.kuali.student.core.statement.dto.ReqComponentInfo; 039 040 public class AtpContextImplTest { 041 private AtpService atpService = new AtpServiceMock(); 042 private AtpContextImpl atpContext = new AtpContextImpl(); 043 private ReqComponentInfo reqComponent1; 044 private ReqComponentInfo reqComponent2; 045 046 private void setupReqComponent1() { 047 reqComponent1 = new ReqComponentInfo(); 048 List<ReqCompFieldInfo> reqCompFieldList = new ArrayList<ReqCompFieldInfo>(); 049 ReqCompFieldInfo reqCompField1 = new ReqCompFieldInfo(); 050 reqCompField1.setType("kuali.reqComponent.field.type.duration"); 051 reqCompField1.setValue("2"); 052 reqCompFieldList.add(reqCompField1); 053 ReqCompFieldInfo reqCompField2 = new ReqCompFieldInfo(); 054 reqCompField2.setType("kuali.reqComponent.field.type.durationType.id"); 055 reqCompField2.setValue("kuali.atp.duration.Year"); 056 reqCompFieldList.add(reqCompField2); 057 058 reqComponent1.setReqCompFields(reqCompFieldList); 059 } 060 061 private void setupReqComponent2() { 062 reqComponent2 = new ReqComponentInfo(); 063 List<ReqCompFieldInfo> reqCompFieldList = new ArrayList<ReqCompFieldInfo>(); 064 ReqCompFieldInfo reqCompField1 = new ReqCompFieldInfo(); 065 reqCompField1.setType("kuali.reqComponent.field.type.duration"); 066 reqCompField1.setValue(null); 067 reqCompFieldList.add(reqCompField1); 068 ReqCompFieldInfo reqCompField2 = new ReqCompFieldInfo(); 069 reqCompField2.setType("kuali.reqComponent.field.type.durationType.id"); 070 reqCompField2.setValue(null); 071 reqCompFieldList.add(reqCompField2); 072 073 reqComponent2.setReqCompFields(reqCompFieldList); 074 } 075 076 @Before 077 public void beforeMethod() { 078 atpContext.setAtpService(atpService); 079 setupReqComponent1(); 080 setupReqComponent2(); 081 } 082 083 @Test 084 public void testCreateContextMap_ContainsTokens() throws OperationFailedException { 085 Map<String, Object> contextMap = atpContext.createContextMap(reqComponent1); 086 Assert.assertNotNull(contextMap); 087 Assert.assertTrue(contextMap.containsKey(AtpContextImpl.DURATION_TOKEN)); 088 Assert.assertTrue(contextMap.containsKey(AtpContextImpl.DURATION_TYPE_TOKEN)); 089 } 090 091 @Test 092 public void testCreateContextMap_TokenValues() throws OperationFailedException { 093 Map<String, Object> contextMap = atpContext.createContextMap(reqComponent1); 094 String duration = (String) contextMap.get(AtpContextImpl.DURATION_TOKEN); 095 AtpDurationTypeInfo type = (AtpDurationTypeInfo) contextMap.get(AtpContextImpl.DURATION_TYPE_TOKEN); 096 097 Assert.assertEquals("2", duration); 098 Assert.assertEquals("kuali.atp.duration.Year", type.getId()); 099 } 100 101 @Test 102 public void testCreateContextMap_NullTokenValues() throws OperationFailedException { 103 Map<String, Object> contextMap = atpContext.createContextMap(reqComponent2); 104 String duration = (String) contextMap.get(AtpContextImpl.DURATION_TOKEN); 105 AtpDurationTypeInfo type = (AtpDurationTypeInfo) contextMap.get(AtpContextImpl.DURATION_TYPE_TOKEN); 106 107 Assert.assertEquals(null, duration); 108 Assert.assertEquals(null, type); 109 } 110 111 private static class AtpServiceMock implements AtpService { 112 113 private Map<String, AtpDurationTypeInfo> durationTypeMap = new HashMap<String, AtpDurationTypeInfo>(); 114 115 public AtpServiceMock() { 116 AtpDurationTypeInfo type1 = new AtpDurationTypeInfo(); 117 type1.setId("kuali.atp.duration.Year"); 118 type1.setName("Year"); 119 durationTypeMap.put("kuali.atp.duration.Year", type1); 120 121 AtpDurationTypeInfo type2 = new AtpDurationTypeInfo(); 122 type2.setId("kuali.atp.duration.Term"); 123 type2.setName("Term"); 124 durationTypeMap.put("kuali.atp.duration.Term", type2); 125 } 126 127 @Override 128 public DateRangeInfo addDateRange(String atpKey, String dateRangeKey, 129 DateRangeInfo dateRangeInfo) throws AlreadyExistsException, 130 DataValidationErrorException, InvalidParameterException, 131 MissingParameterException, OperationFailedException, 132 PermissionDeniedException { 133 // TODO Auto-generated method stub 134 return null; 135 } 136 137 @Override 138 public MilestoneInfo addMilestone(String atpKey, String milestoneKey, 139 MilestoneInfo milestoneInfo) throws AlreadyExistsException, 140 DataValidationErrorException, InvalidParameterException, 141 MissingParameterException, OperationFailedException, 142 PermissionDeniedException { 143 // TODO Auto-generated method stub 144 return null; 145 } 146 147 @Override 148 public AtpInfo createAtp(String atpTypeKey, String atpKey, 149 AtpInfo atpInfo) throws AlreadyExistsException, 150 DataValidationErrorException, InvalidParameterException, 151 MissingParameterException, OperationFailedException, 152 PermissionDeniedException { 153 // TODO Auto-generated method stub 154 return null; 155 } 156 157 @Override 158 public StatusInfo deleteAtp(String atpKey) 159 throws DoesNotExistException, InvalidParameterException, 160 MissingParameterException, OperationFailedException, 161 PermissionDeniedException { 162 // TODO Auto-generated method stub 163 return null; 164 } 165 166 @Override 167 public AtpInfo getAtp(String atpKey) throws DoesNotExistException, 168 InvalidParameterException, MissingParameterException, 169 OperationFailedException { 170 // TODO Auto-generated method stub 171 return null; 172 } 173 174 @Override 175 public AtpDurationTypeInfo getAtpDurationType(String atpDurationTypeKey) 176 throws DoesNotExistException, InvalidParameterException, 177 MissingParameterException, OperationFailedException { 178 return durationTypeMap.get(atpDurationTypeKey); 179 } 180 181 @Override 182 public List<AtpDurationTypeInfo> getAtpDurationTypes() 183 throws OperationFailedException { 184 // TODO Auto-generated method stub 185 return null; 186 } 187 188 @Override 189 public AtpSeasonalTypeInfo getAtpSeasonalType(String atpSeasonalTypeKey) 190 throws DoesNotExistException, InvalidParameterException, 191 MissingParameterException, OperationFailedException { 192 // TODO Auto-generated method stub 193 return null; 194 } 195 196 @Override 197 public List<AtpSeasonalTypeInfo> getAtpSeasonalTypes() 198 throws OperationFailedException { 199 // TODO Auto-generated method stub 200 return null; 201 } 202 203 @Override 204 public AtpTypeInfo getAtpType(String atpTypeKey) 205 throws DoesNotExistException, InvalidParameterException, 206 MissingParameterException, OperationFailedException { 207 // TODO Auto-generated method stub 208 return null; 209 } 210 211 @Override 212 public List<AtpTypeInfo> getAtpTypes() throws OperationFailedException { 213 // TODO Auto-generated method stub 214 return null; 215 } 216 217 @Override 218 public List<AtpInfo> getAtpsByAtpType(String atpTypeKey) 219 throws InvalidParameterException, MissingParameterException, 220 OperationFailedException { 221 // TODO Auto-generated method stub 222 return null; 223 } 224 225 @Override 226 public List<AtpInfo> getAtpsByDate(Date searchDate) 227 throws InvalidParameterException, MissingParameterException, 228 OperationFailedException { 229 // TODO Auto-generated method stub 230 return null; 231 } 232 233 @Override 234 public List<AtpInfo> getAtpsByDates(Date startDate, Date endDate) 235 throws InvalidParameterException, MissingParameterException, 236 OperationFailedException { 237 // TODO Auto-generated method stub 238 return null; 239 } 240 241 @Override 242 public DateRangeInfo getDateRange(String dateRangeKey) 243 throws DoesNotExistException, InvalidParameterException, 244 MissingParameterException, OperationFailedException { 245 // TODO Auto-generated method stub 246 return null; 247 } 248 249 @Override 250 public DateRangeTypeInfo getDateRangeType(String dateRangeTypeKey) 251 throws DoesNotExistException, InvalidParameterException, 252 MissingParameterException, OperationFailedException { 253 // TODO Auto-generated method stub 254 return null; 255 } 256 257 @Override 258 public List<DateRangeTypeInfo> getDateRangeTypes() 259 throws OperationFailedException { 260 // TODO Auto-generated method stub 261 return null; 262 } 263 264 @Override 265 public List<DateRangeTypeInfo> getDateRangeTypesForAtpType( 266 String atpTypeKey) throws DoesNotExistException, 267 InvalidParameterException, MissingParameterException, 268 OperationFailedException { 269 // TODO Auto-generated method stub 270 return null; 271 } 272 273 @Override 274 public List<DateRangeInfo> getDateRangesByAtp(String atpKey) 275 throws InvalidParameterException, MissingParameterException, 276 OperationFailedException { 277 // TODO Auto-generated method stub 278 return null; 279 } 280 281 @Override 282 public List<DateRangeInfo> getDateRangesByDate(Date searchDate) 283 throws InvalidParameterException, MissingParameterException, 284 OperationFailedException { 285 // TODO Auto-generated method stub 286 return null; 287 } 288 289 @Override 290 public MilestoneInfo getMilestone(String milestoneKey) 291 throws DoesNotExistException, InvalidParameterException, 292 MissingParameterException, OperationFailedException { 293 // TODO Auto-generated method stub 294 return null; 295 } 296 297 @Override 298 public MilestoneTypeInfo getMilestoneType(String milestoneTypeKey) 299 throws DoesNotExistException, InvalidParameterException, 300 MissingParameterException, OperationFailedException { 301 // TODO Auto-generated method stub 302 return null; 303 } 304 305 @Override 306 public List<MilestoneTypeInfo> getMilestoneTypes() 307 throws OperationFailedException { 308 // TODO Auto-generated method stub 309 return null; 310 } 311 312 @Override 313 public List<MilestoneTypeInfo> getMilestoneTypesForAtpType( 314 String atpTypeKey) throws DoesNotExistException, 315 InvalidParameterException, MissingParameterException, 316 OperationFailedException { 317 // TODO Auto-generated method stub 318 return null; 319 } 320 321 @Override 322 public List<MilestoneInfo> getMilestonesByAtp(String atpKey) 323 throws InvalidParameterException, MissingParameterException, 324 OperationFailedException { 325 // TODO Auto-generated method stub 326 return null; 327 } 328 329 @Override 330 public List<MilestoneInfo> getMilestonesByDates(Date startDate, 331 Date endDate) throws InvalidParameterException, 332 MissingParameterException, OperationFailedException { 333 // TODO Auto-generated method stub 334 return null; 335 } 336 337 @Override 338 public List<MilestoneInfo> getMilestonesByDatesAndType( 339 String milestoneTypeKey, Date startDate, Date endDate) 340 throws InvalidParameterException, MissingParameterException, 341 OperationFailedException { 342 // TODO Auto-generated method stub 343 return null; 344 } 345 346 @Override 347 public StatusInfo removeDateRange(String dateRangeKey) 348 throws DoesNotExistException, InvalidParameterException, 349 MissingParameterException, OperationFailedException, 350 PermissionDeniedException { 351 // TODO Auto-generated method stub 352 return null; 353 } 354 355 @Override 356 public StatusInfo removeMilestone(String milestoneKey) 357 throws DoesNotExistException, InvalidParameterException, 358 MissingParameterException, OperationFailedException, 359 PermissionDeniedException { 360 // TODO Auto-generated method stub 361 return null; 362 } 363 364 @Override 365 public AtpInfo updateAtp(String atpKey, AtpInfo atpInfo) 366 throws DataValidationErrorException, DoesNotExistException, 367 InvalidParameterException, MissingParameterException, 368 OperationFailedException, PermissionDeniedException, 369 VersionMismatchException { 370 // TODO Auto-generated method stub 371 return null; 372 } 373 374 @Override 375 public DateRangeInfo updateDateRange(String dateRangeKey, 376 DateRangeInfo dateRangeInfo) 377 throws DataValidationErrorException, DoesNotExistException, 378 InvalidParameterException, MissingParameterException, 379 OperationFailedException, PermissionDeniedException, 380 VersionMismatchException { 381 // TODO Auto-generated method stub 382 return null; 383 } 384 385 @Override 386 public MilestoneInfo updateMilestone(String milestoneKey, 387 MilestoneInfo milestoneInfo) 388 throws DataValidationErrorException, DoesNotExistException, 389 InvalidParameterException, MissingParameterException, 390 OperationFailedException, PermissionDeniedException, 391 VersionMismatchException { 392 // TODO Auto-generated method stub 393 return null; 394 } 395 396 @Override 397 public List<ValidationResultInfo> validateAtp(String validationType, 398 AtpInfo atpInfo) throws DoesNotExistException, 399 InvalidParameterException, MissingParameterException, 400 OperationFailedException { 401 // TODO Auto-generated method stub 402 return null; 403 } 404 405 @Override 406 public List<ValidationResultInfo> validateDateRange( 407 String validationType, DateRangeInfo dateRangeInfo) 408 throws DoesNotExistException, InvalidParameterException, 409 MissingParameterException, OperationFailedException { 410 // TODO Auto-generated method stub 411 return null; 412 } 413 414 @Override 415 public List<ValidationResultInfo> validateMilestone( 416 String validationType, MilestoneInfo milestoneInfo) 417 throws DoesNotExistException, InvalidParameterException, 418 MissingParameterException, OperationFailedException { 419 // TODO Auto-generated method stub 420 return null; 421 } 422 423 @Override 424 public SearchCriteriaTypeInfo getSearchCriteriaType( 425 String searchCriteriaTypeKey) throws DoesNotExistException, 426 InvalidParameterException, MissingParameterException, 427 OperationFailedException { 428 // TODO Auto-generated method stub 429 return null; 430 } 431 432 @Override 433 public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes() 434 throws OperationFailedException { 435 // TODO Auto-generated method stub 436 return null; 437 } 438 439 @Override 440 public SearchResultTypeInfo getSearchResultType( 441 String searchResultTypeKey) throws DoesNotExistException, 442 InvalidParameterException, MissingParameterException, 443 OperationFailedException { 444 // TODO Auto-generated method stub 445 return null; 446 } 447 448 @Override 449 public List<SearchResultTypeInfo> getSearchResultTypes() 450 throws OperationFailedException { 451 // TODO Auto-generated method stub 452 return null; 453 } 454 455 @Override 456 public SearchTypeInfo getSearchType(String searchTypeKey) 457 throws DoesNotExistException, InvalidParameterException, 458 MissingParameterException, OperationFailedException { 459 // TODO Auto-generated method stub 460 return null; 461 } 462 463 @Override 464 public List<SearchTypeInfo> getSearchTypes() 465 throws OperationFailedException { 466 // TODO Auto-generated method stub 467 return null; 468 } 469 470 @Override 471 public List<SearchTypeInfo> getSearchTypesByCriteria( 472 String searchCriteriaTypeKey) throws DoesNotExistException, 473 InvalidParameterException, MissingParameterException, 474 OperationFailedException { 475 // TODO Auto-generated method stub 476 return null; 477 } 478 479 @Override 480 public List<SearchTypeInfo> getSearchTypesByResult( 481 String searchResultTypeKey) throws DoesNotExistException, 482 InvalidParameterException, MissingParameterException, 483 OperationFailedException { 484 // TODO Auto-generated method stub 485 return null; 486 } 487 488 @Override 489 public SearchResult search(SearchRequest searchRequest) 490 throws MissingParameterException { 491 // TODO Auto-generated method stub 492 return null; 493 } 494 495 @Override 496 public ObjectStructureDefinition getObjectStructure(String objectTypeKey) { 497 // TODO Kamal - THIS METHOD NEEDS JAVADOCS 498 return null; 499 } 500 501 @Override 502 public List<String> getObjectTypes() { 503 // TODO Kamal - THIS METHOD NEEDS JAVADOCS 504 return null; 505 } 506 507 } 508 }