View Javadoc
1   /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.data.jpa;
17  
18  import org.junit.Assert;
19  import org.junit.Before;
20  import org.junit.BeforeClass;
21  import org.junit.Test;
22  import org.kuali.rice.krad.data.KradDataServiceLocator;
23  import org.kuali.rice.krad.data.metadata.DataObjectMetadata;
24  import org.kuali.rice.krad.data.provider.MetadataProvider;
25  import org.kuali.rice.krad.data.provider.impl.CompositeMetadataProviderImpl;
26  import org.kuali.rice.krad.test.KRADTestCase;
27  
28  import java.util.List;
29  import java.util.Map;
30  
31  import static org.junit.Assert.assertNotNull;
32  import static org.junit.Assert.assertTrue;
33  
34  /**
35   * Integration test for the JpaMetadataProvider.
36   *
37   * @author Kuali Rice Team (rice.collab@kuali.org)
38   */
39  public class JpaMetadataProviderTest extends KRADTestCase {
40  
41      @Test
42      public void verifyInRegistry() {
43          assertNotNull( "Unable to obtain the registry", KradDataServiceLocator.getProviderRegistry() );
44          List<MetadataProvider> metadataProviders = KradDataServiceLocator.getProviderRegistry().getMetadataProviders();
45          assertNotNull("metadata provider list was null", metadataProviders);
46          assertTrue("There should be at least one metadata provider.", metadataProviders.size() > 1);
47          for (MetadataProvider provider : metadataProviders) {
48              assertTrue("All entries should be the CompositeMetadataProviderImpl: " + provider,
49                  provider instanceof CompositeMetadataProviderImpl);
50          }
51      }
52  
53      @Test
54      public void verifyRetrievalOfMetadata() {
55          assertNotNull( "Unable to obtain the registry", KradDataServiceLocator.getProviderRegistry() );
56          List<MetadataProvider> metadataProviders = KradDataServiceLocator.getProviderRegistry().getMetadataProviders();
57          Map<Class<?>, DataObjectMetadata> provideMetadata = metadataProviders.get(0).provideMetadata();
58          assertNotNull("returned metadata map should not be null", provideMetadata);
59          Assert.assertFalse("returned metadata map should not be empty", provideMetadata.isEmpty());
60      }
61  
62  }