View Javadoc
1   package org.kuali.rice.krad.service;
2   
3   import org.junit.Test;
4   import org.kuali.rice.core.api.config.property.ConfigContext;
5   import org.kuali.rice.kns.service.KNSServiceLocator;
6   import org.kuali.rice.krad.util.KRADConstants;
7   
8   import java.util.Collection;
9   import java.util.Map;
10  
11  /**
12   * Exercises LegacyDataAdapter lookup calls using LookupServiceTest test cases
13   */
14  public class LegacyDataAdapterLookupTest extends LookupServiceTest {
15  
16      //    @Override
17      //    protected <T> Collection<T> findCollectionBySearchHelper(Class<T> clazz, Map<String, String> formProps, boolean unbounded) {
18      //        return KRADServiceLocator.getLegacyDataAdapter().findCollectionBySearchHelper(clazz, formProps, unbounded, false, null);
19      //    }
20      //
21      //    @Override
22      //    protected <T> Collection<T> findCollectionBySearchUnbounded(Class<T> clazz, Map<String, String> formProps) {
23      //        return KRADServiceLocator.getLegacyDataAdapter().findCollectionBySearchHelper(clazz, formProps, true, false, null);
24      //    }
25  
26      // superclass test cases ensure LegacyDataAdapter lookups are returning the correct results in legacy mode
27      // (this assumes KNS is loaded in the TestHarness, and therefore legacy is enabled by default)
28  
29      // Additional test cases below explicitly disable legacy data framework, forcing the tests through
30      // the JPA path in LegacyDataAdapter
31  
32      protected void disableLegacyFramework() {
33          ConfigContext.getCurrentContextConfig().putProperty(KRADConstants.Config.ENABLE_LEGACY_DATA_FRAMEWORK, "false");
34      }
35  
36      protected void enableLegacyFramework() {
37          ConfigContext.getCurrentContextConfig().putProperty(KRADConstants.Config.ENABLE_LEGACY_DATA_FRAMEWORK, "true");
38      }
39  
40      @Test
41      public void testJPALookupReturnLimits_Account() throws Exception {
42          disableLegacyFramework();
43          try {
44              testLookupReturnLimits_Account();
45          } finally {
46              enableLegacyFramework();
47          }
48      }
49  
50      @Test
51      public void testJPALookupReturnLimits_TestDataObject() throws Exception {
52          disableLegacyFramework();
53          try {
54              testLookupReturnLimits_TestDataObject();
55          } finally {
56              enableLegacyFramework();
57          }
58      }
59  
60      @Test
61      public void testJPALookupReturnDefaultLimit() throws Exception {
62          disableLegacyFramework();
63          try {
64              testLookupReturnDefaultLimit();
65          } finally {
66              enableLegacyFramework();
67          }
68      }
69  
70      @Test
71      public void testJPALookupReturnDefaultUnbounded_Account() throws Exception {
72          disableLegacyFramework();
73          try {
74              testLookupReturnDefaultUnbounded_Account();
75          } finally {
76              enableLegacyFramework();
77          }
78      }
79  
80      @Test
81      public void testJPALookupReturnDefaultUnbounded_TestDataObject() throws Exception {
82          disableLegacyFramework();
83          try {
84              testLookupReturnDefaultUnbounded_TestDataObject();
85          } finally {
86              enableLegacyFramework();
87          }
88      }
89  
90      @Test
91      @Legacy
92      public void testJPADatabaseRelationshipLookup() throws Exception {
93          KNSServiceLocator.getDataObjectMetaDataService().getDataObjectRelationship(
94                  new org.kuali.rice.krad.test.document.bo.AccountExtension(), org.kuali.rice.krad.test.document.bo.AccountExtension.class,
95                  "accountType", "", true, false, false);
96          KRADServiceLocatorWeb.getLegacyDataAdapter().getDataObjectRelationship(
97                  new org.kuali.rice.krad.test.document.bo.AccountExtension(), org.kuali.rice.krad.test.document.bo.AccountExtension.class,
98                  "accountType", "", true, false, false);
99      }
100 
101 }