1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.service.impl;
17
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNull;
20 import static org.mockito.Matchers.anyListOf;
21 import static org.mockito.Matchers.anyMapOf;
22 import static org.mockito.Matchers.anyObject;
23 import static org.mockito.Matchers.eq;
24 import static org.mockito.Mockito.verify;
25 import static org.mockito.Mockito.verifyZeroInteractions;
26
27 import java.io.Serializable;
28 import java.util.ArrayList;
29 import java.util.HashMap;
30
31 import javax.xml.namespace.QName;
32
33 import org.apache.ojb.broker.metadata.ClassDescriptor;
34 import org.apache.ojb.broker.metadata.MetadataManager;
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.junit.runner.RunWith;
38 import org.kuali.rice.core.api.CoreConstants;
39 import org.kuali.rice.core.api.config.property.ConfigContext;
40 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
41 import org.kuali.rice.core.api.resourceloader.ResourceLoader;
42 import org.kuali.rice.core.framework.config.property.SimpleConfig;
43 import org.kuali.rice.core.framework.resourceloader.BeanFactoryResourceLoader;
44 import org.kuali.rice.krad.bo.PersistableBusinessObject;
45 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
46 import org.kuali.rice.krad.data.metadata.MetadataRepository;
47 import org.kuali.rice.krad.document.Document;
48 import org.kuali.rice.krad.document.DocumentBase;
49 import org.kuali.rice.krad.service.DataDictionaryService;
50 import org.kuali.rice.krad.service.LegacyDataAdapter;
51 import org.kuali.rice.krad.util.KRADConstants;
52 import org.mockito.InjectMocks;
53 import org.mockito.Mock;
54 import org.mockito.runners.MockitoJUnitRunner;
55 import org.springframework.beans.factory.support.StaticListableBeanFactory;
56
57
58
59
60
61
62
63 @RunWith(MockitoJUnitRunner.class)
64 public class LegacyDataAdapterImplTest {
65
66 @Mock private LegacyDataAdapter knsLegacyDataAdapter;
67 @Mock private LegacyDataAdapter kradLegacyDataAdapter;
68 @Mock private DataDictionaryService dataDictionaryService;
69 @Mock private MetadataRepository metadataRepository;
70
71 @InjectMocks private LegacyDataAdapterImpl lda = new LegacyDataAdapterImpl();
72
73 @Before
74 public void setup() throws Exception {
75 GlobalResourceLoader.stop();
76
77 SimpleConfig config = new SimpleConfig();
78 config.putProperty(CoreConstants.Config.APPLICATION_ID, getClass().getName());
79 ConfigContext.init(config);
80 ConfigContext.getCurrentContextConfig().removeProperty(KRADConstants.Config.ENABLE_LEGACY_DATA_FRAMEWORK);
81 ConfigContext.getCurrentContextConfig().removeProperty(KRADConstants.Config.KNS_ENABLED);
82
83 StaticListableBeanFactory testBf = new StaticListableBeanFactory();
84 testBf.addBean("kd-metadataRepository", metadataRepository);
85 testBf.addBean("dataDictionaryService", dataDictionaryService);
86 testBf.addBean("knsLegacyDataAdapter", knsLegacyDataAdapter);
87 testBf.addBean("kradLegacyDataAdapter", kradLegacyDataAdapter);
88
89 ResourceLoader rl = new BeanFactoryResourceLoader(new QName(getClass().getName()), testBf);
90 GlobalResourceLoader.addResourceLoader(rl);
91 GlobalResourceLoader.start();
92
93 MetadataManager mm = MetadataManager.getInstance();
94
95
96 ClassDescriptor legacyDescriptor = new ClassDescriptor(mm.getGlobalRepository());
97 legacyDescriptor.setClassOfObject(Legacy.class);
98 mm.getGlobalRepository().put(Legacy.class, legacyDescriptor);
99
100
101 ClassDescriptor legacyDocumentDescriptor = new ClassDescriptor(mm.getGlobalRepository());
102 legacyDocumentDescriptor.setClassOfObject(LegacyDocument.class);
103 mm.getGlobalRepository().put(LegacyDocument.class, legacyDocumentDescriptor);
104 }
105
106 protected void enableLegacy() {
107 ConfigContext.getCurrentContextConfig().putProperty(KRADConstants.Config.KNS_ENABLED, "true");
108 }
109
110 protected NonLegacy newNonLegacyObject() {
111 return new NonLegacy();
112 }
113
114 protected NonLegacyPersistableBusinessObject newNonLegacyPersistableBusinessObject() {
115 return new NonLegacyPersistableBusinessObject();
116 }
117
118 protected Legacy newLegacyObject() {
119 return new Legacy();
120 }
121
122 protected NonLegacyDocument newNonLegacyDocument() {
123 return new NonLegacyDocument();
124 }
125
126 protected LegacyDocument newLegacyDocument() {
127 return new LegacyDocument();
128 }
129
130 @Test
131 public void testSave() throws Exception {
132 Serializable object = newNonLegacyObject();
133 lda.save(object);
134 verify(kradLegacyDataAdapter).save(object);
135 verifyZeroInteractions(knsLegacyDataAdapter);
136 }
137
138 @Test
139 public void testSave_Legacy() throws Exception {
140 enableLegacy();
141 PersistableBusinessObject object = newLegacyObject();
142 lda.save(object);
143 verify(knsLegacyDataAdapter).save(object);
144 verifyZeroInteractions(kradLegacyDataAdapter);
145 }
146
147 @Test
148 public void testLinkAndSave() throws Exception {
149 Serializable object = newNonLegacyObject();
150 lda.linkAndSave(object);
151 verify(kradLegacyDataAdapter).linkAndSave(object);
152 verifyZeroInteractions(knsLegacyDataAdapter);
153 }
154
155 @Test
156 public void testLinkAndSave_Legacy() throws Exception {
157 enableLegacy();
158 Serializable object = newLegacyObject();
159 lda.linkAndSave(object);
160 verify(knsLegacyDataAdapter).linkAndSave(object);
161 verifyZeroInteractions(kradLegacyDataAdapter);
162 }
163
164 @Test
165 public void testSaveDocument() throws Exception {
166 Document document = newNonLegacyDocument();
167 lda.saveDocument(document);
168 verify(kradLegacyDataAdapter).saveDocument(document);
169 verifyZeroInteractions(knsLegacyDataAdapter);
170 }
171
172 @Test
173 public void testSaveDocument_Legacy() throws Exception {
174 enableLegacy();
175 Document document = newLegacyDocument();
176 lda.saveDocument(document);
177 verify(knsLegacyDataAdapter).saveDocument(document);
178 verifyZeroInteractions(kradLegacyDataAdapter);
179 }
180
181 @Test
182 public void testFindByPrimaryKey() throws Exception {
183 lda.findByPrimaryKey(NonLegacy.class, new HashMap<String, Object>());
184 verify(kradLegacyDataAdapter).findByPrimaryKey(eq(NonLegacy.class), anyMapOf(String.class, Object.class));
185 verifyZeroInteractions(knsLegacyDataAdapter);
186 }
187
188 @Test
189 public void testFindByPrimaryKey_Legacy() throws Exception {
190 enableLegacy();
191 lda.findByPrimaryKey(Legacy.class, new HashMap<String, Object>());
192 verify(knsLegacyDataAdapter).findByPrimaryKey(eq(Legacy.class), anyMapOf(String.class, Object.class));
193 verifyZeroInteractions(kradLegacyDataAdapter);
194 }
195
196 @Test
197 public void testFindBySinglePrimaryKey() throws Exception {
198 lda.findBySinglePrimaryKey(NonLegacy.class, new Object());
199 verify(kradLegacyDataAdapter).findBySinglePrimaryKey(eq(NonLegacy.class), anyObject());
200 verifyZeroInteractions(knsLegacyDataAdapter);
201 }
202
203 @Test
204 public void testFindBySinglePrimaryKey_Legacy() throws Exception {
205 enableLegacy();
206 lda.findBySinglePrimaryKey(Legacy.class, new Object());
207 verify(knsLegacyDataAdapter).findBySinglePrimaryKey(eq(Legacy.class), anyObject());
208 verifyZeroInteractions(kradLegacyDataAdapter);
209 }
210
211 @Test
212 public void testDelete() throws Exception {
213 Object object = newNonLegacyObject();
214 lda.delete(object);
215 verify(kradLegacyDataAdapter).delete(eq(object));
216 verifyZeroInteractions(knsLegacyDataAdapter);
217 }
218
219 @Test
220 public void testDelete_Legacy() throws Exception {
221 enableLegacy();
222 Object object = newLegacyObject();
223 lda.delete(object);
224 verify(knsLegacyDataAdapter).delete(eq(object));
225 verifyZeroInteractions(kradLegacyDataAdapter);
226 }
227
228 @Test
229 public void testDeleteMatching() throws Exception {
230 lda.deleteMatching(NonLegacy.class, new HashMap<String, String>());
231 verify(kradLegacyDataAdapter).deleteMatching(eq(NonLegacy.class), anyMapOf(String.class, String.class));
232 verifyZeroInteractions(knsLegacyDataAdapter);
233 }
234
235 @Test
236 public void testDeleteMatching_Legacy() throws Exception {
237 enableLegacy();
238 lda.deleteMatching(Legacy.class, new HashMap<String, String>());
239 verify(knsLegacyDataAdapter).deleteMatching(eq(Legacy.class), anyMapOf(String.class, String.class));
240 verifyZeroInteractions(kradLegacyDataAdapter);
241 }
242
243 @Test
244 public void testRetrieve() throws Exception {
245 Object object = newNonLegacyObject();
246 lda.retrieve(object);
247 verify(kradLegacyDataAdapter).retrieve(eq(object));
248 verifyZeroInteractions(knsLegacyDataAdapter);
249 }
250
251 @Test
252 public void testRetrieve_Legacy() throws Exception {
253 enableLegacy();
254 Object object = newLegacyObject();
255 lda.retrieve(object);
256 verify(knsLegacyDataAdapter).retrieve(eq(object));
257 verifyZeroInteractions(kradLegacyDataAdapter);
258 }
259
260 @Test
261 public void testFindAll() throws Exception {
262 lda.findAll(NonLegacy.class);
263 verify(kradLegacyDataAdapter).findAll(eq(NonLegacy.class));
264 verifyZeroInteractions(knsLegacyDataAdapter);
265 }
266
267 @Test
268 public void testFindAll_Legacy() throws Exception {
269 enableLegacy();
270 lda.findAll(Legacy.class);
271 verify(knsLegacyDataAdapter).findAll(eq(Legacy.class));;
272 verifyZeroInteractions(kradLegacyDataAdapter);
273 }
274
275 @Test
276 public void testFindMatching() throws Exception {
277 lda.findMatching(NonLegacy.class, new HashMap<String, String>());
278 verify(kradLegacyDataAdapter).findMatching(eq(NonLegacy.class), anyMapOf(String.class, String.class));
279 verifyZeroInteractions(knsLegacyDataAdapter);
280 }
281
282 @Test
283 public void testFindMatching_Legacy() throws Exception {
284 enableLegacy();
285 lda.findMatching(Legacy.class, new HashMap<String, String>());
286 verify(knsLegacyDataAdapter).findMatching(eq(Legacy.class), anyMapOf(String.class, String.class));
287 verifyZeroInteractions(kradLegacyDataAdapter);
288 }
289
290
291 @Test
292 public void testFindMatchingOrderBy() throws Exception {
293 lda.findMatchingOrderBy(NonLegacy.class, new HashMap<String, String>(), "a", true);
294 verify(kradLegacyDataAdapter).findMatchingOrderBy(eq(NonLegacy.class), anyMapOf(String.class, String.class), eq(
295 "a"), eq(Boolean.TRUE));
296 verifyZeroInteractions(knsLegacyDataAdapter);
297 }
298
299 @Test
300 public void testFindMatchingOrderBy_Legacy() throws Exception {
301 enableLegacy();
302 lda.findMatchingOrderBy(Legacy.class, new HashMap<String, String>(), "a", true);
303 verify(knsLegacyDataAdapter).findMatchingOrderBy(eq(Legacy.class), anyMapOf(String.class, String.class), eq(
304 "a"), eq(Boolean.TRUE));
305 verifyZeroInteractions(kradLegacyDataAdapter);
306 }
307
308
309 @Test
310 public void testGetPrimaryKeyFieldValues() throws Exception {
311 Object object = newNonLegacyObject();
312 lda.getPrimaryKeyFieldValues(object);
313 verify(kradLegacyDataAdapter).getPrimaryKeyFieldValues(eq(object));
314 verifyZeroInteractions(knsLegacyDataAdapter);
315 }
316
317 @Test
318 public void testGetPrimaryKeyFieldValues_Legacy() throws Exception {
319 enableLegacy();
320 Object object = newLegacyObject();
321 lda.getPrimaryKeyFieldValues(object);
322 verify(knsLegacyDataAdapter).getPrimaryKeyFieldValues(eq(object));
323 verifyZeroInteractions(kradLegacyDataAdapter);
324 }
325
326 @Test
327 public void testRetrieveNonKeyFields() throws Exception {
328 Object object = newNonLegacyObject();
329 lda.retrieveNonKeyFields(object);
330 verify(kradLegacyDataAdapter).retrieveNonKeyFields(eq(object));
331 verifyZeroInteractions(knsLegacyDataAdapter);
332 }
333
334 @Test
335 public void testRetrieveNonKeyFields_Legacy() throws Exception {
336 enableLegacy();
337 Object object = newLegacyObject();
338 lda.retrieveNonKeyFields(object);
339 verify(knsLegacyDataAdapter).retrieveNonKeyFields(eq(object));
340 verifyZeroInteractions(kradLegacyDataAdapter);
341 }
342
343 @Test
344 public void testRetrieveReferenceObject() throws Exception {
345 Object object = newNonLegacyObject();
346 lda.retrieveReferenceObject(object, "blah");
347 verify(kradLegacyDataAdapter).retrieveReferenceObject(eq(object), eq("blah"));
348 verifyZeroInteractions(knsLegacyDataAdapter);
349 }
350
351 @Test
352 public void testRetrieveReferenceObject_Legacy() throws Exception {
353 enableLegacy();
354 Object object = newLegacyObject();
355 lda.retrieveReferenceObject(object, "blah");
356 verify(knsLegacyDataAdapter).retrieveReferenceObject(eq(object), eq("blah"));
357 verifyZeroInteractions(kradLegacyDataAdapter);
358 }
359
360 @Test
361 public void testRefreshAllNonUpdatingReferences() throws Exception {
362 Object object = newNonLegacyObject();
363 lda.refreshAllNonUpdatingReferences(object);
364 verify(kradLegacyDataAdapter).refreshAllNonUpdatingReferences(eq(object));
365 verifyZeroInteractions(knsLegacyDataAdapter);
366 }
367
368 @Test
369 public void testRefreshAllNonUpdatingReferences_Legacy() throws Exception {
370 enableLegacy();
371 Object object = newLegacyObject();
372 lda.refreshAllNonUpdatingReferences(object);
373 verify(knsLegacyDataAdapter).refreshAllNonUpdatingReferences(eq(object));
374 verifyZeroInteractions(kradLegacyDataAdapter);
375 }
376
377
378 @Test
379 public void testIsProxied() throws Exception {
380 Object object = newNonLegacyObject();
381 lda.isProxied(object);
382 verify(kradLegacyDataAdapter).isProxied(eq(object));
383 verifyZeroInteractions(knsLegacyDataAdapter);
384 }
385
386 @Test
387 public void testIsProxied_Legacy() throws Exception {
388 enableLegacy();
389 Object object = newLegacyObject();
390 lda.isProxied(object);
391 verify(knsLegacyDataAdapter).isProxied(eq(object));
392 verifyZeroInteractions(kradLegacyDataAdapter);
393 }
394
395
396 @Test
397 public void testResolveProxy() throws Exception {
398 Object object = newNonLegacyObject();
399 lda.resolveProxy(object);
400 verify(kradLegacyDataAdapter).resolveProxy(eq(object));
401 verifyZeroInteractions(knsLegacyDataAdapter);
402 }
403
404 @Test
405 public void testResolveProxy_Legacy() throws Exception {
406 enableLegacy();
407 Object object = newLegacyObject();
408 lda.resolveProxy(object);
409 verify(knsLegacyDataAdapter).resolveProxy(eq(object));
410 verifyZeroInteractions(kradLegacyDataAdapter);
411 }
412
413 @Test
414 public void testFindCollectionBySearchHelper() throws Exception {
415 lda.findCollectionBySearchHelper(NonLegacy.class, new HashMap<String, String>(), true, true, 50);
416 verify(kradLegacyDataAdapter).findCollectionBySearchHelper(eq(NonLegacy.class), anyMapOf(String.class,
417 String.class), eq(true), eq(true), eq(50));
418 verifyZeroInteractions(knsLegacyDataAdapter);
419 }
420
421 @Test
422 public void testFindCollectionBySearchHelper_Legacy() throws Exception {
423 enableLegacy();
424 lda.findCollectionBySearchHelper(Legacy.class, new HashMap<String, String>(), true, true, 50);
425 verify(knsLegacyDataAdapter).findCollectionBySearchHelper(eq(Legacy.class), anyMapOf(String.class,
426 String.class), eq(true), eq(true), eq(50));
427 verifyZeroInteractions(kradLegacyDataAdapter);
428 }
429
430 @Test
431 public void testFindObjectBySearch() throws Exception {
432 lda.findObjectBySearch(NonLegacy.class, new HashMap<String, String>());
433 verify(kradLegacyDataAdapter).findObjectBySearch(eq(NonLegacy.class), anyMapOf(String.class, String.class));
434 verifyZeroInteractions(knsLegacyDataAdapter);
435 }
436
437 @Test
438 public void testFindObjectBySearch_Legacy() throws Exception {
439 enableLegacy();
440 lda.findObjectBySearch(Legacy.class, new HashMap<String, String>());
441 verify(knsLegacyDataAdapter).findObjectBySearch(eq(Legacy.class), anyMapOf(String.class, String.class));
442 verifyZeroInteractions(kradLegacyDataAdapter);
443 }
444
445 @Test
446 public void testAllPrimaryKeyValuesPresentAndNotWildcard() throws Exception {
447 lda.allPrimaryKeyValuesPresentAndNotWildcard(NonLegacy.class, new HashMap<String, String>());
448 verify(kradLegacyDataAdapter).allPrimaryKeyValuesPresentAndNotWildcard(eq(NonLegacy.class), anyMapOf(
449 String.class, String.class));
450 verifyZeroInteractions(knsLegacyDataAdapter);
451 }
452
453 @Test
454 public void testAllPrimaryKeyValuesPresentAndNotWildcard_Legacy() throws Exception {
455 enableLegacy();
456 lda.allPrimaryKeyValuesPresentAndNotWildcard(Legacy.class, new HashMap<String, String>());
457 verify(knsLegacyDataAdapter).allPrimaryKeyValuesPresentAndNotWildcard(eq(Legacy.class), anyMapOf(String.class, String.class));
458 verifyZeroInteractions(kradLegacyDataAdapter);
459 }
460
461 @Test
462 public void testListPrimaryKeyFieldNames() throws Exception {
463 lda.listPrimaryKeyFieldNames(NonLegacy.class);
464 verify(kradLegacyDataAdapter).listPrimaryKeyFieldNames(eq(NonLegacy.class));
465 verifyZeroInteractions(knsLegacyDataAdapter);
466 }
467
468 @Test
469 public void testListPrimaryKeyFieldNames_Legacy() throws Exception {
470 enableLegacy();
471 lda.listPrimaryKeyFieldNames(Legacy.class);
472 verify(knsLegacyDataAdapter).listPrimaryKeyFieldNames(eq(Legacy.class));
473 verifyZeroInteractions(kradLegacyDataAdapter);
474 }
475
476 @Test
477 public void testDetermineCollectionObjectType() throws Exception {
478 lda.determineCollectionObjectType(NonLegacy.class, "blah");
479 verify(kradLegacyDataAdapter).determineCollectionObjectType(eq(NonLegacy.class), eq("blah"));
480 verifyZeroInteractions(knsLegacyDataAdapter);
481 }
482
483 @Test
484 public void testDetermineCollectionObjectType_Legacy() throws Exception {
485 enableLegacy();
486 lda.determineCollectionObjectType(Legacy.class, "blah");
487 verify(knsLegacyDataAdapter).determineCollectionObjectType(eq(Legacy.class), eq("blah"));
488 verifyZeroInteractions(kradLegacyDataAdapter);
489 }
490
491 @Test
492 public void testHasReference() throws Exception {
493 lda.hasReference(NonLegacy.class, "blah");
494 verify(kradLegacyDataAdapter).hasReference(eq(NonLegacy.class), eq("blah"));
495 verifyZeroInteractions(knsLegacyDataAdapter);
496 }
497
498 @Test
499 public void testHasReference_Legacy() throws Exception {
500 enableLegacy();
501 lda.hasReference(Legacy.class, "blah");
502 verify(knsLegacyDataAdapter).hasReference(eq(Legacy.class), eq("blah"));
503 verifyZeroInteractions(kradLegacyDataAdapter);
504 }
505
506 @Test
507 public void testHasCollection() throws Exception {
508 lda.hasCollection(NonLegacy.class, "blah");
509 verify(kradLegacyDataAdapter).hasCollection(eq(NonLegacy.class), eq("blah"));
510 verifyZeroInteractions(knsLegacyDataAdapter);
511 }
512
513 @Test
514 public void testHasCollection_Legacy() throws Exception {
515 enableLegacy();
516 lda.hasCollection(Legacy.class, "blah");
517 verify(knsLegacyDataAdapter).hasCollection(eq(Legacy.class), eq("blah"));
518 verifyZeroInteractions(kradLegacyDataAdapter);
519 }
520
521 @Test
522 public void testIsExtensionAttribute() throws Exception {
523 lda.isExtensionAttribute(NonLegacy.class, "blah", NonLegacy.class);
524 verify(kradLegacyDataAdapter).isExtensionAttribute(eq(NonLegacy.class), eq("blah"), eq(NonLegacy.class));
525 verifyZeroInteractions(knsLegacyDataAdapter);
526 }
527
528 @Test
529 public void testIsExtensionAttribute_Legacy() throws Exception {
530 enableLegacy();
531 lda.isExtensionAttribute(Legacy.class, "blah", Legacy.class);
532 verify(knsLegacyDataAdapter).isExtensionAttribute(eq(Legacy.class), eq("blah"), eq(Legacy.class));
533 verifyZeroInteractions(kradLegacyDataAdapter);
534 }
535
536 @Test
537 public void testGetExtensionAttributeClass() throws Exception {
538 lda.getExtensionAttributeClass(NonLegacy.class, "blah");
539 verify(kradLegacyDataAdapter).getExtensionAttributeClass(eq(NonLegacy.class), eq("blah"));
540 verifyZeroInteractions(knsLegacyDataAdapter);
541 }
542
543 @Test
544 public void testGetExtensionAttributeClass_Legacy() throws Exception {
545 enableLegacy();
546 lda.getExtensionAttributeClass(Legacy.class, "blah");
547 verify(knsLegacyDataAdapter).getExtensionAttributeClass(eq(Legacy.class), eq("blah"));
548 verifyZeroInteractions(kradLegacyDataAdapter);
549 }
550
551 @Test
552 public void testGetPrimaryKeyFieldValuesDOMDS() throws Exception {
553 Object object = newNonLegacyObject();
554 lda.getPrimaryKeyFieldValuesDOMDS(object);
555 verify(kradLegacyDataAdapter).getPrimaryKeyFieldValuesDOMDS(eq(object));
556 verifyZeroInteractions(knsLegacyDataAdapter);
557 }
558
559 @Test
560 public void testGetPrimaryKeyFieldValuesDOMDS_Legacy() throws Exception {
561 enableLegacy();
562 Object object = newLegacyObject();
563 lda.getPrimaryKeyFieldValuesDOMDS(object);
564 verify(knsLegacyDataAdapter).getPrimaryKeyFieldValuesDOMDS(eq(object));
565 verifyZeroInteractions(kradLegacyDataAdapter);
566 }
567
568 @Test
569 public void testEqualsByPrimaryKeys() throws Exception {
570 Object object1 = newNonLegacyObject();
571 Object object2 = newNonLegacyObject();
572 lda.equalsByPrimaryKeys(object1, object2);
573 verify(kradLegacyDataAdapter).equalsByPrimaryKeys(eq(object1), eq(object2));
574 verifyZeroInteractions(knsLegacyDataAdapter);
575 }
576
577 @Test
578 public void testEqualsByPrimaryKeys_Legacy() throws Exception {
579 enableLegacy();
580 Object object1 = newLegacyObject();
581 Object object2 = newLegacyObject();
582 lda.equalsByPrimaryKeys(object1, object2);
583 verify(knsLegacyDataAdapter).equalsByPrimaryKeys(eq(object1), eq(object2));
584 verifyZeroInteractions(kradLegacyDataAdapter);
585 }
586
587 @Test
588 public void testToPersistableBusinessObject() throws Exception {
589 Object object = newNonLegacyObject();
590 lda.toPersistableBusinessObject(object);
591 verify(kradLegacyDataAdapter).toPersistableBusinessObject(eq(object));
592 verifyZeroInteractions(knsLegacyDataAdapter);
593 }
594
595 @Test
596 public void testToPersistableBusinessObject_Legacy() throws Exception {
597 enableLegacy();
598 Object object = newLegacyObject();
599 lda.toPersistableBusinessObject(object);
600 verify(knsLegacyDataAdapter).toPersistableBusinessObject(eq(object));
601 verifyZeroInteractions(kradLegacyDataAdapter);
602 }
603
604 @Test
605 public void testMaterializeAllSubObjects() throws Exception {
606 Object object = newNonLegacyObject();
607 lda.materializeAllSubObjects(object);
608 verify(kradLegacyDataAdapter).materializeAllSubObjects(eq(object));
609 verifyZeroInteractions(knsLegacyDataAdapter);
610 }
611
612 @Test
613 public void testMaterializeAllSubObjects_Legacy() throws Exception {
614 enableLegacy();
615 Object object = newLegacyObject();
616 lda.materializeAllSubObjects(object);
617 verify(knsLegacyDataAdapter).materializeAllSubObjects(eq(object));
618 verifyZeroInteractions(kradLegacyDataAdapter);
619 }
620
621 @Test
622 public void testGetPropertyType() throws Exception {
623 Object object = newNonLegacyObject();
624 lda.getPropertyType(object, "blah");
625 verify(kradLegacyDataAdapter).getPropertyType(eq(object), eq("blah"));
626 verifyZeroInteractions(knsLegacyDataAdapter);
627 }
628
629 @Test
630 public void testGetPropertyType_Legacy() throws Exception {
631 enableLegacy();
632 Object object = newLegacyObject();
633 lda.getPropertyType(object, "blah");
634 verify(knsLegacyDataAdapter).getPropertyType(eq(object), eq("blah"));
635 verifyZeroInteractions(kradLegacyDataAdapter);
636 }
637
638 @Test
639 public void testGetExtension() throws Exception {
640 lda.getExtension(NonLegacyPersistableBusinessObject.class);
641 verify(kradLegacyDataAdapter).getExtension(eq(NonLegacyPersistableBusinessObject.class));
642 verifyZeroInteractions(knsLegacyDataAdapter);
643 }
644
645 @Test
646 public void testGetExtension_Legacy() throws Exception {
647 enableLegacy();
648 lda.getExtension(Legacy.class);
649 verify(knsLegacyDataAdapter).getExtension(eq(Legacy.class));
650 verifyZeroInteractions(kradLegacyDataAdapter);
651 }
652
653 @Test
654 public void testRefreshReferenceObject() throws Exception {
655 PersistableBusinessObject object = newNonLegacyPersistableBusinessObject();
656 lda.refreshReferenceObject(object, "blah");
657 verify(kradLegacyDataAdapter).refreshReferenceObject(eq(object), eq("blah"));
658 verifyZeroInteractions(knsLegacyDataAdapter);
659 }
660
661 @Test
662 public void testRefreshReferenceObject_Legacy() throws Exception {
663 enableLegacy();
664 PersistableBusinessObject object = newLegacyObject();
665 lda.refreshReferenceObject(object, "blah");
666 verify(knsLegacyDataAdapter).refreshReferenceObject(eq(object), eq("blah"));
667 verifyZeroInteractions(kradLegacyDataAdapter);
668 }
669
670 @Test
671 public void testIsLockable() throws Exception {
672 Object object = newNonLegacyObject();
673 lda.isLockable(object);
674 verify(kradLegacyDataAdapter).isLockable(eq(object));
675 verifyZeroInteractions(knsLegacyDataAdapter);
676 }
677
678 @Test
679 public void testIsLockable_Legacy() throws Exception {
680 enableLegacy();
681 Object object = newLegacyObject();
682 lda.isLockable(object);
683 verify(knsLegacyDataAdapter).isLockable(eq(object));
684 verifyZeroInteractions(kradLegacyDataAdapter);
685 }
686
687 @Test
688 public void testVerifyVersionNumber() throws Exception {
689 Object object = newNonLegacyObject();
690 lda.verifyVersionNumber(object);
691 verify(kradLegacyDataAdapter).verifyVersionNumber(eq(object));
692 verifyZeroInteractions(knsLegacyDataAdapter);
693 }
694
695 @Test
696 public void testVerifyVersionNumber_Legacy() throws Exception {
697 enableLegacy();
698 Object object = newLegacyObject();
699 lda.verifyVersionNumber(object);
700 verify(knsLegacyDataAdapter).verifyVersionNumber(eq(object));
701 verifyZeroInteractions(kradLegacyDataAdapter);
702 }
703
704 @Test
705 public void testCreateQuickFinder() throws Exception {
706 lda.createQuickFinder(NonLegacy.class, "blah");
707 verify(kradLegacyDataAdapter).createQuickFinder(eq(NonLegacy.class), eq("blah"));
708 verifyZeroInteractions(knsLegacyDataAdapter);
709 }
710
711 @Test
712 public void testCreateQuickFinder_Legacy() throws Exception {
713 enableLegacy();
714 lda.createQuickFinder(Legacy.class, "blah");
715 verify(knsLegacyDataAdapter).createQuickFinder(eq(Legacy.class), eq("blah"));
716 verifyZeroInteractions(kradLegacyDataAdapter);
717 }
718
719 @Test
720 public void testIsReferenceUpdatable() throws Exception {
721 lda.isReferenceUpdatable(NonLegacy.class, "blah");
722 verify(kradLegacyDataAdapter).isReferenceUpdatable(eq(NonLegacy.class), eq("blah"));
723 verifyZeroInteractions(knsLegacyDataAdapter);
724 }
725
726 @Test
727 public void testIsReferenceUpdatable_Legacy() throws Exception {
728 enableLegacy();
729 lda.isReferenceUpdatable(Legacy.class, "blah");
730 verify(knsLegacyDataAdapter).isReferenceUpdatable(eq(Legacy.class), eq("blah"));
731 verifyZeroInteractions(kradLegacyDataAdapter);
732 }
733
734 @Test
735 public void testListReferenceObjectFields() throws Exception {
736 lda.listReferenceObjectFields(NonLegacy.class);
737 verify(kradLegacyDataAdapter).listReferenceObjectFields(eq(NonLegacy.class));
738 verifyZeroInteractions(knsLegacyDataAdapter);
739 }
740
741 @Test
742 public void testListReferenceObjectFields_Legacy() throws Exception {
743 enableLegacy();
744 lda.listReferenceObjectFields(Legacy.class);
745 verify(knsLegacyDataAdapter).listReferenceObjectFields(eq(Legacy.class));
746 verifyZeroInteractions(kradLegacyDataAdapter);
747 }
748
749 @Test
750 public void testIsCollectionUpdatable() throws Exception {
751 lda.isCollectionUpdatable(NonLegacy.class, "blah");
752 verify(kradLegacyDataAdapter).isCollectionUpdatable(eq(NonLegacy.class), eq("blah"));
753 verifyZeroInteractions(knsLegacyDataAdapter);
754 }
755
756 @Test
757 public void testIsCollectionUpdatable_Legacy() throws Exception {
758 enableLegacy();
759 lda.isCollectionUpdatable(Legacy.class, "blah");
760 verify(knsLegacyDataAdapter).isCollectionUpdatable(eq(Legacy.class), eq("blah"));
761 verifyZeroInteractions(kradLegacyDataAdapter);
762 }
763
764 @Test
765 public void testListCollectionObjectTypes() throws Exception {
766 lda.listCollectionObjectTypes(NonLegacy.class);
767 verify(kradLegacyDataAdapter).listCollectionObjectTypes(eq(NonLegacy.class));
768 verifyZeroInteractions(knsLegacyDataAdapter);
769 }
770
771 @Test
772 public void testListCollectionObjectTypes_Legacy() throws Exception {
773 enableLegacy();
774 lda.listCollectionObjectTypes(Legacy.class);
775 verify(knsLegacyDataAdapter).listCollectionObjectTypes(eq(Legacy.class));
776 verifyZeroInteractions(kradLegacyDataAdapter);
777 }
778
779 @Test
780 public void testGetReferenceIfExists() throws Exception {
781 PersistableBusinessObject object = newNonLegacyPersistableBusinessObject();
782 lda.getReferenceIfExists(object, "blah");
783 verify(kradLegacyDataAdapter).getReferenceIfExists(eq(object), eq("blah"));
784 verifyZeroInteractions(knsLegacyDataAdapter);
785 }
786
787 @Test
788 public void testGetReferenceIfExists_Legacy() throws Exception {
789 enableLegacy();
790 PersistableBusinessObject object = newLegacyObject();
791 lda.getReferenceIfExists(object, "blah");
792 verify(knsLegacyDataAdapter).getReferenceIfExists(eq(object), eq("blah"));
793 verifyZeroInteractions(kradLegacyDataAdapter);
794 }
795
796 @Test
797 public void testAllForeignKeyValuesPopulatedForReference() throws Exception {
798 PersistableBusinessObject object = newNonLegacyPersistableBusinessObject();
799 lda.allForeignKeyValuesPopulatedForReference(object, "blah");
800 verify(kradLegacyDataAdapter).allForeignKeyValuesPopulatedForReference(eq(object), eq("blah"));
801 verifyZeroInteractions(knsLegacyDataAdapter);
802 }
803
804 @Test
805 public void testAllForeignKeyValuesPopulatedForReference_Legacy() throws Exception {
806 enableLegacy();
807 PersistableBusinessObject object = newLegacyObject();
808 lda.allForeignKeyValuesPopulatedForReference(object, "blah");
809 verify(knsLegacyDataAdapter).allForeignKeyValuesPopulatedForReference(eq(object), eq("blah"));
810 verifyZeroInteractions(kradLegacyDataAdapter);
811 }
812
813 @Test
814 public void testGetDictionaryRelationship() throws Exception {
815 lda.getDictionaryRelationship(NonLegacy.class, "blah");
816 verify(kradLegacyDataAdapter).getDictionaryRelationship(eq(NonLegacy.class), eq("blah"));
817 verifyZeroInteractions(knsLegacyDataAdapter);
818 }
819
820 @Test
821 public void testGetDictionaryRelationship_Legacy() throws Exception {
822 enableLegacy();
823 lda.getDictionaryRelationship(Legacy.class, "blah");
824 verify(knsLegacyDataAdapter).getDictionaryRelationship(eq(Legacy.class), eq("blah"));
825 verifyZeroInteractions(kradLegacyDataAdapter);
826 }
827
828 @Test
829 public void testGetTitleAttribute() throws Exception {
830 lda.getTitleAttribute(NonLegacy.class);
831 verify(kradLegacyDataAdapter).getTitleAttribute(eq(NonLegacy.class));
832 verifyZeroInteractions(knsLegacyDataAdapter);
833 }
834
835 @Test
836 public void testGetTitleAttribute_Legacy() throws Exception {
837 enableLegacy();
838 lda.getTitleAttribute(Legacy.class);
839 verify(knsLegacyDataAdapter).getTitleAttribute(eq(Legacy.class));
840 verifyZeroInteractions(kradLegacyDataAdapter);
841 }
842
843 @Test
844 public void testAreNotesSupported() throws Exception {
845 lda.areNotesSupported(NonLegacy.class);
846 verify(kradLegacyDataAdapter).areNotesSupported(eq(NonLegacy.class));
847 verifyZeroInteractions(knsLegacyDataAdapter);
848 }
849
850 @Test
851 public void testAreNotesSupported_Legacy() throws Exception {
852 enableLegacy();
853 lda.areNotesSupported(Legacy.class);
854 verify(knsLegacyDataAdapter).areNotesSupported(eq(Legacy.class));
855 verifyZeroInteractions(kradLegacyDataAdapter);
856 }
857
858 @Test
859 public void testGetDataObjectIdentifierString() throws Exception {
860 Object object = newNonLegacyObject();
861 lda.getDataObjectIdentifierString(object);
862 verify(kradLegacyDataAdapter).getDataObjectIdentifierString(eq(object));
863 verifyZeroInteractions(knsLegacyDataAdapter);
864 }
865
866 @Test
867 public void testGetDataObjectIdentifierString_Legacy() throws Exception {
868 enableLegacy();
869 Object object = newLegacyObject();
870 lda.getDataObjectIdentifierString(object);
871 verify(knsLegacyDataAdapter).getDataObjectIdentifierString(eq(object));
872 verifyZeroInteractions(kradLegacyDataAdapter);
873 }
874
875 @Test
876 public void testGetInquiryObjectClassIfNotTitle() throws Exception {
877 Object object = newNonLegacyObject();
878 lda.getInquiryObjectClassIfNotTitle(object, "blah");
879 verify(kradLegacyDataAdapter).getInquiryObjectClassIfNotTitle(eq(object), eq("blah"));
880 verifyZeroInteractions(knsLegacyDataAdapter);
881 }
882
883 @Test
884 public void testGetInquiryObjectClassIfNotTitle_Legacy() throws Exception {
885 enableLegacy();
886 Object object = newLegacyObject();
887 lda.getInquiryObjectClassIfNotTitle(object, "blah");
888 verify(knsLegacyDataAdapter).getInquiryObjectClassIfNotTitle(eq(object), eq("blah"));
889 verifyZeroInteractions(kradLegacyDataAdapter);
890 }
891
892 @Test
893 public void testGetInquiryParameters() throws Exception {
894 Object object = newNonLegacyObject();
895 lda.getInquiryParameters(object, new ArrayList<String>(), "blah");
896 verify(kradLegacyDataAdapter).getInquiryParameters(eq(object), anyListOf(String.class), eq("blah"));
897 verifyZeroInteractions(knsLegacyDataAdapter);
898 }
899
900 @Test
901 public void testGetInquiryParameters_Legacy() throws Exception {
902 enableLegacy();
903 Object object = newLegacyObject();
904 lda.getInquiryParameters(object, new ArrayList<String>(), "blah");
905 verify(knsLegacyDataAdapter).getInquiryParameters(eq(object), anyListOf(String.class), eq("blah"));
906 verifyZeroInteractions(kradLegacyDataAdapter);
907 }
908
909 @Test
910 public void testHasLocalLookup() throws Exception {
911 lda.hasLocalLookup(NonLegacy.class);
912 verify(kradLegacyDataAdapter).hasLocalLookup(eq(NonLegacy.class));
913 verifyZeroInteractions(knsLegacyDataAdapter);
914 }
915
916 @Test
917 public void testHasLocalLookup_Legacy() throws Exception {
918 enableLegacy();
919 lda.hasLocalLookup(Legacy.class);
920 verify(knsLegacyDataAdapter).hasLocalLookup(eq(Legacy.class));
921 verifyZeroInteractions(kradLegacyDataAdapter);
922 }
923
924 @Test
925 public void testHasLocalInquiry() throws Exception {
926 lda.hasLocalInquiry(NonLegacy.class);
927 verify(kradLegacyDataAdapter).hasLocalInquiry(eq(NonLegacy.class));
928 verifyZeroInteractions(knsLegacyDataAdapter);
929 }
930
931 @Test
932 public void testHasLocalInquiry_Legacy() throws Exception {
933 enableLegacy();
934 lda.hasLocalInquiry(Legacy.class);
935 verify(knsLegacyDataAdapter).hasLocalInquiry(eq(Legacy.class));
936 verifyZeroInteractions(kradLegacyDataAdapter);
937 }
938
939 @Test
940 public void testGetDataObjectRelationship() throws Exception {
941 Object object = newNonLegacyObject();
942 lda.getDataObjectRelationship(object, NonLegacy.class, "blah", "prefix", true, true, true);
943 verify(kradLegacyDataAdapter).getDataObjectRelationship(eq(object), eq(NonLegacy.class), eq("blah"), eq(
944 "prefix"), eq(true), eq(true), eq(true));
945 verifyZeroInteractions(knsLegacyDataAdapter);
946 }
947
948 @Test
949 public void testGetDataObjectRelationship_Legacy() throws Exception {
950 enableLegacy();
951 Object object = newLegacyObject();
952 lda.getDataObjectRelationship(object, Legacy.class, "blah", "prefix", true, true, true);
953 verify(knsLegacyDataAdapter).getDataObjectRelationship(eq(object), eq(Legacy.class), eq("blah"), eq(
954 "prefix"), eq(true), eq(true), eq(true));
955 verifyZeroInteractions(kradLegacyDataAdapter);
956 }
957
958 @Test
959 public void testIsPersistable() throws Exception {
960 lda.isPersistable(NonLegacy.class);
961 verify(kradLegacyDataAdapter).isPersistable(eq(NonLegacy.class));
962 verifyZeroInteractions(knsLegacyDataAdapter);
963 }
964
965 @Test
966 public void testIsPersistable_Legacy() throws Exception {
967 enableLegacy();
968 lda.isPersistable(Legacy.class);
969 verify(knsLegacyDataAdapter).isPersistable(eq(Legacy.class));
970 verifyZeroInteractions(kradLegacyDataAdapter);
971 }
972
973 @Test
974 public void testGetForeignKeyFieldsPopulationState() throws Exception {
975 Object object = newNonLegacyObject();
976 lda.getForeignKeyFieldsPopulationState(object, "blah");
977 verify(kradLegacyDataAdapter).getForeignKeyFieldsPopulationState(eq(object), eq("blah"));
978 verifyZeroInteractions(knsLegacyDataAdapter);
979 }
980
981 @Test
982 public void testGetForeignKeyFieldsPopulationState_Legacy() throws Exception {
983 enableLegacy();
984 Object object = newLegacyObject();
985 lda.getForeignKeyFieldsPopulationState(object, "blah");
986 verify(knsLegacyDataAdapter).getForeignKeyFieldsPopulationState(eq(object), eq("blah"));
987 verifyZeroInteractions(kradLegacyDataAdapter);
988 }
989
990 @Test
991 public void testGetForeignKeysForReference() throws Exception {
992 lda.getForeignKeysForReference(NonLegacy.class, "blah");
993 verify(kradLegacyDataAdapter).getForeignKeysForReference(eq(NonLegacy.class), eq("blah"));
994 verifyZeroInteractions(knsLegacyDataAdapter);
995 }
996
997 @Test
998 public void testGetForeignKeysForReference_Legacy() throws Exception {
999 enableLegacy();
1000 lda.getForeignKeysForReference(Legacy.class, "blah");
1001 verify(knsLegacyDataAdapter).getForeignKeysForReference(eq(Legacy.class), eq("blah"));
1002 verifyZeroInteractions(kradLegacyDataAdapter);
1003 }
1004
1005 @Test
1006 public void testHasPrimaryKeyFieldValues() throws Exception {
1007 Object object = newNonLegacyObject();
1008 lda.hasPrimaryKeyFieldValues(object);
1009 verify(kradLegacyDataAdapter).hasPrimaryKeyFieldValues(eq(object));
1010 verifyZeroInteractions(knsLegacyDataAdapter);
1011 }
1012
1013 @Test
1014 public void testHasPrimaryKeyFieldValues_Legacy() throws Exception {
1015 enableLegacy();
1016 Object object = newLegacyObject();
1017 lda.hasPrimaryKeyFieldValues(object);
1018 verify(knsLegacyDataAdapter).hasPrimaryKeyFieldValues(eq(object));
1019 verifyZeroInteractions(kradLegacyDataAdapter);
1020 }
1021
1022 @Test
1023 public void testSetObjectPropertyDeep() throws Exception {
1024 Object object = newNonLegacyObject();
1025 lda.setObjectPropertyDeep(object, "blahName", NonLegacy.class, "blahValue");
1026 verify(kradLegacyDataAdapter).setObjectPropertyDeep(eq(object), eq("blahName"), eq(NonLegacy.class), eq(
1027 "blahValue"));
1028 verifyZeroInteractions(knsLegacyDataAdapter);
1029 }
1030
1031 @Test
1032 public void testSetObjectPropertyDeep_Legacy() throws Exception {
1033 enableLegacy();
1034 Object object = newLegacyObject();
1035 lda.setObjectPropertyDeep(object, "blahName", Legacy.class, "blahValue");
1036 verify(knsLegacyDataAdapter).setObjectPropertyDeep(eq(object), eq("blahName"), eq(Legacy.class), eq(
1037 "blahValue"));
1038 verifyZeroInteractions(kradLegacyDataAdapter);
1039 }
1040
1041 @Test
1042 public void testMaterializeClassForProxiedObject() throws Exception {
1043 Object object = newNonLegacyObject();
1044 lda.materializeClassForProxiedObject(object);
1045 verify(kradLegacyDataAdapter).materializeClassForProxiedObject(eq(object));
1046 verifyZeroInteractions(knsLegacyDataAdapter);
1047 }
1048
1049 @Test
1050 public void testMaterializeClassForProxiedObject_Legacy() throws Exception {
1051 enableLegacy();
1052 Object object = newLegacyObject();
1053 lda.materializeClassForProxiedObject(object);
1054 verify(knsLegacyDataAdapter).materializeClassForProxiedObject(eq(object));
1055 verifyZeroInteractions(kradLegacyDataAdapter);
1056 }
1057
1058 @Test
1059 public void testGetNestedValue() throws Exception {
1060 Object object = newNonLegacyObject();
1061 lda.getNestedValue(object, "blah");
1062 verify(kradLegacyDataAdapter).getNestedValue(eq(object), eq("blah"));
1063 verifyZeroInteractions(knsLegacyDataAdapter);
1064 }
1065
1066 @Test
1067 public void testGetNestedValue_Legacy() throws Exception {
1068 enableLegacy();
1069 Object object = newLegacyObject();
1070 lda.getNestedValue(object, "blah");
1071 verify(knsLegacyDataAdapter).getNestedValue(eq(object), eq("blah"));
1072 verifyZeroInteractions(kradLegacyDataAdapter);
1073 }
1074
1075 @Test
1076 public void testCreateNewObjectFromClass() throws Exception {
1077 lda.createNewObjectFromClass(NonLegacy.class);
1078 verify(kradLegacyDataAdapter).createNewObjectFromClass(eq(NonLegacy.class));
1079 verifyZeroInteractions(knsLegacyDataAdapter);
1080 }
1081
1082 @Test
1083 public void testCreateNewObjectFromClass_Legacy() throws Exception {
1084 enableLegacy();
1085 lda.createNewObjectFromClass(Legacy.class);
1086 verify(knsLegacyDataAdapter).createNewObjectFromClass(eq(Legacy.class));
1087 verifyZeroInteractions(kradLegacyDataAdapter);
1088 }
1089
1090 @Test
1091 public void testIsNull() throws Exception {
1092 Object object = newNonLegacyObject();
1093 lda.isNull(object);
1094 verify(kradLegacyDataAdapter).isNull(eq(object));
1095 verifyZeroInteractions(knsLegacyDataAdapter);
1096 }
1097
1098 @Test
1099 public void testIsNull_Legacy() throws Exception {
1100 enableLegacy();
1101 Object object = newLegacyObject();
1102 lda.isNull(object);
1103 verify(knsLegacyDataAdapter).isNull(eq(object));
1104 verifyZeroInteractions(kradLegacyDataAdapter);
1105 }
1106
1107 @Test
1108 public void testSetObjectProperty() throws Exception {
1109 Object object = newNonLegacyObject();
1110 lda.setObjectProperty(object, "blahName", NonLegacy.class, "blahValue");
1111 verify(kradLegacyDataAdapter).setObjectProperty(eq(object), eq("blahName"), eq(NonLegacy.class),
1112 eq("blahValue"));
1113 verifyZeroInteractions(knsLegacyDataAdapter);
1114 }
1115
1116 @Test
1117 public void testSetObjectProperty_Legacy() throws Exception {
1118 enableLegacy();
1119 Object object = newLegacyObject();
1120 lda.setObjectProperty(object, "blahName", Legacy.class, "blahValue");
1121 verify(knsLegacyDataAdapter).setObjectProperty(eq(object), eq("blahName"), eq(Legacy.class), eq("blahValue"));
1122 verifyZeroInteractions(kradLegacyDataAdapter);
1123 }
1124
1125
1126 @Test
1127 public void testFindByDocumentHeaderId() throws Exception {
1128 lda.findByDocumentHeaderId(NonLegacyDocument.class, "1234");
1129 verify(kradLegacyDataAdapter).findByDocumentHeaderId(eq(NonLegacyDocument.class), eq("1234"));
1130 verifyZeroInteractions(knsLegacyDataAdapter);
1131 }
1132
1133 @Test
1134 public void testFindByDocumentHeaderId_Legacy() throws Exception {
1135 enableLegacy();
1136 lda.findByDocumentHeaderId(LegacyDocument.class, "1234");
1137 verify(knsLegacyDataAdapter).findByDocumentHeaderId(eq(LegacyDocument.class), eq("1234"));
1138 verifyZeroInteractions(kradLegacyDataAdapter);
1139 }
1140
1141 @Test
1142 public void testFindByDocumentHeaderIds() throws Exception {
1143 lda.findByDocumentHeaderIds(NonLegacyDocument.class, new ArrayList<String>());
1144 verify(kradLegacyDataAdapter).findByDocumentHeaderIds(eq(NonLegacyDocument.class), anyListOf(String.class));
1145 verifyZeroInteractions(knsLegacyDataAdapter);
1146 }
1147
1148 @Test
1149 public void testFindByDocumentHeaderIds_Legacy() throws Exception {
1150 enableLegacy();
1151 lda.findByDocumentHeaderIds(LegacyDocument.class, new ArrayList<String>());
1152 verify(knsLegacyDataAdapter).findByDocumentHeaderIds(eq(LegacyDocument.class), anyListOf(String.class));
1153 verifyZeroInteractions(kradLegacyDataAdapter);
1154 }
1155
1156 @Test
1157 public void testGetKnsLegacyDataAdapter() throws Exception {
1158 assertEquals(knsLegacyDataAdapter, lda.getKnsLegacyDataAdapter());
1159 }
1160
1161 @Test
1162 public void testSetKnsLegacyDataAdapter() throws Exception {
1163 lda.setKnsLegacyDataAdapter(null);
1164 assertNull(lda.getKnsLegacyDataAdapter());
1165 }
1166
1167
1168 @Test
1169 public void testGetKradLegacyDataAdapter() throws Exception {
1170 assertEquals(kradLegacyDataAdapter, lda.getKradLegacyDataAdapter());
1171 }
1172
1173 @Test
1174 public void testSetKradLegacyDataAdapter() throws Exception {
1175 lda.setKradLegacyDataAdapter(null);
1176 assertNull(lda.getKradLegacyDataAdapter());
1177 }
1178
1179 @Test
1180 public void testSelectAdapter() throws Exception {
1181
1182
1183 assertEquals(kradLegacyDataAdapter, lda.selectAdapter(NonLegacy.class));
1184 assertEquals(kradLegacyDataAdapter, lda.selectAdapter(newNonLegacyObject()));
1185 assertEquals(kradLegacyDataAdapter, lda.selectAdapter(Legacy.class));
1186 assertEquals(kradLegacyDataAdapter, lda.selectAdapter(newLegacyObject()));
1187
1188
1189 enableLegacy();
1190
1191
1192 assertEquals(knsLegacyDataAdapter, lda.selectAdapter(Legacy.class));
1193
1194
1195 assertEquals(knsLegacyDataAdapter, lda.selectAdapter(newLegacyObject()));
1196
1197
1198 assertEquals(kradLegacyDataAdapter, lda.selectAdapter(NonLegacy.class));
1199
1200
1201 assertEquals(kradLegacyDataAdapter, lda.selectAdapter(newNonLegacyObject()));
1202
1203 }
1204
1205 public static final class NonLegacy implements Serializable {}
1206 public static final class Legacy extends PersistableBusinessObjectBase {}
1207 public static final class NonLegacyPersistableBusinessObject extends PersistableBusinessObjectBase {}
1208
1209 public static final class NonLegacyDocument extends DocumentBase {}
1210 public static final class LegacyDocument extends DocumentBase {}
1211
1212 }