@Test
  public void testExtensionAttribute_eclipselink_data() {
    ClassDescriptor classDescriptor = jpaMetadataProvider.getClassDescriptor(TestDataObject.class);
    ClassDescriptor referenceDescriptor =
        jpaMetadataProvider.getClassDescriptor(TestDataObjectExtension.class);
    assertNotNull(
        "A classDescriptor should have been retrieved from JPA for TestDataObject",
        classDescriptor);
    assertNotNull(
        "A classDescriptor should have been retrieved from JPA for TestDataObjectExtension",
        referenceDescriptor);
    DatabaseMapping databaseMapping = classDescriptor.getMappingForAttributeName("extension");
    assertNotNull("extension mapping missing from metamodel", databaseMapping);
    assertTrue("Should be a OneToOne mapping", databaseMapping instanceof OneToOneMapping);
    OneToOneMapping mapping = (OneToOneMapping) databaseMapping;

    assertEquals(
        "Should be mapped by primaryKeyProperty", "primaryKeyProperty", mapping.getMappedBy());
    Map<DatabaseField, DatabaseField> databaseFields = mapping.getSourceToTargetKeyFields();
    assertEquals(1, databaseFields.size());
    for (DatabaseField sourceField : databaseFields.keySet()) {
      DatabaseField targetField = databaseFields.get(sourceField);
      assertEquals("PK_PROP", sourceField.getName());
      assertEquals("PK_PROP", targetField.getName());
    }

    assertNotNull(
        "Reference descriptor missing from relationship", mapping.getReferenceDescriptor());
    assertEquals(
        "Reference descriptor should be the one for TestDataObjectExtension",
        referenceDescriptor,
        mapping.getReferenceDescriptor());

    assertNotNull("selection query relationship missing", mapping.getSelectionQuery());
    assertNotNull("selection query missing name", mapping.getSelectionQuery().getName());
    assertEquals(
        "selection query name incorrect", "extension", mapping.getSelectionQuery().getName());
    assertNotNull(
        "selection query reference class", mapping.getSelectionQuery().getReferenceClass());
    assertEquals(
        "selection query reference class incorrect",
        TestDataObjectExtension.class,
        mapping.getSelectionQuery().getReferenceClass());
    assertNotNull(
        "selection query reference class name",
        mapping.getSelectionQuery().getReferenceClassName());
    assertNotNull(
        "selection query source mapping missing", mapping.getSelectionQuery().getSourceMapping());
    assertEquals(
        "selection query source mapping incorrect",
        mapping,
        mapping.getSelectionQuery().getSourceMapping());
  }
 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
   BasicConfigurator.configure();
   Logger.getLogger(CompositeMetadataProviderImpl.class).setLevel(Level.DEBUG);
   Logger.getLogger(AnnotationMetadataProviderImpl.class).setLevel(Level.DEBUG);
   Logger.getLogger(EclipseLinkJpaMetadataProviderImpl.class).setLevel(Level.DEBUG);
   jpaMetadataProvider = new EclipseLinkJpaMetadataProviderImpl();
   EntityManagerFactory entityManagerFactory =
       Persistence.createEntityManagerFactory("krad-data-unit-test");
   jpaMetadataProvider.setEntityManager(entityManagerFactory.createEntityManager());
 }
 @Test
 public void testConvertersEstabished_autoApply() throws Exception {
   ClassDescriptor classDescriptor = jpaMetadataProvider.getClassDescriptor(TestDataObject.class);
   DatabaseMapping attribute = classDescriptor.getMappingForAttributeName("currencyProperty");
   assertEquals("attribute data type mismatch", DirectToFieldMapping.class, attribute.getClass());
   Converter converter =
       ((org.eclipse.persistence.mappings.DirectToFieldMapping) attribute).getConverter();
   assertNotNull("converter not assigned", converter);
   assertEquals(
       "Mismatch - converter should have been the EclipseLink JPA wrapper class",
       ConverterClass.class,
       converter.getClass());
   Field f = ConverterClass.class.getDeclaredField("attributeConverterClassName");
   f.setAccessible(true);
   String attributeConverterClassName = (String) f.get(converter);
   assertNotNull("attributeConverterClassName missing", attributeConverterClassName);
   assertEquals(
       "Converter class incorrect",
       "org.kuali.rice.krad.data.jpa.converters.KualiDecimalConverter",
       attributeConverterClassName);
 }