1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
36
37
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 }