nus-yam/ex-repair huggingface dataset:
Program: 25964
Project: 25964
Buggy source:
@Test public void testErrorCalc(){
  final ErrorCalculation calc=new ErrorCalculationESS();
  final double result=ErrorTestingUtil.calculateError(calc,ErrorTestingUtil.ACTUAL,ErrorTestingUtil.IDEAL);
  assertEquals(1516.205,result,0.001);
}

Fixed version (ground truth):
@Test public void testErrorCalc(){
  final ErrorCalculation calc=new ErrorCalculationSSE();
  final double result=ErrorTestingUtil.calculateError(calc,ErrorTestingUtil.ACTUAL,ErrorTestingUtil.IDEAL);
  assertEquals(3032.41,result,0.001);
}
Program: 25965
Project: 25965
Buggy source:
@Test public void testGeneral(){
  final List<BasicData> training=BasicData.convertArrays(TEST_INPUT,TEST_IDEAL);
  final ScoreRegressionData score=new ScoreRegressionData(training);
  final ErrorCalculation ec=new ErrorCalculationMSE();
  score.setErrorCalc(ec);
  assertEquals(ec,score.getErrorCalc());
}

Fixed version (ground truth):
@Test public void testGeneral(){
  final List<BasicData> training=BasicData.convertArrays(TEST_INPUT,TEST_IDEAL);
  final ScoreRegressionData score=new ScoreRegressionData(training);
  final ErrorCalculation ec=new ErrorCalculationSSE();
  score.setErrorCalc(ec);
  assertEquals(ec,score.getErrorCalc());
}
Program: 25966
Project: 25966
Buggy source:
@Test public void testRegression(){
  final double[] ACTUAL={0.0,1.0,0.0,0.0};
  final List<BasicData> training=BasicData.convertArrays(TEST_INPUT,TEST_IDEAL);
  final ScoreRegressionData score=new ScoreRegressionData(training);
  final SimpleAlgo simple=new SimpleAlgo(ACTUAL);
  final double s=score.calculateScore(simple);
  assertEquals(training,score.getTrainingData());
  assertEquals(0.25,s,AIFH.DEFAULT_PRECISION);
}

Fixed version (ground truth):
@Test public void testRegression(){
  final double[] ACTUAL={0.0,1.0,0.0,0.0};
  final List<BasicData> training=BasicData.convertArrays(TEST_INPUT,TEST_IDEAL);
  final ScoreRegressionData score=new ScoreRegressionData(training);
  final SimpleAlgo simple=new SimpleAlgo(ACTUAL);
  final double s=score.calculateScore(simple);
  assertEquals(training,score.getTrainingData());
  assertEquals(1.0,s,AIFH.DEFAULT_PRECISION);
}
Program: 25967
Project: 25967
Buggy source:
@Test public void testTrain(){
  final double[][] x={{1},{3},{2},{200},{230}};
  final double[][] y={{1.0},{1.0},{1.0},{0.0},{0.0}};
  final List<BasicData> trainingData=BasicData.convertArrays(x,y);
  final MultipleLinearRegression regression=new MultipleLinearRegression(1);
  regression.setLinkFunction(new LogitLinkFunction());
  final TrainReweightLeastSquares train=new TrainReweightLeastSquares(regression,trainingData);
  train.iteration();
  train.getError();
  final double[] input={0};
  final double[] output=regression.computeRegression(input);
  assertEquals(0.6630762084733353,output[0],AIFH.DEFAULT_PRECISION);
}

Fixed version (ground truth):
@Test public void testTrain(){
  final double[][] x={{1},{3},{2},{200},{230}};
  final double[][] y={{1.0},{1.0},{1.0},{0.0},{0.0}};
  final List<BasicData> trainingData=BasicData.convertArrays(x,y);
  final MultipleLinearRegression regression=new MultipleLinearRegression(1);
  regression.setLinkFunction(new LogitLinkFunction());
  final TrainReweightLeastSquares train=new TrainReweightLeastSquares(regression,trainingData);
  train.iteration();
  train.getError();
  final double[] input={0};
  final double[] output=regression.computeRegression(input);
  assertEquals(0.8833017302699877,output[0],AIFH.DEFAULT_PRECISION);
}
Program: 25968
Project: 25968
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public String toString(){
  final NumberFormat f=NumberFormat.getNumberInstance();
  f.setMinimumFractionDigits(2);
  final StringBuilder result=new StringBuilder();
  result.append("String_Node_Str");
  result.append(this.getClass().getSimpleName());
  result.append("String_Node_Str");
  result.append(f.format(this.getWidth()));
  result.append("String_Node_Str");
  for (int i=0; i < this.dimensions; i++) {
    if (i > 0) {
      result.append("String_Node_Str");
      result.append(f.format(this.params[this.indexCenters + i]));
    }
  }
  result.append("String_Node_Str");
  return result.toString();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public String toString(){
  final NumberFormat f=NumberFormat.getNumberInstance();
  f.setMinimumFractionDigits(2);
  final StringBuilder result=new StringBuilder();
  result.append("String_Node_Str");
  result.append(this.getClass().getSimpleName());
  result.append("String_Node_Str");
  result.append(f.format(this.getWidth()));
  result.append("String_Node_Str");
  for (int i=0; i < this.dimensions; i++) {
    if (i > 0) {
      result.append("String_Node_Str");
    }
    result.append(f.format(this.params[this.indexCenters + i]));
  }
  result.append("String_Node_Str");
  return result.toString();
}
Program: 25969
Project: 25969
Buggy source:
public void process(){
  try {
    InputStream istream=this.getClass().getResourceAsStream("String_Node_Str");
    DataSet ds=DataSet.load(istream);
    ds.normalizeRange(0,0,1);
    ds.normalizeRange(1,0,1);
    ds.normalizeRange(2,0,1);
    ds.normalizeRange(3,0,1);
    ds.encodeEquilateral(4);
    istream.close();
    List<BasicData> trainingData=ds.extractSupervised(0,4,4,2);
    RBFNetwork network=new RBFNetwork(4,4,2);
    network.reset(new MersenneTwisterGenerateRandom());
    ScoreFunction score=new ScoreRegressionData(trainingData);
    TrainAnneal train=new TrainAnneal(true,network,score);
    performIterations(train,1000000,0.01,true);
    query(network,trainingData);
  }
 catch (  Throwable t) {
    t.printStackTrace();
  }
}

Fixed version (ground truth):
public void process(){
  try {
    InputStream istream=this.getClass().getResourceAsStream("String_Node_Str");
    DataSet ds=DataSet.load(istream);
    ds.normalizeRange(0,0,1);
    ds.normalizeRange(1,0,1);
    ds.normalizeRange(2,0,1);
    ds.normalizeRange(3,0,1);
    ds.encodeEquilateral(4);
    istream.close();
    List<BasicData> trainingData=ds.extractSupervised(0,4,4,2);
    RBFNetwork network=new RBFNetwork(4,4,2);
    network.reset(new MersenneTwisterGenerateRandom());
    ScoreFunction score=new ScoreRegressionData(trainingData);
    TrainAnneal train=new TrainAnneal(network,score);
    performIterations(train,1000000,0.01,true);
    query(network,trainingData);
  }
 catch (  Throwable t) {
    t.printStackTrace();
  }
}
Program: 25970
Project: 25970
Buggy source:
/** 
 * {@inheritDoc}
 */
public boolean equals(Object other){
  if (!(other instanceof DataSet)) {
    return false;
  }
  DataSet otherSet=(DataSet)other;
  if (getHeaderCount() != otherSet.getHeaderCount()) {
    return false;
  }
  if (size() != otherSet.size()) {
    return false;
  }
  for (int i=0; i < getHeaderCount(); i++) {
    if (!this.headers[i].equals(otherSet.getHeaders()[i])) {
      return false;
    }
  }
  for (int i=0; i < size(); i++) {
    Object[] row1=this.data.get(i);
    Object[] row2=((DataSet)other).getData().get(i);
    for (int j=0; j < getHeaderCount(); j++) {
      if (!row1[j].equals(row2[j])) {
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean equals(Object other){
  if (!(other instanceof DataSet)) {
    return false;
  }
  DataSet otherSet=(DataSet)other;
  if (getHeaderCount() != otherSet.getHeaderCount()) {
    return false;
  }
  if (size() != otherSet.size()) {
    return false;
  }
  for (int i=0; i < getHeaderCount(); i++) {
    if (!this.headers[i].equals(otherSet.getHeaders()[i])) {
      return false;
    }
  }
  for (int i=0; i < size(); i++) {
    Object[] row1=this.data.get(i);
    Object[] row2=((DataSet)other).getData().get(i);
    for (int j=0; j < getHeaderCount(); j++) {
      if (!row1[j].equals(row2[j])) {
        return false;
      }
    }
  }
  return true;
}
Program: 25971
Project: 25971
Buggy source:
@Test public void testIterations(){
  TrainAnneal anneal=new TrainAnneal(true,new TrialAlgo(),new TrialScore(),10,400,0.0001);
  anneal.setCycles(10);
  assertEquals(400,anneal.coolingSchedule(),AIFH.DEFAULT_PRECISION);
  assertEquals(400,anneal.getStartingTemperature(),AIFH.DEFAULT_PRECISION);
  assertEquals(0.0001,anneal.getEndingTemperature(),AIFH.DEFAULT_PRECISION);
  assertEquals(10,anneal.getCycles());
  assertEquals(0,anneal.getCurrentTemperature(),AIFH.DEFAULT_PRECISION);
  assertEquals(0,anneal.getK());
  assertEquals(false,anneal.done());
  assertEquals(true,Double.isInfinite(anneal.getLastError()));
  assertEquals(0,anneal.getLastProbability(),AIFH.DEFAULT_PRECISION);
  anneal.iteration();
  assertTrue(anneal.getLastError() > 0);
  assertEquals(87.46896591546223,anneal.getCurrentTemperature(),AIFH.DEFAULT_PRECISION);
  assertEquals(1,anneal.getK());
  assertEquals(false,anneal.done());
  for (int i=0; i < 9; i++) {
    anneal.iteration();
  }
  assertEquals(true,anneal.done());
  assertEquals(9.999999999999E-5,anneal.getCurrentTemperature(),AIFH.DEFAULT_PRECISION);
  assertEquals(10,anneal.getK());
}

Fixed version (ground truth):
@Test public void testIterations(){
  TrainAnneal anneal=new TrainAnneal(new TrialAlgo(),new TrialScore(),10,400,0.0001);
  anneal.setCycles(10);
  assertEquals(400,anneal.coolingSchedule(),AIFH.DEFAULT_PRECISION);
  assertEquals(400,anneal.getStartingTemperature(),AIFH.DEFAULT_PRECISION);
  assertEquals(0.0001,anneal.getEndingTemperature(),AIFH.DEFAULT_PRECISION);
  assertEquals(10,anneal.getCycles());
  assertEquals(0,anneal.getCurrentTemperature(),AIFH.DEFAULT_PRECISION);
  assertEquals(0,anneal.getK());
  assertEquals(false,anneal.done());
  assertEquals(true,Double.isInfinite(anneal.getLastError()));
  assertEquals(0,anneal.getLastProbability(),AIFH.DEFAULT_PRECISION);
  anneal.iteration();
  assertTrue(anneal.getLastError() > 0);
  assertEquals(87.46896591546223,anneal.getCurrentTemperature(),AIFH.DEFAULT_PRECISION);
  assertEquals(1,anneal.getK());
  assertEquals(false,anneal.done());
  for (int i=0; i < 9; i++) {
    anneal.iteration();
  }
  assertEquals(true,anneal.done());
  assertEquals(9.999999999999E-5,anneal.getCurrentTemperature(),AIFH.DEFAULT_PRECISION);
  assertEquals(10,anneal.getK());
}
Program: 25972
Project: 25972
Buggy source:
@Test public void testRandomize(){
  TrialAlgo algo=new TrialAlgo();
  TrainAnneal anneal=new TrainAnneal(true,algo,new TrialScore());
  anneal.performRandomize(algo.getLongTermMemory());
  anneal.finishTraining();
  assertEquals(0,algo.getLongTermMemory()[0],AIFH.DEFAULT_PRECISION);
}

Fixed version (ground truth):
@Test public void testRandomize(){
  TrialAlgo algo=new TrialAlgo();
  TrainAnneal anneal=new TrainAnneal(algo,new TrialScore());
  anneal.performRandomize(algo.getLongTermMemory());
  anneal.finishTraining();
  assertEquals(0,algo.getLongTermMemory()[0],AIFH.DEFAULT_PRECISION);
}
Program: 25973
Project: 25973
Buggy source:
@Test public void testGetStatus(){
  TrainAnneal anneal=new TrainAnneal(true,new TrialAlgo(),new TrialScore());
  assertEquals("String_Node_Str",anneal.getStatus());
}

Fixed version (ground truth):
@Test public void testGetStatus(){
  TrainAnneal anneal=new TrainAnneal(new TrialAlgo(),new TrialScore());
  assertEquals("String_Node_Str",anneal.getStatus());
}
Program: 25974
Project: 25974
Buggy source:
@Test public void testBasic(){
  TrainAnneal anneal=new TrainAnneal(true,new TrialAlgo(),new TrialScore());
  assertEquals(400,anneal.coolingSchedule(),AIFH.DEFAULT_PRECISION);
}

Fixed version (ground truth):
@Test public void testBasic(){
  TrainAnneal anneal=new TrainAnneal(new TrialAlgo(),new TrialScore());
  assertEquals(400,anneal.coolingSchedule(),AIFH.DEFAULT_PRECISION);
}
Program: 25975
Project: 25975
Buggy source:
@Test public void testAnneal(){
  TrainAnneal anneal=new TrainAnneal(true,new TrialAlgo(),new TrialScore());
  performTest(anneal);
}

Fixed version (ground truth):
@Test public void testAnneal(){
  TrainAnneal anneal=new TrainAnneal(new TrialAlgo(),new TrialScore());
  performTest(anneal);
}
Program: 25977
Project: 25977
Buggy source:
/** 
 * TDS converts a number of important data types to String. This isn't what we want, nor helpful. Here, we change them back.
 */
@Override public Object overrideDriverTypeConversion(MetaModel mm,String attributeName,Object value){
  if (value instanceof String && !((String)value).isEmpty()) {
    String typeName=mm.getColumnMetadata().get(attributeName).getTypeName();
    if ("String_Node_Str".equalsIgnoreCase(typeName)) {
      return java.sql.Date.valueOf((String)value);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(typeName)) {
      return java.sql.Timestamp.valueOf((String)value);
    }
  }
  return value;
}

Fixed version (ground truth):
/** 
 * TDS converts a number of important data types to String. This isn't what we want, nor helpful. Here, we change them back.
 */
@Override public Object overrideDriverTypeConversion(MetaModel mm,String attributeName,Object value){
  if (value instanceof String && !Util.blank(value)) {
    String typeName=mm.getColumnMetadata().get(attributeName).getTypeName();
    if ("String_Node_Str".equalsIgnoreCase(typeName)) {
      return java.sql.Date.valueOf((String)value);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(typeName)) {
      return java.sql.Timestamp.valueOf((String)value);
    }
  }
  return value;
}
Program: 25978
Project: 25978
Buggy source:
@Override public Object overrideDriverTypeConversion(MetaModel mm,String attributeName,Object value){
  if (value instanceof String || value instanceof Number) {
    String typeName=mm.getColumnMetadata().get(attributeName).getTypeName();
    if ("String_Node_Str".equalsIgnoreCase(typeName)) {
      return Convert.toSqlDate(value);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(typeName)) {
      return Convert.toTimestamp(value);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(typeName)) {
      return Convert.toTime(value);
    }
  }
  return value;
}

Fixed version (ground truth):
@Override public Object overrideDriverTypeConversion(MetaModel mm,String attributeName,Object value){
  if (value instanceof String && !Util.blank(value) || value instanceof Number) {
    String typeName=mm.getColumnMetadata().get(attributeName).getTypeName();
    if ("String_Node_Str".equalsIgnoreCase(typeName)) {
      return Convert.toSqlDate(value);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(typeName)) {
      return Convert.toTimestamp(value);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(typeName)) {
      return Convert.toTime(value);
    }
  }
  return value;
}
Program: 25979
Project: 25979
Buggy source:
@Before public final void before() throws Exception {
  Base.open(driver(),url(),user(),password());
  Base.connection().setAutoCommit(false);
synchronized (this) {
    if (!schemaGenerated) {
      generateSchema();
      schemaGenerated=true;
      System.out.println("String_Node_Str" + db() + "String_Node_Str"+ driver());
    }
  }
}

Fixed version (ground truth):
@Before public final void before() throws Exception {
  Base.open(driver(),url(),user(),password());
synchronized (this) {
    if (!schemaGenerated) {
      generateSchema();
      schemaGenerated=true;
      System.out.println("String_Node_Str" + db() + "String_Node_Str"+ driver());
    }
  }
  Base.connection().setAutoCommit(false);
}
Program: 25980
Project: 25980
Buggy source:
private void processChildren(OneToManyAssociation association){
  if (delegate.isEmpty()) {
    return;
  }
  final MetaModel childMetaModel=metaModelOf(association.getTargetClass());
  final String fkName=association.getFkName();
  final Map<Object,List<Model>> childrenByParentId=new HashMap<>();
  List<Object> ids=collect(metaModel.getIdName());
  StringBuilder query=new StringBuilder().append(fkName).append("String_Node_Str");
  appendQuestions(query,ids.size());
  query.append(')');
  for (  Model child : new LazyList<>(query.toString(),childMetaModel,ids.toArray()).orderBy(childMetaModel.getIdName())) {
    if (childrenByParentId.get(child.get(fkName)) == null) {
      childrenByParentId.put(child.get(fkName),new SuperLazyList<>());
    }
    childrenByParentId.get(child.get(fkName)).add(child);
  }
  for (  T parent : delegate) {
    List<Model> children=childrenByParentId.get(parent.getId());
    if (children != null) {
      parent.setChildren(childMetaModel.getModelClass(),children);
    }
  }
}

Fixed version (ground truth):
private void processChildren(OneToManyAssociation association){
  if (delegate.isEmpty()) {
    return;
  }
  final MetaModel childMetaModel=metaModelOf(association.getTargetClass());
  final String fkName=association.getFkName();
  final Map<Object,List<Model>> childrenByParentId=new HashMap<>();
  List<Object> ids=collect(metaModel.getIdName());
  StringBuilder query=new StringBuilder().append(fkName).append("String_Node_Str");
  appendQuestions(query,ids.size());
  query.append(')');
  for (  Model child : new LazyList<>(query.toString(),childMetaModel,ids.toArray()).orderBy(childMetaModel.getIdName())) {
    if (childrenByParentId.get(child.get(fkName)) == null) {
      childrenByParentId.put(child.get(fkName),new SuperLazyList<>());
    }
    childrenByParentId.get(child.get(fkName)).add(child);
  }
  for (  T parent : delegate) {
    List<Model> children=childrenByParentId.get(parent.getId());
    if (children != null) {
      parent.setChildren(childMetaModel.getModelClass(),children);
    }
 else {
      parent.setChildren(childMetaModel.getModelClass(),new SuperLazyList<>());
    }
  }
}
Program: 25981
Project: 25981
Buggy source:
private void processManyToMany(Many2ManyAssociation association){
  if (delegate.isEmpty()) {
    return;
  }
  final MetaModel childMetaModel=metaModelOf(association.getTargetClass());
  final Map<Object,List<Model>> childrenByParentId=new HashMap<>();
  List<Object> ids=collect(metaModel.getIdName());
  List<Map> childResults=new DB(childMetaModel.getDbName()).findAll(childMetaModel.getDialect().selectManyToManyAssociation(association,"String_Node_Str",ids.size()),ids.toArray());
  for (  Map res : childResults) {
    Model child=ModelDelegate.instance(res,childMetaModel);
    Object parentId=res.get("String_Node_Str");
    if (childrenByParentId.get(parentId) == null) {
      childrenByParentId.put(parentId,new SuperLazyList<>());
    }
    childrenByParentId.get(parentId).add(child);
  }
  for (  T parent : delegate) {
    List<Model> children=childrenByParentId.get(parent.getId());
    if (children != null) {
      parent.setChildren(childMetaModel.getModelClass(),children);
    }
  }
}

Fixed version (ground truth):
private void processManyToMany(Many2ManyAssociation association){
  if (delegate.isEmpty()) {
    return;
  }
  final MetaModel childMetaModel=metaModelOf(association.getTargetClass());
  final Map<Object,List<Model>> childrenByParentId=new HashMap<>();
  List<Object> ids=collect(metaModel.getIdName());
  List<Map> childResults=new DB(childMetaModel.getDbName()).findAll(childMetaModel.getDialect().selectManyToManyAssociation(association,"String_Node_Str",ids.size()),ids.toArray());
  for (  Map res : childResults) {
    Model child=ModelDelegate.instance(res,childMetaModel);
    Object parentId=res.get("String_Node_Str");
    if (childrenByParentId.get(parentId) == null) {
      childrenByParentId.put(parentId,new SuperLazyList<>());
    }
    childrenByParentId.get(parentId).add(child);
  }
  for (  T parent : delegate) {
    List<Model> children=childrenByParentId.get(parent.getId());
    if (children != null) {
      parent.setChildren(childMetaModel.getModelClass(),children);
    }
 else {
      parent.setChildren(childMetaModel.getModelClass(),new SuperLazyList<>());
    }
  }
}
Program: 25982
Project: 25982
Buggy source:
private void processPolymorphicChildren(OneToManyPolymorphicAssociation association){
  if (delegate.isEmpty()) {
    return;
  }
  MetaModel childMetaModel=metaModelOf(association.getTargetClass());
  Map<Object,List<Model>> childrenByParentId=new HashMap<>();
  List<Object> ids=collect(metaModel.getIdName());
  StringBuilder query=new StringBuilder().append("String_Node_Str");
  appendQuestions(query,ids.size());
  query.append("String_Node_Str").append(association.getTypeLabel()).append('\'');
  for (  Model child : new LazyList<>(query.toString(),childMetaModel,ids.toArray()).orderBy(childMetaModel.getIdName())) {
    if (childrenByParentId.get(child.get("String_Node_Str")) == null) {
      childrenByParentId.put(child.get("String_Node_Str"),new SuperLazyList<>());
    }
    childrenByParentId.get(child.get("String_Node_Str")).add(child);
  }
  for (  T parent : delegate) {
    List<Model> children=childrenByParentId.get(parent.getId());
    if (children != null) {
      parent.setChildren(childMetaModel.getModelClass(),children);
    }
  }
}

Fixed version (ground truth):
private void processPolymorphicChildren(OneToManyPolymorphicAssociation association){
  if (delegate.isEmpty()) {
    return;
  }
  MetaModel childMetaModel=metaModelOf(association.getTargetClass());
  Map<Object,List<Model>> childrenByParentId=new HashMap<>();
  List<Object> ids=collect(metaModel.getIdName());
  StringBuilder query=new StringBuilder().append("String_Node_Str");
  appendQuestions(query,ids.size());
  query.append("String_Node_Str").append(association.getTypeLabel()).append('\'');
  for (  Model child : new LazyList<>(query.toString(),childMetaModel,ids.toArray()).orderBy(childMetaModel.getIdName())) {
    if (childrenByParentId.get(child.get("String_Node_Str")) == null) {
      childrenByParentId.put(child.get("String_Node_Str"),new SuperLazyList<>());
    }
    childrenByParentId.get(child.get("String_Node_Str")).add(child);
  }
  for (  T parent : delegate) {
    List<Model> children=childrenByParentId.get(parent.getId());
    if (children != null) {
      parent.setChildren(childMetaModel.getModelClass(),children);
    }
 else {
      parent.setChildren(childMetaModel.getModelClass(),new SuperLazyList<>());
    }
  }
}
Program: 25983
Project: 25983
Buggy source:
@Test public void shouldDeleteMany2ManyShallow(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Registry.cacheManager().flush(CacheEvent.ALL);
  a(Prescription.count()).shouldBeEqual(5);
  Doctor.findById(3).deleteCascadeShallow();
  a(Doctor.count()).shouldBeEqual(2);
  a(DoctorsPatients.count()).shouldBeEqual(3);
  a(Prescription.count()).shouldBeEqual(5);
}

Fixed version (ground truth):
@Test public void shouldDeleteMany2ManyShallow(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Registry.cacheManager().flush(CacheEvent.ALL);
  a(Prescription.count()).shouldBeEqual(5);
  Doctor.findById(3).deleteCascadeShallow();
  a(Doctor.count()).shouldBeEqual(3);
  a(DoctorsPatients.count()).shouldBeEqual(3);
  a(Prescription.count()).shouldBeEqual(5);
}
Program: 25984
Project: 25984
Buggy source:
@Test public void shouldDeleteMany2ManyDeepSkippingAssociation(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Registry.cacheManager().flush(new CacheEvent("String_Node_Str","String_Node_Str"));
  Registry.cacheManager().flush(new CacheEvent("String_Node_Str","String_Node_Str"));
  Registry.cacheManager().flush(new CacheEvent("String_Node_Str","String_Node_Str"));
  Doctor.findAll().dump();
  Patient.findAll().dump();
  Prescription.findAll().dump();
  a(Doctor.count()).shouldBeEqual(3);
  a(Patient.count()).shouldBeEqual(3);
  a(Prescription.count()).shouldBeEqual(5);
  Patient.findById(3).deleteCascadeExcept(Patient.getMetaModel().getAssociationForTarget(Prescription.class));
  a(Doctor.count()).shouldBeEqual(2);
  a(Patient.count()).shouldBeEqual(2);
  a(Prescription.count()).shouldBeEqual(5);
}

Fixed version (ground truth):
@Test public void shouldDeleteMany2ManyDeepSkippingAssociation(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Registry.cacheManager().flush(new CacheEvent("String_Node_Str","String_Node_Str"));
  Registry.cacheManager().flush(new CacheEvent("String_Node_Str","String_Node_Str"));
  Registry.cacheManager().flush(new CacheEvent("String_Node_Str","String_Node_Str"));
  Doctor.findAll().dump();
  Patient.findAll().dump();
  Prescription.findAll().dump();
  a(Doctor.count()).shouldBeEqual(4);
  a(Patient.count()).shouldBeEqual(3);
  a(Prescription.count()).shouldBeEqual(5);
  Patient.findById(3).deleteCascadeExcept(Patient.getMetaModel().getAssociationForTarget(Prescription.class));
  a(Doctor.count()).shouldBeEqual(3);
  a(Patient.count()).shouldBeEqual(2);
  a(Prescription.count()).shouldBeEqual(5);
}
Program: 25985
Project: 25985
Buggy source:
@Test public void shouldDeleteMany2ManyDeep(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Registry.cacheManager().flush(CacheEvent.ALL);
  a(Prescription.count()).shouldBeEqual(5);
  Doctor.findById(3).deleteCascade();
  a(Doctor.count()).shouldBeEqual(2);
  a(DoctorsPatients.count()).shouldBeEqual(3);
  a(Prescription.count()).shouldBeEqual(4);
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Prescription.findById(1).add(Comment.create("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  Prescription.findById(5).add(Comment.create("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  a(Prescription.count()).shouldBeEqual(5);
  a(Comment.count()).shouldBeEqual(2);
  Doctor.findById(1).deleteCascade();
  a(Doctor.count()).shouldBeEqual(1);
  a(DoctorsPatients.count()).shouldBeEqual(1);
  a(Prescription.count()).shouldBeEqual(1);
  a(Comment.count()).shouldBeEqual(1);
}

Fixed version (ground truth):
@Test public void shouldDeleteMany2ManyDeep(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Registry.cacheManager().flush(CacheEvent.ALL);
  a(Prescription.count()).shouldBeEqual(5);
  Doctor.findById(3).deleteCascade();
  a(Doctor.count()).shouldBeEqual(3);
  a(DoctorsPatients.count()).shouldBeEqual(3);
  a(Prescription.count()).shouldBeEqual(4);
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Prescription.findById(1).add(Comment.create("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  Prescription.findById(5).add(Comment.create("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  a(Prescription.count()).shouldBeEqual(5);
  a(Comment.count()).shouldBeEqual(2);
  Doctor.findById(1).deleteCascade();
  a(Doctor.count()).shouldBeEqual(2);
  a(DoctorsPatients.count()).shouldBeEqual(1);
  a(Prescription.count()).shouldBeEqual(1);
  a(Comment.count()).shouldBeEqual(1);
}
Program: 25986
Project: 25986
Buggy source:
@Test public void shouldDeleteOneToManyDeep(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str");
  a(Address.count()).shouldBeEqual(7);
  a(Room.count()).shouldBeEqual(4);
  User u=User.findById(1);
  u.deleteCascade();
  a(u).shouldBe("String_Node_Str");
  a(User.count()).shouldBeEqual(1);
  a(Address.count()).shouldBeEqual(4);
  a(Address.where("String_Node_Str",1).size()).shouldBeEqual(0);
  a(Room.count()).shouldBeEqual(2);
  a(Room.count("String_Node_Str",1)).shouldBeEqual(0);
}

Fixed version (ground truth):
@Test public void shouldDeleteOneToManyDeep(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str");
  a(Address.count()).shouldBeEqual(7);
  a(Room.count()).shouldBeEqual(4);
  User u=User.findById(1);
  u.deleteCascade();
  a(u).shouldBe("String_Node_Str");
  a(User.count()).shouldBeEqual(2);
  a(Address.count()).shouldBeEqual(4);
  a(Address.where("String_Node_Str",1).size()).shouldBeEqual(0);
  a(Room.count()).shouldBeEqual(2);
  a(Room.count("String_Node_Str",1)).shouldBeEqual(0);
}
Program: 25987
Project: 25987
Buggy source:
@Test public void shouldDeleteOne2ManyShallow(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str");
  a(Address.count()).shouldBeEqual(7);
  a(Room.count()).shouldBeEqual(4);
  User u=User.findById(1);
  u.deleteCascadeShallow();
  a(u).shouldBe("String_Node_Str");
  a(User.count()).shouldBeEqual(1);
  a(Address.count()).shouldBeEqual(4);
  a(Address.where("String_Node_Str",1).size()).shouldBeEqual(0);
  a(Room.count()).shouldBeEqual(4);
  a(Room.count("String_Node_Str",1)).shouldBeEqual(2);
}

Fixed version (ground truth):
@Test public void shouldDeleteOne2ManyShallow(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str");
  a(Address.count()).shouldBeEqual(7);
  a(Room.count()).shouldBeEqual(4);
  User u=User.findById(1);
  u.deleteCascadeShallow();
  a(u).shouldBe("String_Node_Str");
  a(User.count()).shouldBeEqual(2);
  a(Address.count()).shouldBeEqual(4);
  a(Address.where("String_Node_Str",1).size()).shouldBeEqual(0);
  a(Room.count()).shouldBeEqual(4);
  a(Room.count("String_Node_Str",1)).shouldBeEqual(2);
}
Program: 25988
Project: 25988
Buggy source:
@Test public void testDeleteCascade(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str");
  final User u=new User();
  u.set("String_Node_Str","String_Node_Str");
  u.set("String_Node_Str","String_Node_Str");
  u.set("String_Node_Str","String_Node_Str");
  u.saveIt();
  Address a=new Address();
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  u.add(a);
  a=new Address();
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  u.add(a);
  a(User.findAll().size()).shouldBeEqual(3);
  a(Address.findAll().size()).shouldBeEqual(9);
  u.deleteCascade();
  a(User.findAll().size()).shouldBeEqual(2);
  a(Address.findAll().size()).shouldBeEqual(7);
}

Fixed version (ground truth):
@Test public void testDeleteCascade(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str");
  final User u=new User();
  u.set("String_Node_Str","String_Node_Str");
  u.set("String_Node_Str","String_Node_Str");
  u.set("String_Node_Str","String_Node_Str");
  u.saveIt();
  Address a=new Address();
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  u.add(a);
  a=new Address();
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  a.set("String_Node_Str","String_Node_Str");
  u.add(a);
  a(User.findAll().size()).shouldBeEqual(4);
  a(Address.findAll().size()).shouldBeEqual(9);
  u.deleteCascade();
  a(User.findAll().size()).shouldBeEqual(3);
  a(Address.findAll().size()).shouldBeEqual(7);
}
Program: 25989
Project: 25989
Buggy source:
@Test public void shouldFindFOtherDb(){
  List<User> users=User.findAll().orderBy("String_Node_Str");
  List<OtherDbModel> others=OtherDbModel.findAll().orderBy("String_Node_Str");
  the(users.size()).shouldBeEqual(2);
  the(users.get(0).get("String_Node_Str")).shouldBeEqual("String_Node_Str");
  the(users.get(1).get("String_Node_Str")).shouldBeEqual("String_Node_Str");
  the(others.size()).shouldBeEqual(2);
  the(others.get(0).get("String_Node_Str")).shouldBeEqual("String_Node_Str");
  the(others.get(1).get("String_Node_Str")).shouldBeEqual("String_Node_Str");
}

Fixed version (ground truth):
@Test public void shouldFindFOtherDb(){
  List<User> users=User.findAll().orderBy("String_Node_Str");
  List<OtherDbModel> others=OtherDbModel.findAll().orderBy("String_Node_Str");
  the(users.size()).shouldBeEqual(3);
  the(users.get(0).get("String_Node_Str")).shouldBeEqual("String_Node_Str");
  the(users.get(1).get("String_Node_Str")).shouldBeEqual("String_Node_Str");
  the(users.get(2).get("String_Node_Str")).shouldBeEqual("String_Node_Str");
  the(others.size()).shouldBeEqual(2);
  the(others.get(0).get("String_Node_Str")).shouldBeEqual("String_Node_Str");
  the(others.get(1).get("String_Node_Str")).shouldBeEqual("String_Node_Str");
}
Program: 25990
Project: 25990
Buggy source:
@Test public void shouldGenerateFromList(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str");
  LazyList<User> personList=User.findAll().orderBy("String_Node_Str").include(Address.class);
  String xml=personList.toXml(false,true);
  a(XPathHelper.count("String_Node_Str",xml)).shouldEqual(2);
  a(XPathHelper.count("String_Node_Str",xml)).shouldEqual(7);
  a(XPathHelper.count("String_Node_Str",xml)).shouldEqual(7);
}

Fixed version (ground truth):
@Test public void shouldGenerateFromList(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str");
  LazyList<User> personList=User.findAll().orderBy("String_Node_Str").include(Address.class);
  String xml=personList.toXml(false,true);
  a(XPathHelper.count("String_Node_Str",xml)).shouldEqual(3);
  a(XPathHelper.count("String_Node_Str",xml)).shouldEqual(7);
  a(XPathHelper.count("String_Node_Str",xml)).shouldEqual(7);
}
Program: 25998
Project: 25998
Buggy source:
private void processChildren(OneToManyAssociation association){
  if (delegate.isEmpty()) {
    return;
  }
  final MetaModel childMetaModel=metaModelOf(association.getTargetClass());
  final String fkName=association.getFkName();
  final Map<Object,List<Model>> childrenByParentId=new HashMap<>();
  List<Object> ids=collect(metaModel.getIdName());
  StringBuilder query=new StringBuilder().append(fkName).append("String_Node_Str");
  appendQuestions(query,ids.size());
  query.append(')');
  for (  Model child : new LazyList<>(query.toString(),childMetaModel,ids.toArray()).orderBy(childMetaModel.getIdName())) {
    if (childrenByParentId.get(child.get(fkName)) == null) {
      childrenByParentId.put(child.get(fkName),new SuperLazyList<>());
    }
    childrenByParentId.get(child.get(fkName)).add(child);
  }
  for (  T parent : delegate) {
    List<Model> children=childrenByParentId.get(parent.getId());
    if (children != null) {
      parent.setChildren(childMetaModel.getModelClass(),children);
    }
  }
}

Fixed version (ground truth):
private void processChildren(OneToManyAssociation association){
  if (delegate.isEmpty()) {
    return;
  }
  final MetaModel childMetaModel=metaModelOf(association.getTargetClass());
  final String fkName=association.getFkName();
  final Map<Object,List<Model>> childrenByParentId=new HashMap<>();
  List<Object> ids=collect(metaModel.getIdName());
  StringBuilder query=new StringBuilder().append(fkName).append("String_Node_Str");
  appendQuestions(query,ids.size());
  query.append(')');
  for (  Model child : new LazyList<>(query.toString(),childMetaModel,ids.toArray()).orderBy(childMetaModel.getIdName())) {
    if (childrenByParentId.get(child.get(fkName)) == null) {
      childrenByParentId.put(child.get(fkName),new SuperLazyList<>());
    }
    childrenByParentId.get(child.get(fkName)).add(child);
  }
  for (  T parent : delegate) {
    List<Model> children=childrenByParentId.get(parent.getId());
    if (children != null) {
      parent.setChildren(childMetaModel.getModelClass(),children);
    }
 else {
      parent.setChildren(childMetaModel.getModelClass(),new SuperLazyList<>());
    }
  }
}
Program: 25999
Project: 25999
Buggy source:
private void processManyToMany(Many2ManyAssociation association){
  if (delegate.isEmpty()) {
    return;
  }
  final MetaModel childMetaModel=metaModelOf(association.getTargetClass());
  final Map<Object,List<Model>> childrenByParentId=new HashMap<>();
  List<Object> ids=collect(metaModel.getIdName());
  List<Map> childResults=new DB(childMetaModel.getDbName()).findAll(childMetaModel.getDialect().selectManyToManyAssociation(association,"String_Node_Str",ids.size()),ids.toArray());
  for (  Map res : childResults) {
    Model child=ModelDelegate.instance(res,childMetaModel);
    Object parentId=res.get("String_Node_Str");
    if (childrenByParentId.get(parentId) == null) {
      childrenByParentId.put(parentId,new SuperLazyList<>());
    }
    childrenByParentId.get(parentId).add(child);
  }
  for (  T parent : delegate) {
    List<Model> children=childrenByParentId.get(parent.getId());
    if (children != null) {
      parent.setChildren(childMetaModel.getModelClass(),children);
    }
  }
}

Fixed version (ground truth):
private void processManyToMany(Many2ManyAssociation association){
  if (delegate.isEmpty()) {
    return;
  }
  final MetaModel childMetaModel=metaModelOf(association.getTargetClass());
  final Map<Object,List<Model>> childrenByParentId=new HashMap<>();
  List<Object> ids=collect(metaModel.getIdName());
  List<Map> childResults=new DB(childMetaModel.getDbName()).findAll(childMetaModel.getDialect().selectManyToManyAssociation(association,"String_Node_Str",ids.size()),ids.toArray());
  for (  Map res : childResults) {
    Model child=ModelDelegate.instance(res,childMetaModel);
    Object parentId=res.get("String_Node_Str");
    if (childrenByParentId.get(parentId) == null) {
      childrenByParentId.put(parentId,new SuperLazyList<>());
    }
    childrenByParentId.get(parentId).add(child);
  }
  for (  T parent : delegate) {
    List<Model> children=childrenByParentId.get(parent.getId());
    if (children != null) {
      parent.setChildren(childMetaModel.getModelClass(),children);
    }
 else {
      parent.setChildren(childMetaModel.getModelClass(),new SuperLazyList<>());
    }
  }
}
Program: 26000
Project: 26000
Buggy source:
private void processPolymorphicChildren(OneToManyPolymorphicAssociation association){
  if (delegate.isEmpty()) {
    return;
  }
  MetaModel childMetaModel=metaModelOf(association.getTargetClass());
  Map<Object,List<Model>> childrenByParentId=new HashMap<>();
  List<Object> ids=collect(metaModel.getIdName());
  StringBuilder query=new StringBuilder().append("String_Node_Str");
  appendQuestions(query,ids.size());
  query.append("String_Node_Str").append(association.getTypeLabel()).append('\'');
  for (  Model child : new LazyList<>(query.toString(),childMetaModel,ids.toArray()).orderBy(childMetaModel.getIdName())) {
    if (childrenByParentId.get(child.get("String_Node_Str")) == null) {
      childrenByParentId.put(child.get("String_Node_Str"),new SuperLazyList<>());
    }
    childrenByParentId.get(child.get("String_Node_Str")).add(child);
  }
  for (  T parent : delegate) {
    List<Model> children=childrenByParentId.get(parent.getId());
    if (children != null) {
      parent.setChildren(childMetaModel.getModelClass(),children);
    }
  }
}

Fixed version (ground truth):
private void processPolymorphicChildren(OneToManyPolymorphicAssociation association){
  if (delegate.isEmpty()) {
    return;
  }
  MetaModel childMetaModel=metaModelOf(association.getTargetClass());
  Map<Object,List<Model>> childrenByParentId=new HashMap<>();
  List<Object> ids=collect(metaModel.getIdName());
  StringBuilder query=new StringBuilder().append("String_Node_Str");
  appendQuestions(query,ids.size());
  query.append("String_Node_Str").append(association.getTypeLabel()).append('\'');
  for (  Model child : new LazyList<>(query.toString(),childMetaModel,ids.toArray()).orderBy(childMetaModel.getIdName())) {
    if (childrenByParentId.get(child.get("String_Node_Str")) == null) {
      childrenByParentId.put(child.get("String_Node_Str"),new SuperLazyList<>());
    }
    childrenByParentId.get(child.get("String_Node_Str")).add(child);
  }
  for (  T parent : delegate) {
    List<Model> children=childrenByParentId.get(parent.getId());
    if (children != null) {
      parent.setChildren(childMetaModel.getModelClass(),children);
    }
 else {
      parent.setChildren(childMetaModel.getModelClass(),new SuperLazyList<>());
    }
  }
}
Program: 26001
Project: 26001
Buggy source:
@Test public void shouldDeleteMany2ManyShallow(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Registry.cacheManager().flush(CacheEvent.ALL);
  a(Prescription.count()).shouldBeEqual(5);
  Doctor.findById(3).deleteCascadeShallow();
  a(Doctor.count()).shouldBeEqual(2);
  a(DoctorsPatients.count()).shouldBeEqual(3);
  a(Prescription.count()).shouldBeEqual(5);
}

Fixed version (ground truth):
@Test public void shouldDeleteMany2ManyShallow(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Registry.cacheManager().flush(CacheEvent.ALL);
  a(Prescription.count()).shouldBeEqual(5);
  Doctor.findById(3).deleteCascadeShallow();
  a(Doctor.count()).shouldBeEqual(3);
  a(DoctorsPatients.count()).shouldBeEqual(3);
  a(Prescription.count()).shouldBeEqual(5);
}
Program: 26002
Project: 26002
Buggy source:
@Test public void shouldDeleteMany2ManyDeepSkippingAssociation(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Registry.cacheManager().flush(new CacheEvent("String_Node_Str","String_Node_Str"));
  Registry.cacheManager().flush(new CacheEvent("String_Node_Str","String_Node_Str"));
  Registry.cacheManager().flush(new CacheEvent("String_Node_Str","String_Node_Str"));
  Doctor.findAll().dump();
  Patient.findAll().dump();
  Prescription.findAll().dump();
  a(Doctor.count()).shouldBeEqual(3);
  a(Patient.count()).shouldBeEqual(3);
  a(Prescription.count()).shouldBeEqual(5);
  Patient.findById(3).deleteCascadeExcept(Patient.getMetaModel().getAssociationForTarget(Prescription.class));
  a(Doctor.count()).shouldBeEqual(2);
  a(Patient.count()).shouldBeEqual(2);
  a(Prescription.count()).shouldBeEqual(5);
}

Fixed version (ground truth):
@Test public void shouldDeleteMany2ManyDeepSkippingAssociation(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Registry.cacheManager().flush(new CacheEvent("String_Node_Str","String_Node_Str"));
  Registry.cacheManager().flush(new CacheEvent("String_Node_Str","String_Node_Str"));
  Registry.cacheManager().flush(new CacheEvent("String_Node_Str","String_Node_Str"));
  Doctor.findAll().dump();
  Patient.findAll().dump();
  Prescription.findAll().dump();
  a(Doctor.count()).shouldBeEqual(4);
  a(Patient.count()).shouldBeEqual(3);
  a(Prescription.count()).shouldBeEqual(5);
  Patient.findById(3).deleteCascadeExcept(Patient.getMetaModel().getAssociationForTarget(Prescription.class));
  a(Doctor.count()).shouldBeEqual(3);
  a(Patient.count()).shouldBeEqual(2);
  a(Prescription.count()).shouldBeEqual(5);
}
Program: 26003
Project: 26003
Buggy source:
@Test public void shouldDeleteMany2ManyDeep(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Registry.cacheManager().flush(CacheEvent.ALL);
  a(Prescription.count()).shouldBeEqual(5);
  Doctor.findById(3).deleteCascade();
  a(Doctor.count()).shouldBeEqual(2);
  a(DoctorsPatients.count()).shouldBeEqual(3);
  a(Prescription.count()).shouldBeEqual(4);
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Prescription.findById(1).add(Comment.create("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  Prescription.findById(5).add(Comment.create("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  a(Prescription.count()).shouldBeEqual(5);
  a(Comment.count()).shouldBeEqual(2);
  Doctor.findById(1).deleteCascade();
  a(Doctor.count()).shouldBeEqual(1);
  a(DoctorsPatients.count()).shouldBeEqual(1);
  a(Prescription.count()).shouldBeEqual(1);
  a(Comment.count()).shouldBeEqual(1);
}

Fixed version (ground truth):
@Test public void shouldDeleteMany2ManyDeep(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Registry.cacheManager().flush(CacheEvent.ALL);
  a(Prescription.count()).shouldBeEqual(5);
  Doctor.findById(3).deleteCascade();
  a(Doctor.count()).shouldBeEqual(3);
  a(DoctorsPatients.count()).shouldBeEqual(3);
  a(Prescription.count()).shouldBeEqual(4);
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Prescription.findById(1).add(Comment.create("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  Prescription.findById(5).add(Comment.create("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  a(Prescription.count()).shouldBeEqual(5);
  a(Comment.count()).shouldBeEqual(2);
  Doctor.findById(1).deleteCascade();
  a(Doctor.count()).shouldBeEqual(2);
  a(DoctorsPatients.count()).shouldBeEqual(1);
  a(Prescription.count()).shouldBeEqual(1);
  a(Comment.count()).shouldBeEqual(1);
}
Program: 26004
Project: 26004
Buggy source:
@Test public void shouldDeleteOneToManyDeep(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str");
  a(Address.count()).shouldBeEqual(7);
  a(Room.count()).shouldBeEqual(4);
  User u=User.findById(1);
  u.deleteCascade();
  a(u).shouldBe("String_Node_Str");
  a(User.count()).shouldBeEqual(1);
  a(Address.count()).shouldBeEqual(4);
  a(Address.where("String_Node_Str",1).size()).shouldBeEqual(0);
  a(Room.count()).shouldBeEqual(2);
  a(Room.count("String_Node_Str",1)).shouldBeEqual(0);
}

Fixed version (ground truth):
@Test public void shouldDeleteOneToManyDeep(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str");
  a(Address.count()).shouldBeEqual(7);
  a(Room.count()).shouldBeEqual(4);
  User u=User.findById(1);
  u.deleteCascade();
  a(u).shouldBe("String_Node_Str");
  a(User.count()).shouldBeEqual(2);
  a(Address.count()).shouldBeEqual(4);
  a(Address.where("String_Node_Str",1).size()).shouldBeEqual(0);
  a(Room.count()).shouldBeEqual(2);
  a(Room.count("String_Node_Str",1)).shouldBeEqual(0);
}
Program: 26005
Project: 26005
Buggy source:
@Test public void shouldDeleteOne2ManyShallow(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str");
  a(Address.count()).shouldBeEqual(7);
  a(Room.count()).shouldBeEqual(4);
  User u=User.findById(1);
  u.deleteCascadeShallow();
  a(u).shouldBe("String_Node_Str");
  a(User.count()).shouldBeEqual(1);
  a(Address.count()).shouldBeEqual(4);
  a(Address.where("String_Node_Str",1).size()).shouldBeEqual(0);
  a(Room.count()).shouldBeEqual(4);
  a(Room.count("String_Node_Str",1)).shouldBeEqual(2);
}

Fixed version (ground truth):
@Test public void shouldDeleteOne2ManyShallow(){
  deleteAndPopulateTables("String_Node_Str","String_Node_Str","String_Node_Str");
  a(Address.count()).shouldBeEqual(7);
  a(Room.count()).shouldBeEqual(4);
  User u=User.findById(1);
  u.deleteCascadeShallow();
  a(u).shouldBe("String_Node_Str");
  a(User.count()).shouldBeEqual(2);
  a(Address.count()).shouldBeEqual(4);
  a(Address.where("String_Node_Str",1).size()).shouldBeEqual(0);
  a(Room.count()).shouldBeEqual(4);
  a(Room.count("String_Node_Str",1)).shouldBeEqual(2);
}