Program: 66286
Project: 66286
Buggy source:
/** 
 * This test performs minimal sanity testing on the advanced JPA model in order to verify metamodel creation.<p> See the metamodel test package suite for full regression tests. See SVN rev# 5124 http://fisheye2.atlassian.com/changelog/~author=mobrien/eclipselink/?cs=5124
 */
public void testMetamodelMinimalSanityTest(){
  if (!this.isJPA10()) {
    EntityManager em=createEntityManager();
    if (!this.isOnServer()) {
      ((EntityManagerFactoryImpl)((EntityManagerImpl)em).getEntityManagerFactory()).setMetamodel(null);
    }
    Metamodel metamodel=em.getMetamodel();
    EntityType<LargeProject> entityLargeProject=metamodel.entity(LargeProject.class);
    Set<Attribute<LargeProject,?>> declaredAttributes=entityLargeProject.getDeclaredAttributes();
    assertTrue(declaredAttributes.size() > 0);
    Attribute<LargeProject,?> budgetAttribute=entityLargeProject.getDeclaredAttribute("String_Node_Str");
    assertNotNull(budgetAttribute);
    Attribute<LargeProject,?> budgetSingularAttribute=entityLargeProject.getDeclaredSingularAttribute("String_Node_Str");
    assertNotNull(budgetSingularAttribute);
    assertEquals(budgetSingularAttribute,budgetAttribute);
    assertTrue(declaredAttributes.contains(budgetSingularAttribute));
    Class budgetClass=budgetSingularAttribute.getJavaType();
    assertEquals(double.class,budgetClass);
    EntityType<Buyer> entityBuyer=metamodel.entity(Buyer.class);
    assertNotNull(entityBuyer);
    assertEquals(PersistenceType.ENTITY,entityBuyer.getPersistenceType());
    assertEquals(Buyer.class,entityBuyer.getJavaType());
    Attribute buyingDaysAttribute=entityBuyer.getAttribute("String_Node_Str");
    assertNotNull(buyingDaysAttribute);
    assertEquals(PersistentAttributeType.BASIC,buyingDaysAttribute.getPersistentAttributeType());
    assertFalse(((SingularAttributeImpl)buyingDaysAttribute).isPlural());
    BindableType buyingDaysElementBindableType=((SingularAttributeImpl)buyingDaysAttribute).getBindableType();
    assertEquals(BindableType.SINGULAR_ATTRIBUTE,buyingDaysElementBindableType);
    SingularAttribute<? super Buyer,EnumSet> buyingDaysSingularAttribute=entityBuyer.getSingularAttribute("String_Node_Str",EnumSet.class);
    assertNotNull(buyingDaysSingularAttribute);
    assertFalse(buyingDaysSingularAttribute.isCollection());
    boolean expectedIAExceptionThrown=false;
    boolean hasSingleIdAttribute=false;
    try {
      hasSingleIdAttribute=entityBuyer.hasSingleIdAttribute();
    }
 catch (    IllegalArgumentException iae) {
      expectedIAExceptionThrown=true;
    }
    assertFalse(expectedIAExceptionThrown);
    assertTrue(hasSingleIdAttribute);
    Attribute buyerCreditCards=entityBuyer.getAttribute("String_Node_Str");
    assertNotNull(buyerCreditCards);
    assertTrue(buyerCreditCards.isCollection());
    assertTrue(buyerCreditCards instanceof MapAttributeImpl);
    MapAttribute<? super Buyer,?,?> buyerCreditCardsMap=entityBuyer.getMap("String_Node_Str");
    assertNotNull(buyerCreditCardsMap);
    assertEquals(entityBuyer,buyerCreditCardsMap.getDeclaringType());
    assertEquals(String.class,buyerCreditCardsMap.getKeyJavaType());
    assertEquals(Long.class,buyerCreditCardsMap.getElementType().getJavaType());
  }
}

Fixed version (ground truth):
/** 
 * This test performs minimal sanity testing on the advanced JPA model in order to verify metamodel creation.<p> See the metamodel test package suite for full regression tests. See SVN rev# 5124 http://fisheye2.atlassian.com/changelog/~author=mobrien/eclipselink/?cs=5124
 */
public void testMetamodelMinimalSanityTest(){
  EntityManager em=createEntityManager();
  if (!this.isOnServer()) {
    ((EntityManagerFactoryImpl)((EntityManagerImpl)em).getEntityManagerFactory()).setMetamodel(null);
  }
  Metamodel metamodel=em.getMetamodel();
  EntityType<LargeProject> entityLargeProject=metamodel.entity(LargeProject.class);
  Set<Attribute<LargeProject,?>> declaredAttributes=entityLargeProject.getDeclaredAttributes();
  assertTrue(declaredAttributes.size() > 0);
  Attribute<LargeProject,?> budgetAttribute=entityLargeProject.getDeclaredAttribute("String_Node_Str");
  assertNotNull(budgetAttribute);
  Attribute<LargeProject,?> budgetSingularAttribute=entityLargeProject.getDeclaredSingularAttribute("String_Node_Str");
  assertNotNull(budgetSingularAttribute);
  assertEquals(budgetSingularAttribute,budgetAttribute);
  assertTrue(declaredAttributes.contains(budgetSingularAttribute));
  Class budgetClass=budgetSingularAttribute.getJavaType();
  assertEquals(double.class,budgetClass);
  EntityType<Buyer> entityBuyer=metamodel.entity(Buyer.class);
  assertNotNull(entityBuyer);
  assertEquals(PersistenceType.ENTITY,entityBuyer.getPersistenceType());
  assertEquals(Buyer.class,entityBuyer.getJavaType());
  Attribute buyingDaysAttribute=entityBuyer.getAttribute("String_Node_Str");
  assertNotNull(buyingDaysAttribute);
  assertEquals(PersistentAttributeType.BASIC,buyingDaysAttribute.getPersistentAttributeType());
  assertFalse(((SingularAttributeImpl)buyingDaysAttribute).isPlural());
  BindableType buyingDaysElementBindableType=((SingularAttributeImpl)buyingDaysAttribute).getBindableType();
  assertEquals(BindableType.SINGULAR_ATTRIBUTE,buyingDaysElementBindableType);
  SingularAttribute<? super Buyer,EnumSet> buyingDaysSingularAttribute=entityBuyer.getSingularAttribute("String_Node_Str",EnumSet.class);
  assertNotNull(buyingDaysSingularAttribute);
  assertFalse(buyingDaysSingularAttribute.isCollection());
  boolean expectedIAExceptionThrown=false;
  boolean hasSingleIdAttribute=false;
  try {
    hasSingleIdAttribute=entityBuyer.hasSingleIdAttribute();
  }
 catch (  IllegalArgumentException iae) {
    expectedIAExceptionThrown=true;
  }
  assertFalse(expectedIAExceptionThrown);
  assertTrue(hasSingleIdAttribute);
  Attribute buyerCreditCards=entityBuyer.getAttribute("String_Node_Str");
  assertNotNull(buyerCreditCards);
  assertTrue(buyerCreditCards.isCollection());
  assertTrue(buyerCreditCards instanceof MapAttributeImpl);
  MapAttribute<? super Buyer,?,?> buyerCreditCardsMap=entityBuyer.getMap("String_Node_Str");
  assertNotNull(buyerCreditCardsMap);
  assertEquals(entityBuyer,buyerCreditCardsMap.getDeclaringType());
  assertEquals(String.class,buyerCreditCardsMap.getKeyJavaType());
  assertEquals(Long.class,buyerCreditCardsMap.getElementType().getJavaType());
}