Program: 104901
Project: 104901
Buggy source:
@Test public void testDynamicInstantiation() throws Exception {
  Mongo mongo=new Mongo();
  DB db=mongo.getDB("String_Node_Str");
  try {
    DBCollection shapes=db.getCollection("String_Node_Str");
    DBCollection shapeshifters=db.getCollection("String_Node_Str");
    Morphia morphia=new Morphia();
    morphia.map(Circle.class).map(Rectangle.class).map(ShapeShifter.class);
    Shape rectangle=new Rectangle(2,5);
    DBObject rectangleDbObj=morphia.toDBObject(rectangle);
    shapes.save(rectangleDbObj);
    BasicDBObject rectangleDbObjLoaded=(BasicDBObject)shapes.findOne(new BasicDBObject(Mapper.ID_KEY,rectangleDbObj.get(Mapper.ID_KEY)));
    Shape rectangleLoaded=morphia.fromDBObject(Shape.class,rectangleDbObjLoaded);
    assertTrue(rectangle.getArea() == rectangleLoaded.getArea());
    assertTrue(rectangleLoaded instanceof Rectangle);
    ShapeShifter shifter=new ShapeShifter();
    shifter.setReferencedShape(rectangleLoaded);
    shifter.setMainShape(new Circle(2.2));
    shifter.getAvailableShapes().add(new Rectangle(3,3));
    shifter.getAvailableShapes().add(new Circle(4.4));
    DBObject shifterDbObj=morphia.toDBObject(shifter);
    shapeshifters.save(shifterDbObj);
    BasicDBObject shifterDbObjLoaded=(BasicDBObject)shapeshifters.findOne(new BasicDBObject(Mapper.ID_KEY,shifterDbObj.get(Mapper.ID_KEY)));
    ShapeShifter shifterLoaded=morphia.fromDBObject(ShapeShifter.class,shifterDbObjLoaded);
    assertTrue(rectangle.getArea() == shifterLoaded.getReferencedShape().getArea());
    assertTrue(shifterLoaded.getReferencedShape() instanceof Rectangle);
    assertTrue(shifter.getMainShape().getArea() == shifterLoaded.getMainShape().getArea());
    assertEquals(shifter.getAvailableShapes().size(),shifterLoaded.getAvailableShapes().size());
  }
  finally {
    db.dropDatabase();
  }
}

Fixed version (ground truth):
@Test public void testDynamicInstantiation() throws Exception {
  Mongo mongo=new Mongo();
  DB db=mongo.getDB("String_Node_Str");
  try {
    DBCollection shapes=db.getCollection("String_Node_Str");
    DBCollection shapeshifters=db.getCollection("String_Node_Str");
    Morphia morphia=new Morphia();
    morphia.map(Circle.class).map(Rectangle.class).map(ShapeShifter.class);
    Shape rectangle=new Rectangle(2,5);
    DBObject rectangleDbObj=morphia.toDBObject(rectangle);
    shapes.save(rectangleDbObj);
    BasicDBObject rectangleDbObjLoaded=(BasicDBObject)shapes.findOne(new BasicDBObject(Mapper.ID_KEY,rectangleDbObj.get(Mapper.ID_KEY)));
    Shape rectangleLoaded=morphia.fromDBObject(Shape.class,rectangleDbObjLoaded);
    assertTrue(rectangle.getArea() == rectangleLoaded.getArea());
    assertTrue(rectangleLoaded instanceof Rectangle);
    ShapeShifter shifter=new ShapeShifter();
    shifter.setReferencedShape(rectangleLoaded);
    shifter.setMainShape(new Circle(2.2));
    shifter.getAvailableShapes().add(new Rectangle(3,3));
    shifter.getAvailableShapes().add(new Circle(4.4));
    DBObject shifterDbObj=morphia.toDBObject(shifter);
    shapeshifters.save(shifterDbObj);
    BasicDBObject shifterDbObjLoaded=(BasicDBObject)shapeshifters.findOne(new BasicDBObject(Mapper.ID_KEY,shifterDbObj.get(Mapper.ID_KEY)));
    ShapeShifter shifterLoaded=morphia.fromDBObject(ShapeShifter.class,shifterDbObjLoaded);
    assertNotNull(shifterLoaded);
    assertNotNull(shifterLoaded.getReferencedShape());
    assertNotNull(shifterLoaded.getReferencedShape().getArea());
    assertNotNull(rectangle);
    assertNotNull(rectangle.getArea());
    assertTrue(rectangle.getArea() == shifterLoaded.getReferencedShape().getArea());
    assertTrue(shifterLoaded.getReferencedShape() instanceof Rectangle);
    assertTrue(shifter.getMainShape().getArea() == shifterLoaded.getMainShape().getArea());
    assertEquals(shifter.getAvailableShapes().size(),shifterLoaded.getAvailableShapes().size());
  }
  finally {
    db.dropDatabase();
  }
}