nus-yam/ex-repair huggingface dataset:
Program: 117217
Project: 117217
Buggy source:
@Override public void read(BufferedReader in) throws Exception {
  int k=Integer.parseInt(in.readLine().split("String_Node_Str")[1]);
  trees=new BoostedRegressionTrees[k];
  for (int i=0; i < trees.length; i++) {
    trees[i]=new BoostedRegressionTrees();
    int n=Integer.parseInt(in.readLine().split("String_Node_Str")[1]);
    for (int j=0; j < n; i++) {
      RegressionTree rt=new RegressionTree();
      rt.read(in);
      trees[i].add(rt);
      in.readLine();
    }
  }
}

Fixed version (ground truth):
@Override public void read(BufferedReader in) throws Exception {
  int k=Integer.parseInt(in.readLine().split("String_Node_Str")[1]);
  trees=new BoostedRegressionTrees[k];
  for (int i=0; i < trees.length; i++) {
    int n=Integer.parseInt(in.readLine().split("String_Node_Str")[1]);
    trees[i]=new BoostedRegressionTrees();
    for (int j=0; j < n; j++) {
      in.readLine();
      RegressionTree rt=new RegressionTree();
      rt.read(in);
      trees[i].add(rt);
      in.readLine();
    }
    in.readLine();
  }
}
Program: 117218
Project: 117218
Buggy source:
@Override public void write(PrintWriter out) throws Exception {
  out.printf("String_Node_Str",this.getClass().getCanonicalName());
  out.println("String_Node_Str" + trees.length);
  for (  BoostedRegressionTrees rtList : trees) {
    out.println("String_Node_Str" + rtList.size());
    for (    RegressionTree rt : rtList) {
      rt.write(out);
    }
    out.println();
  }
}

Fixed version (ground truth):
@Override public void write(PrintWriter out) throws Exception {
  out.printf("String_Node_Str",this.getClass().getCanonicalName());
  out.println("String_Node_Str" + trees.length);
  for (  BoostedRegressionTrees rtList : trees) {
    out.println("String_Node_Str" + rtList.size());
    for (    RegressionTree rt : rtList) {
      rt.write(out);
      out.println();
    }
    out.println();
  }
}
Program: 117219
Project: 117219
Buggy source:
protected void getHistogram(Instances instances,List<IntDoublePair> pairs,List<Double> uniqueValues,double w,double s,List<DoublePair> histogram){
  if (pairs.size() == 0) {
    return;
  }
  double lastValue=pairs.get(0).v2;
  double totalWeight=instances.get(pairs.get(0).v1).getWeight();
  double sum=instances.get(pairs.get(0).v1).getTarget() * totalWeight;
  for (int i=1; i < pairs.size(); i++) {
    IntDoublePair pair=pairs.get(i);
    double value=pair.v2;
    double weight=instances.get(pairs.get(i).v1).getWeight();
    double resp=instances.get(pairs.get(i).v1).getTarget();
    if (value != lastValue) {
      uniqueValues.add(lastValue);
      histogram.add(new DoublePair(totalWeight,sum));
      lastValue=value;
      totalWeight=weight;
      sum=resp * weight;
    }
 else {
      totalWeight+=weight;
      sum+=resp * weight;
    }
  }
  uniqueValues.add(lastValue);
  histogram.add(new DoublePair(totalWeight,sum));
  if (pairs.size() != instances.size()) {
    double sumWeight=0;
    double sumTarget=0;
    for (    DoublePair pair : histogram) {
      sumWeight+=pair.v1;
      sumTarget+=pair.v2;
    }
    double weightOnZero=w - sumWeight;
    double sumOnZero=s - sumTarget;
    int idx=Collections.binarySearch(uniqueValues,ZERO);
    if (idx < 0) {
      uniqueValues.add(-idx - 1,ZERO);
      histogram.add(-idx - 1,new DoublePair(weightOnZero,sumOnZero));
    }
  }
}

Fixed version (ground truth):
protected void getHistogram(Instances instances,List<IntDoublePair> pairs,List<Double> uniqueValues,double w,double s,List<DoublePair> histogram){
  if (pairs.size() > 0) {
    double lastValue=pairs.get(0).v2;
    double totalWeight=instances.get(pairs.get(0).v1).getWeight();
    double sum=instances.get(pairs.get(0).v1).getTarget() * totalWeight;
    for (int i=1; i < pairs.size(); i++) {
      IntDoublePair pair=pairs.get(i);
      double value=pair.v2;
      double weight=instances.get(pairs.get(i).v1).getWeight();
      double resp=instances.get(pairs.get(i).v1).getTarget();
      if (value != lastValue) {
        uniqueValues.add(lastValue);
        histogram.add(new DoublePair(totalWeight,sum));
        lastValue=value;
        totalWeight=weight;
        sum=resp * weight;
      }
 else {
        totalWeight+=weight;
        sum+=resp * weight;
      }
    }
    uniqueValues.add(lastValue);
    histogram.add(new DoublePair(totalWeight,sum));
  }
  if (pairs.size() != instances.size()) {
    double sumWeight=0;
    double sumTarget=0;
    for (    DoublePair pair : histogram) {
      sumWeight+=pair.v1;
      sumTarget+=pair.v2;
    }
    double weightOnZero=w - sumWeight;
    double sumOnZero=s - sumTarget;
    int idx=Collections.binarySearch(uniqueValues,ZERO);
    if (idx < 0) {
      uniqueValues.add(-idx - 1,ZERO);
      histogram.add(-idx - 1,new DoublePair(weightOnZero,sumOnZero));
    }
  }
}
Program: 117221
Project: 117221
Buggy source:
static GAM getGAM(GLM glm,List<Attribute> attList){
  double[] w=glm.coefficients(0);
  GAM gam=new GAM();
  int k=0;
  for (  Attribute attribute : attList) {
    int attIndex=attribute.getIndex();
    int[] term=new int[]{attIndex};
    if (attribute instanceof NumericalAttribute) {
      LinearFunction func=new LinearFunction(attIndex,-w[k++]);
      gam.add(term,func);
    }
 else     if (attribute instanceof BinnedAttribute) {
      BinnedAttribute binnedAttribute=(BinnedAttribute)attribute;
      int size=binnedAttribute.getNumBins();
      double[] predictions=new double[size];
      for (int j=0; j < predictions.length; j++) {
        predictions[j]=-w[k++];
      }
      Array1D ary=new Array1D(attIndex,predictions);
      gam.add(term,ary);
    }
 else     if (attribute instanceof NominalAttribute) {
      NominalAttribute nominalAttribute=(NominalAttribute)attribute;
      int size=nominalAttribute.getCardinality();
      double[] predictions=new double[size];
      for (int j=0; j < predictions.length; j++) {
        predictions[j]=-w[k++];
      }
      Array1D ary=new Array1D(attIndex,predictions);
      gam.add(term,ary);
    }
  }
  gam.setIntercept(-glm.intercept(0));
  return gam;
}

Fixed version (ground truth):
static GAM getGAM(GLM glm,List<Attribute> attList){
  double[] w=glm.coefficients(0);
  GAM gam=new GAM();
  int k=0;
  for (  Attribute attribute : attList) {
    int attIndex=attribute.getIndex();
    int[] term=new int[]{attIndex};
    if (attribute instanceof NumericalAttribute) {
      LinearFunction func=new LinearFunction(attIndex,-w[k++]);
      gam.add(term,func);
    }
 else     if (attribute instanceof BinnedAttribute) {
      BinnedAttribute binnedAttribute=(BinnedAttribute)attribute;
      int size=binnedAttribute.getNumBins();
      double[] predictions=new double[size];
      for (int j=0; j < predictions.length && k < w.length; j++) {
        predictions[j]=-w[k++];
      }
      Array1D ary=new Array1D(attIndex,predictions);
      gam.add(term,ary);
    }
 else     if (attribute instanceof NominalAttribute) {
      NominalAttribute nominalAttribute=(NominalAttribute)attribute;
      int size=nominalAttribute.getCardinality();
      double[] predictions=new double[size];
      for (int j=0; j < predictions.length && k < w.length; j++) {
        predictions[j]=-w[k++];
      }
      Array1D ary=new Array1D(attIndex,predictions);
      gam.add(term,ary);
    }
  }
  gam.setIntercept(-glm.intercept(0));
  return gam;
}
Program: 117222
Project: 117222
Buggy source:
/** 
 * <p> <pre> Usage: SPLAMLearner -t	train set path [-r]	attribute file path [-o]	output model path [-g]	task between classification (c) and regression (r) (default: r) [-d]	number of knots (default: 10) [-m]	maximum number of iterations (default: 0) [-l]	lambda (default: 0) [-a]	alpha (default: 1, i.e., SPAM model) </pre> </p>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(SPLAMLearner.class,opts);
  Task task=null;
  try {
    parser.parse(args);
    task=Task.getEnum(opts.task);
    if (opts.numKnots < 0) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances trainSet=InstancesReader.read(opts.attPath,opts.trainPath);
  SPLAMLearner splamLearner=new SPLAMLearner();
  splamLearner.setNumKnots(opts.numKnots);
  splamLearner.setMaxNumIters(opts.maxNumIters);
  splamLearner.setLambda(opts.lambda);
  splamLearner.setAlpha(opts.alpha);
  splamLearner.setTask(task);
  splamLearner.setVerbose(true);
  long start=System.currentTimeMillis();
  GAM gam=splamLearner.build(trainSet);
  long end=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (end - start) / 1000.0);
  if (opts.outputModelPath != null) {
    PredictorWriter.write(gam,opts.outputModelPath);
  }
}

Fixed version (ground truth):
/** 
 * <p> <pre> Usage: SPLAMLearner -t	train set path [-r]	attribute file path [-o]	output model path [-g]	task between classification (c) and regression (r) (default: r) [-d]	number of knots (default: 10) [-m]	maximum number of iterations (default: 0) [-l]	lambda (default: 0) [-a]	alpha (default: 0, i.e., SPAM model) </pre> </p>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(SPLAMLearner.class,opts);
  Task task=null;
  try {
    parser.parse(args);
    task=Task.getEnum(opts.task);
    if (opts.numKnots < 0) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances trainSet=InstancesReader.read(opts.attPath,opts.trainPath);
  SPLAMLearner splamLearner=new SPLAMLearner();
  splamLearner.setNumKnots(opts.numKnots);
  splamLearner.setMaxNumIters(opts.maxNumIters);
  splamLearner.setLambda(opts.lambda);
  splamLearner.setAlpha(opts.alpha);
  splamLearner.setTask(task);
  splamLearner.setVerbose(true);
  long start=System.currentTimeMillis();
  GAM gam=splamLearner.build(trainSet);
  long end=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (end - start) / 1000.0);
  if (opts.outputModelPath != null) {
    PredictorWriter.write(gam,opts.outputModelPath);
  }
}
Program: 117223
Project: 117223
Buggy source:
/** 
 * Constructor.
 */
public SPLAMLearner(){
  verbose=false;
  fitIntercept=true;
  refit=false;
  numKnots=10;
  maxNumIters=-1;
  lambda=0.0;
  alpha=1;
  epsilon=MathUtils.EPSILON;
  task=Task.REGRESSION;
}

Fixed version (ground truth):
/** 
 * Constructor.
 */
public SPLAMLearner(){
  verbose=false;
  fitIntercept=true;
  refit=false;
  numKnots=10;
  maxNumIters=-1;
  lambda=0.0;
  alpha=0;
  epsilon=MathUtils.EPSILON;
  task=Task.REGRESSION;
}
Program: 117225
Project: 117225
Buggy source:
@Override public void read(BufferedReader in) throws Exception {
  int bn=Integer.parseInt(in.readLine().split("String_Node_Str")[1]);
  groves=new ArrayList<>();
  for (int i=0; i < bn; i++) {
    int tn=Integer.parseInt(in.readLine().split("String_Node_Str")[1]);
    RegressionTree[] grove=new RegressionTree[tn];
    for (int j=0; j < tn; i++) {
      RegressionTree rt=new RegressionTree();
      rt.read(in);
      grove[i]=rt;
      in.readLine();
    }
    groves.add(grove);
  }
}

Fixed version (ground truth):
@Override public void read(BufferedReader in) throws Exception {
  int bn=Integer.parseInt(in.readLine().split("String_Node_Str")[1]);
  groves=new ArrayList<>();
  for (int i=0; i < bn; i++) {
    int tn=Integer.parseInt(in.readLine().split("String_Node_Str")[1]);
    RegressionTree[] grove=new RegressionTree[tn];
    for (int j=0; j < tn; j++) {
      in.readLine();
      RegressionTree rt=new RegressionTree();
      rt.read(in);
      grove[i]=rt;
      in.readLine();
    }
    groves.add(grove);
    in.readLine();
  }
}
Program: 117226
Project: 117226
Buggy source:
@Override public void write(PrintWriter out) throws Exception {
  out.printf("String_Node_Str",this.getClass().getCanonicalName());
  out.println("String_Node_Str" + groves.size());
  for (  RegressionTree[] grove : groves) {
    out.println("String_Node_Str" + grove.length);
    for (    RegressionTree rt : grove) {
      rt.write(out);
    }
    out.println();
  }
}

Fixed version (ground truth):
@Override public void write(PrintWriter out) throws Exception {
  out.printf("String_Node_Str",this.getClass().getCanonicalName());
  out.println("String_Node_Str" + groves.size());
  for (  RegressionTree[] grove : groves) {
    out.println("String_Node_Str" + grove.length);
    for (    RegressionTree rt : grove) {
      rt.write(out);
      out.println();
    }
    out.println();
  }
}
Program: 117228
Project: 117228
Buggy source:
protected static Function2D getFunction2D(int attIndex1,int attIndex2,int[] v1,int v2,double[] predInt){
  double[] splits1=null;
  double[] splits2=new double[]{v2 + 0.5,Double.POSITIVE_INFINITY};
  double[][] predictions=null;
  if (v1[0] < v1[1]) {
    splits1=new double[]{v1[0] + 0.5,v1[1] + 0.5,Double.POSITIVE_INFINITY};
    predictions=new double[][]{{predInt[0],predInt[2]},{predInt[1],predInt[2]},{predInt[1],predInt[3]}};
  }
 else   if (v1[0] > v1[1]) {
    splits1=new double[]{v1[1] + 0.5,v1[0] + 0.5,Double.POSITIVE_INFINITY};
    predictions=new double[][]{{predInt[0],predInt[2]},{predInt[0],predInt[3]},{predInt[1],predInt[3]}};
  }
 else {
    splits1=new double[]{v1[0] + 0.5,Double.POSITIVE_INFINITY};
    predictions=new double[][]{{predInt[0],predInt[1]},{predInt[2],predInt[3]}};
  }
  return new Function2D(attIndex1,attIndex2,splits1,splits2,predictions);
}

Fixed version (ground truth):
protected static Function2D getFunction2D(int attIndex1,int attIndex2,int[] v1,int v2,double[] predInt){
  double[] splits1=null;
  double[] splits2=new double[]{v2,Double.POSITIVE_INFINITY};
  double[][] predictions=null;
  if (v1[0] < v1[1]) {
    splits1=new double[]{v1[0],v1[1],Double.POSITIVE_INFINITY};
    predictions=new double[][]{{predInt[0],predInt[2]},{predInt[1],predInt[2]},{predInt[1],predInt[3]}};
  }
 else   if (v1[0] > v1[1]) {
    splits1=new double[]{v1[1],v1[0],Double.POSITIVE_INFINITY};
    predictions=new double[][]{{predInt[0],predInt[2]},{predInt[0],predInt[3]},{predInt[1],predInt[3]}};
  }
 else {
    splits1=new double[]{v1[0],Double.POSITIVE_INFINITY};
    predictions=new double[][]{{predInt[0],predInt[2]},{predInt[1],predInt[3]}};
  }
  return new Function2D(attIndex1,attIndex2,splits1,splits2,predictions);
}
Program: 117229
Project: 117229
Buggy source:
protected static void lineSearch(Instances instances,int attIndex1,int attIndex2,int c1,int c21,int c22,double[] predictions){
  double[] numerator=new double[4];
  double[] denominator=new double[4];
  for (  Instance instance : instances) {
    int v1=(int)instance.getValue(attIndex1);
    int v2=(int)instance.getValue(attIndex2);
    double target=instance.getTarget();
    double t=Math.abs(target);
    if (v1 <= c1) {
      if (v2 <= c21) {
        numerator[0]+=target * instance.getWeight();
        denominator[0]+=t * (1 - t) * instance.getWeight();
      }
 else {
        numerator[1]+=target * instance.getWeight();
        denominator[1]+=t * (1 - t) * instance.getWeight();
      }
    }
 else {
      if (v2 <= c22) {
        numerator[2]+=target * instance.getWeight();
        denominator[2]+=t * (1 - t) * instance.getWeight();
      }
 else {
        numerator[3]+=target * instance.getWeight();
        denominator[3]+=t * (1 - t) * instance.getWeight();
      }
    }
  }
  for (int i=0; i < numerator.length; i++) {
    predictions[i]=denominator[i] == 0 ? 0.0 : numerator[i] / denominator[i];
  }
}

Fixed version (ground truth):
protected static void lineSearch(Instances instances,int attIndex1,int attIndex2,int c1,int c21,int c22,double[] predictions){
  double[] numerator=new double[4];
  double[] denominator=new double[4];
  for (  Instance instance : instances) {
    int v1=(int)instance.getValue(attIndex1);
    int v2=(int)instance.getValue(attIndex2);
    double target=instance.getTarget();
    double t=Math.abs(target);
    if (v1 <= c1) {
      if (v2 <= c21) {
        numerator[0]+=target * instance.getWeight();
        denominator[0]+=t * (1 - t) * instance.getWeight();
      }
 else {
        numerator[1]+=target * instance.getWeight();
        denominator[1]+=t * (1 - t) * instance.getWeight();
      }
    }
 else {
      if (v2 <= c22) {
        numerator[2]+=target * instance.getWeight();
        denominator[2]+=t * (1 - t) * instance.getWeight();
      }
 else {
        numerator[3]+=target * instance.getWeight();
        denominator[3]+=t * (1 - t) * instance.getWeight();
      }
    }
  }
  for (int i=0; i < numerator.length; i++) {
    predictions[i]=Math.abs(denominator[i]) < MathUtils.EPSILON ? 0.0 : numerator[i] / denominator[i];
  }
}
Program: 117230
Project: 117230
Buggy source:
protected static void lineSearch(Instances instances,int attIndex1,int attIndex2,int c1,int c21,int c22,double[] predictions){
  double[] numerator=new double[4];
  double[] denominator=new double[4];
  for (  Instance instance : instances) {
    int v1=(int)instance.getValue(attIndex1);
    int v2=(int)instance.getValue(attIndex2);
    double target=instance.getTarget();
    double t=Math.abs(target);
    if (v1 <= c1) {
      if (v2 <= c21) {
        numerator[0]+=target;
        denominator[0]+=t * (1 - t);
      }
 else {
        numerator[1]+=target;
        denominator[1]+=t * (1 - t);
      }
    }
 else {
      if (v2 <= c22) {
        numerator[2]+=target;
        denominator[2]+=t * (1 - t);
      }
 else {
        numerator[3]+=target;
        denominator[3]+=t * (1 - t);
      }
    }
  }
  for (int i=0; i < numerator.length; i++) {
    predictions[i]=denominator[i] == 0 ? 0.0 : numerator[i] / denominator[i];
  }
}

Fixed version (ground truth):
protected static void lineSearch(Instances instances,int attIndex1,int attIndex2,int c1,int c21,int c22,double[] predictions){
  double[] numerator=new double[4];
  double[] denominator=new double[4];
  for (  Instance instance : instances) {
    int v1=(int)instance.getValue(attIndex1);
    int v2=(int)instance.getValue(attIndex2);
    double target=instance.getTarget();
    double t=Math.abs(target);
    if (v1 <= c1) {
      if (v2 <= c21) {
        numerator[0]+=target * instance.getWeight();
        denominator[0]+=t * (1 - t) * instance.getWeight();
      }
 else {
        numerator[1]+=target * instance.getWeight();
        denominator[1]+=t * (1 - t) * instance.getWeight();
      }
    }
 else {
      if (v2 <= c22) {
        numerator[2]+=target * instance.getWeight();
        denominator[2]+=t * (1 - t) * instance.getWeight();
      }
 else {
        numerator[3]+=target * instance.getWeight();
        denominator[3]+=t * (1 - t) * instance.getWeight();
      }
    }
  }
  for (int i=0; i < numerator.length; i++) {
    predictions[i]=denominator[i] == 0 ? 0.0 : numerator[i] / denominator[i];
  }
}
Program: 117231
Project: 117231
Buggy source:
@Override public double eval(double[] preds,Instances instances){
  double error=0;
  for (int i=0; i < preds.length; i++) {
    if (preds[i] != instances.get(i).getTarget()) {
      error++;
    }
  }
  return error / preds.length;
}

Fixed version (ground truth):
@Override public double eval(double[] preds,Instances instances){
  double error=0;
  for (int i=0; i < preds.length; i++) {
    double cls=preds[i] <= 0 ? 0 : 1;
    if (cls != instances.get(i).getTarget()) {
      error++;
    }
  }
  return error / preds.length;
}
Program: 117232
Project: 117232
Buggy source:
protected double findMaxLambda(int[][] indices,double[][] values,int[] y,double[] predictionTrain,double l1Ratio){
  if (fitIntercept) {
    OptimUtils.fitIntercept(predictionTrain,y);
  }
  double maxLambda=0;
  for (int k=0; k < values.length; k++) {
    double eta=0;
    int[] index=indices[k];
    double[] value=values[k];
    for (int i=0; i < index.length; i++) {
      int idx=index[i];
      double r=OptimUtils.getPseudoResidual(predictionTrain[idx],y[idx]);
      r*=value[i];
      eta+=r;
    }
    double t=Math.abs(eta);
    if (t > maxLambda) {
      maxLambda=t;
    }
  }
  maxLambda/=y.length;
  maxLambda/=l1Ratio;
  if (fitIntercept) {
    Arrays.fill(predictionTrain,0);
  }
  return maxLambda;
}

Fixed version (ground truth):
protected double findMaxLambda(int[][] indices,double[][] values,int[] y,double[] pTrain,double[] rTrain,double l1Ratio){
  if (fitIntercept) {
    OptimUtils.fitIntercept(pTrain,rTrain,y);
  }
  double maxLambda=0;
  for (int k=0; k < values.length; k++) {
    double eta=0;
    int[] index=indices[k];
    double[] value=values[k];
    for (int i=0; i < index.length; i++) {
      int idx=index[i];
      double r=OptimUtils.getPseudoResidual(pTrain[idx],y[idx]);
      r*=value[i];
      eta+=r;
    }
    double t=Math.abs(eta);
    if (t > maxLambda) {
      maxLambda=t;
    }
  }
  maxLambda/=y.length;
  maxLambda/=l1Ratio;
  if (fitIntercept) {
    Arrays.fill(pTrain,0);
    OptimUtils.computePseudoResidual(pTrain,y,rTrain);
  }
  return maxLambda;
}
Program: 117237
Project: 117237
Buggy source:
static GLM getGLM(int[] attrs,double[] w,double intercept){
  GLM glm=attrs.length == 0 ? new GLM(0) : new GLM(attrs[attrs.length - 1] + 1);
  for (int i=0; i < attrs.length; i++) {
    glm.w[0][attrs[i]]=w[i];
  }
  glm.intercept[0]=intercept;
  return glm;
}

Fixed version (ground truth):
static GLM getGLM(int[] attrs,double[] w,double intercept){
  final int p=attrs.length == 0 ? 0 : StatUtils.max(attrs) + 1;
  GLM glm=new GLM(p);
  for (int i=0; i < attrs.length; i++) {
    glm.w[0][attrs[i]]=w[i];
  }
  glm.intercept[0]=intercept;
  return glm;
}
Program: 117238
Project: 117238
Buggy source:
@Override public String stringValue(){
  int offset=this.getTzOffsetMinutes();
  if (offset == 0) {
    return "String_Node_Str";
  }
  StringBuilder stringBuilder=new StringBuilder();
  if (offset < 0) {
    stringBuilder.append('-');
  }
 else {
    stringBuilder.append('+');
  }
  int hourPart=offset / 60;
  int minutePart=offset - (hourPart * 60);
  stringBuilder.append(String.format("String_Node_Str",hourPart));
  stringBuilder.append(':');
  stringBuilder.append(String.format("String_Node_Str",minutePart));
  return stringBuilder.toString();
}

Fixed version (ground truth):
@Override public String stringValue(){
  int offset=this.getTzOffsetMinutes();
  if (offset == 0) {
    return "String_Node_Str";
  }
  StringBuilder stringBuilder=new StringBuilder();
  if (offset < 0) {
    stringBuilder.append('-');
    offset=offset * -1;
  }
 else {
    stringBuilder.append('+');
  }
  int hourPart=offset / 60;
  int minutePart=offset - (hourPart * 60);
  stringBuilder.append(String.format("String_Node_Str",hourPart));
  stringBuilder.append(':');
  stringBuilder.append(String.format("String_Node_Str",minutePart));
  return stringBuilder.toString();
}
Program: 117239
Project: 117239
Buggy source:
protected static PolicyDef newInstance(Document document,PolicySet policySetParent) throws DOMStructureException {
  PolicyDef policyDef=null;
  try {
    Node rootNode=document.getFirstChild();
    if (rootNode == null) {
      throw new Exception("String_Node_Str");
    }
    if (DOMUtil.isInNamespace(rootNode,XACML3.XMLNS)) {
      if (XACML3.ELEMENT_POLICY.equals(rootNode.getLocalName())) {
        policyDef=DOMPolicy.newInstance(rootNode,policySetParent,null);
        if (policyDef == null) {
          throw new DOMStructureException("String_Node_Str");
        }
      }
 else       if (XACML3.ELEMENT_POLICYSET.equals(rootNode.getLocalName())) {
        policyDef=DOMPolicySet.newInstance(rootNode,policySetParent,null);
        if (policyDef == null) {
          throw new DOMStructureException("String_Node_Str");
        }
      }
 else {
        throw DOMUtil.newUnexpectedElementException(rootNode);
      }
    }
 else {
      throw DOMUtil.newUnexpectedElementException(rootNode);
    }
  }
 catch (  Exception ex) {
    throw new DOMStructureException("String_Node_Str" + ex.getMessage(),ex);
  }
  return policyDef;
}

Fixed version (ground truth):
protected static PolicyDef newInstance(Document document,PolicySet policySetParent) throws DOMStructureException {
  PolicyDef policyDef=null;
  try {
    Node rootNode=document.getFirstChild();
    if (rootNode == null) {
      throw new Exception("String_Node_Str");
    }
    while (true) {
      if (rootNode.getNodeType() != Node.COMMENT_NODE) {
        break;
      }
      rootNode=rootNode.getNextSibling();
      if (rootNode == null) {
        throw new Exception("String_Node_Str");
      }
    }
    if (DOMUtil.isInNamespace(rootNode,XACML3.XMLNS)) {
      if (XACML3.ELEMENT_POLICY.equals(rootNode.getLocalName())) {
        policyDef=DOMPolicy.newInstance(rootNode,policySetParent,null);
        if (policyDef == null) {
          throw new DOMStructureException("String_Node_Str");
        }
      }
 else       if (XACML3.ELEMENT_POLICYSET.equals(rootNode.getLocalName())) {
        policyDef=DOMPolicySet.newInstance(rootNode,policySetParent,null);
        if (policyDef == null) {
          throw new DOMStructureException("String_Node_Str");
        }
      }
 else {
        throw DOMUtil.newUnexpectedElementException(rootNode);
      }
    }
 else {
      throw DOMUtil.newUnexpectedElementException(rootNode);
    }
  }
 catch (  Exception ex) {
    throw new DOMStructureException("String_Node_Str" + ex.getMessage(),ex);
  }
  return policyDef;
}
Program: 117242
Project: 117242
Buggy source:
private void addObligation(Object parent,ObligationExpressionType expression,boolean bAdd){
  ObligationExpressionsType expressions=null;
  if (parent instanceof PolicySetType) {
    expressions=((PolicySetType)parent).getObligationExpressions();
    if (expressions == null) {
      expressions=new ObligationExpressionsType();
      ((PolicySetType)parent).setObligationExpressions(expressions);
    }
  }
 else   if (parent instanceof PolicyType) {
    expressions=((PolicyType)parent).getObligationExpressions();
    if (expressions == null) {
      expressions=new ObligationExpressionsType();
      ((PolicyType)parent).setObligationExpressions(expressions);
    }
  }
 else   if (parent instanceof RuleType) {
    expressions=((RuleType)parent).getObligationExpressions();
    if (expressions == null) {
      expressions=new ObligationExpressionsType();
      ((RuleType)parent).setObligationExpressions(expressions);
    }
  }
  if (bAdd) {
    expressions.getObligationExpression().add(expression);
  }
  this.obligations.put(expression,parent);
}

Fixed version (ground truth):
private void addObligation(Object parent,ObligationExpressionType expression,boolean bAdd){
  ObligationExpressionsType expressions=null;
  if (parent instanceof PolicySetType) {
    expressions=((PolicySetType)parent).getObligationExpressions();
    if (expressions == null) {
      expressions=new ObligationExpressionsType();
      ((PolicySetType)parent).setObligationExpressions(expressions);
    }
  }
 else   if (parent instanceof PolicyType) {
    expressions=((PolicyType)parent).getObligationExpressions();
    if (expressions == null) {
      expressions=new ObligationExpressionsType();
      ((PolicyType)parent).setObligationExpressions(expressions);
    }
  }
 else   if (parent instanceof RuleType) {
    expressions=((RuleType)parent).getObligationExpressions();
    if (expressions == null) {
      expressions=new ObligationExpressionsType();
      ((RuleType)parent).setObligationExpressions(expressions);
    }
  }
 else   if (parent instanceof ObligationExpressionsType) {
    expressions=(ObligationExpressionsType)parent;
    if (bAdd) {
      expressions.getObligationExpression().add(expression);
    }
    parent=this.getParent(expressions);
    this.obligations.put(expression,parent);
    return;
  }
  if (bAdd) {
    expressions.getObligationExpression().add(expression);
  }
  this.obligations.put(expression,parent);
}
Program: 117243
Project: 117243
Buggy source:
private void addAdvice(Object parent,AdviceExpressionType expression,boolean bAdd){
  AdviceExpressionsType expressions=null;
  if (parent instanceof PolicySetType) {
    expressions=((PolicySetType)parent).getAdviceExpressions();
    if (expressions == null) {
      expressions=new AdviceExpressionsType();
      ((PolicySetType)parent).setAdviceExpressions(expressions);
    }
  }
 else   if (parent instanceof PolicyType) {
    expressions=((PolicyType)parent).getAdviceExpressions();
    if (expressions == null) {
      expressions=new AdviceExpressionsType();
      ((PolicyType)parent).setAdviceExpressions(expressions);
    }
  }
 else   if (parent instanceof RuleType) {
    expressions=((RuleType)parent).getAdviceExpressions();
    if (expressions == null) {
      expressions=new AdviceExpressionsType();
      ((RuleType)parent).setAdviceExpressions(expressions);
    }
  }
  if (bAdd) {
    expressions.getAdviceExpression().add(expression);
  }
  this.advice.put(expression,parent);
}

Fixed version (ground truth):
private void addAdvice(Object parent,AdviceExpressionType expression,boolean bAdd){
  AdviceExpressionsType expressions=null;
  if (parent instanceof PolicySetType) {
    expressions=((PolicySetType)parent).getAdviceExpressions();
    if (expressions == null) {
      expressions=new AdviceExpressionsType();
      ((PolicySetType)parent).setAdviceExpressions(expressions);
    }
  }
 else   if (parent instanceof PolicyType) {
    expressions=((PolicyType)parent).getAdviceExpressions();
    if (expressions == null) {
      expressions=new AdviceExpressionsType();
      ((PolicyType)parent).setAdviceExpressions(expressions);
    }
  }
 else   if (parent instanceof RuleType) {
    expressions=((RuleType)parent).getAdviceExpressions();
    if (expressions == null) {
      expressions=new AdviceExpressionsType();
      ((RuleType)parent).setAdviceExpressions(expressions);
    }
  }
 else   if (parent instanceof AdviceExpressionsType) {
    expressions=(AdviceExpressionsType)parent;
    if (bAdd) {
      expressions.getAdviceExpression().add(expression);
    }
    parent=this.getParent(expressions);
    this.advice.put(expression,parent);
    return;
  }
  if (bAdd) {
    expressions.getAdviceExpression().add(expression);
  }
  this.advice.put(expression,parent);
}
Program: 117244
Project: 117244
Buggy source:
@Override public Object getParent(Object itemId){
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + itemId);
  }
  if (itemId.equals(this.root)) {
    if (logger.isTraceEnabled()) {
      logger.trace("String_Node_Str");
    }
    return null;
  }
  if (itemId instanceof PolicySetType) {
    return this.policySets.get(itemId);
  }
  if (itemId instanceof PolicyType) {
    return this.policies.get(itemId);
  }
  if (itemId instanceof RuleType) {
    return this.rules.get(itemId);
  }
  if (itemId instanceof TargetType) {
    return this.targets.get(itemId);
  }
  if (itemId instanceof ObligationExpressionType) {
    return this.obligations.get(itemId);
  }
  if (itemId instanceof AdviceExpressionType) {
    return this.advice.get(itemId);
  }
  if (itemId instanceof AllOfType) {
    return this.allofs.get(itemId);
  }
  if (itemId instanceof AnyOfType) {
    return this.anyofs.get(itemId);
  }
  if (itemId instanceof MatchType) {
    return this.matches.get(itemId);
  }
  if (itemId instanceof ConditionType) {
    return this.conditions.get(itemId);
  }
  if (itemId instanceof VariableDefinitionType) {
    return this.variables.get(itemId);
  }
  return null;
}

Fixed version (ground truth):
@Override public Object getParent(Object itemId){
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + itemId);
  }
  assert(itemId != null);
  if (itemId == null) {
    logger.fatal("String_Node_Str");
    return null;
  }
  if (itemId.equals(this.root)) {
    if (logger.isTraceEnabled()) {
      logger.trace("String_Node_Str");
    }
    return null;
  }
  if (itemId instanceof PolicySetType) {
    return this.policySets.get(itemId);
  }
  if (itemId instanceof PolicyType) {
    return this.policies.get(itemId);
  }
  if (itemId instanceof RuleType) {
    return this.rules.get(itemId);
  }
  if (itemId instanceof TargetType) {
    return this.targets.get(itemId);
  }
  if (itemId instanceof ObligationExpressionType) {
    return this.obligations.get(itemId);
  }
  if (itemId instanceof AdviceExpressionType) {
    return this.advice.get(itemId);
  }
  if (itemId instanceof AllOfType) {
    return this.allofs.get(itemId);
  }
  if (itemId instanceof AnyOfType) {
    return this.anyofs.get(itemId);
  }
  if (itemId instanceof MatchType) {
    return this.matches.get(itemId);
  }
  if (itemId instanceof ConditionType) {
    return this.conditions.get(itemId);
  }
  if (itemId instanceof VariableDefinitionType) {
    return this.variables.get(itemId);
  }
  return null;
}
Program: 117245
Project: 117245
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  PreferenceManager.setDefaultValues(this,R.xml.preferences,false);
  Preferences.getInstance(this).getPreferences().registerOnSharedPreferenceChangeListener(this);
  mConversions=Conversions.getInstance();
  setContentView(R.layout.activity_main);
  setupToolbar();
  setToolbarHomeNavigation(true);
  if (getSupportActionBar() != null)   getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
  int conversion=Preferences.getInstance(this).getLastConversion();
  setToolbarTitle(mConversions.getById(conversion).getLabelResource());
  mDrawerLayout=(DrawerLayout)findViewById(R.id.drawer_layout);
  mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener(){
    @Override public void onDrawerSlide(    View drawerView,    float slideOffset){
    }
    @Override public void onDrawerOpened(    View drawerView){
      hideKeyboard();
    }
    @Override public void onDrawerClosed(    View drawerView){
    }
    @Override public void onDrawerStateChanged(    int newState){
    }
  }
);
  setupDrawer(conversion);
  if (savedInstanceState == null) {
    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,ConversionFragment.newInstance(conversion)).commit();
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  PreferenceManager.setDefaultValues(this,R.xml.preferences,false);
  Preferences.getInstance(this).getPreferences().registerOnSharedPreferenceChangeListener(this);
  mConversions=Conversions.getInstance();
  setContentView(R.layout.activity_main);
  setupToolbar();
  setToolbarHomeNavigation(true);
  if (getSupportActionBar() != null)   getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
  int conversion=Preferences.getInstance(this).getLastConversion();
  setToolbarTitle(mConversions.getById(conversion).getLabelResource());
  mDrawerLayout=(DrawerLayout)findViewById(R.id.drawer_layout);
  mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener(){
    @Override public void onDrawerSlide(    View drawerView,    float slideOffset){
    }
    @Override public void onDrawerOpened(    View drawerView){
      hideKeyboard();
    }
    @Override public void onDrawerClosed(    View drawerView){
    }
    @Override public void onDrawerStateChanged(    int newState){
    }
  }
);
  setupDrawer(getMenuPositionOfConversion(conversion));
  if (savedInstanceState == null) {
    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,ConversionFragment.newInstance(conversion)).commit();
  }
}
Program: 117246
Project: 117246
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.menu_download:
    mPresenter.onUpdateCurrencyConversions(true);
  return true;
case R.id.menu_clear:
mTxtValue.setText("String_Node_Str");
return true;
case R.id.menu_help:
HelpDialogFragment.newInstance().show(getChildFragmentManager(),HelpDialogFragment.TAG);
return true;
case R.id.menu_settings:
PreferencesActivity.start(getActivity());
return true;
case R.id.menu_donate:
DonateActivity.start(getActivity());
default :
return super.onOptionsItemSelected(item);
}
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.menu_download:
    mPresenter.onUpdateCurrencyConversions();
  return true;
case R.id.menu_clear:
mTxtValue.setText("String_Node_Str");
return true;
case R.id.menu_help:
HelpDialogFragment.newInstance().show(getChildFragmentManager(),HelpDialogFragment.TAG);
return true;
case R.id.menu_settings:
PreferencesActivity.start(getActivity());
return true;
case R.id.menu_donate:
DonateActivity.start(getActivity());
default :
return super.onOptionsItemSelected(item);
}
}
Program: 117247
Project: 117247
Buggy source:
/** 
 * Get the Unit associated with the checked button in a radio group
 * @param group RadioGroup which contains the button
 * @return Unit associated with checked button
 */
private Unit getCheckedUnit(RadioGroup group){
  int index=group.getCheckedRadioButtonId();
  RadioButton btn=(RadioButton)group.findViewById(index);
  return (Unit)btn.getTag();
}

Fixed version (ground truth):
/** 
 * Get the Unit associated with the checked button in a radio group
 * @param group RadioGroup which contains the button
 * @return Unit associated with checked button
 */
private Unit getCheckedUnit(RadioGroup group){
  int id=group.getCheckedRadioButtonId();
  Conversion c=Conversions.getInstance().getById(mConversionId);
  for (  Unit unit : c.getUnits()) {
    if (unit.getId() == id) {
      return unit;
    }
  }
  return c.getUnits().get(0);
}
Program: 117248
Project: 117248
Buggy source:
@Override public void onFailure(Call<CurrencyResponse> call,Throwable t){
  if (!Conversions.getInstance().hasCurrency()) {
    mView.showLoadingError(R.string.error_loading_currency);
  }
 else   if (showResult) {
    mView.showToastError(R.string.toast_error_updating_currency);
  }
}

Fixed version (ground truth):
@Override public void onFailure(Call<CurrencyResponse> call,Throwable t){
  if (!Conversions.getInstance().hasCurrency()) {
    mView.showLoadingError(R.string.error_loading_currency);
  }
 else {
    mView.showToastError(R.string.toast_error_updating_currency);
  }
}
Program: 117249
Project: 117249
Buggy source:
public void onGetUnitsToDisplay(@Conversion.id int conversionId){
switch (conversionId) {
case Conversion.CURRENCY:
    onUpdateCurrencyConversions(false);
  if (Conversions.getInstance().hasCurrency()) {
    mView.showUnitsList(Conversions.getInstance().getById(conversionId));
  }
 else {
    mView.showProgressCircle();
  }
break;
default :
mView.showUnitsList(Conversions.getInstance().getById(conversionId));
break;
}
}

Fixed version (ground truth):
public void onGetUnitsToDisplay(@Conversion.id int conversionId){
switch (conversionId) {
case Conversion.CURRENCY:
    if (Conversions.getInstance().hasCurrency()) {
      mView.showUnitsList(Conversions.getInstance().getById(conversionId));
    }
 else {
      mView.showProgressCircle();
    }
  if (!Conversions.getInstance().isCurrencyUpdated()) {
    onUpdateCurrencyConversions();
  }
break;
default :
mView.showUnitsList(Conversions.getInstance().getById(conversionId));
break;
}
}
Program: 117250
Project: 117250
Buggy source:
@Override public void onResponse(Call<CurrencyResponse> call,Response<CurrencyResponse> response){
  boolean hadCurrency=Conversions.getInstance().hasCurrency();
  Preferences.getInstance(mView.getContext()).saveLatestCurrency(response.body());
  Conversions.getInstance().updateCurrencyConversions(mView.getContext());
  if (hadCurrency) {
    mView.updateCurrencyConversion();
    if (showResult) {
      mView.showToast(R.string.toast_currency_updated);
    }
  }
 else {
    mView.showUnitsList(Conversions.getInstance().getById(Conversion.CURRENCY));
  }
}

Fixed version (ground truth):
@Override public void onResponse(Call<CurrencyResponse> call,Response<CurrencyResponse> response){
  boolean hadCurrency=Conversions.getInstance().hasCurrency();
  Preferences.getInstance(mView.getContext()).saveLatestCurrency(response.body());
  Conversions.getInstance().updateCurrencyConversions(mView.getContext());
  Conversions.getInstance().setCurrencyUpdated(true);
  mView.showToast(R.string.toast_currency_updated);
  if (hadCurrency) {
    mView.updateCurrencyConversion();
  }
 else {
    mView.showUnitsList(Conversions.getInstance().getById(Conversion.CURRENCY));
  }
}
Program: 117251
Project: 117251
Buggy source:
public void onUpdateCurrencyConversions(final boolean showResult){
  FixerApi.getInstance().getService().getLatestRates().enqueue(new Callback<CurrencyResponse>(){
    @Override public void onResponse(    Call<CurrencyResponse> call,    Response<CurrencyResponse> response){
      boolean hadCurrency=Conversions.getInstance().hasCurrency();
      Preferences.getInstance(mView.getContext()).saveLatestCurrency(response.body());
      Conversions.getInstance().updateCurrencyConversions(mView.getContext());
      if (hadCurrency) {
        mView.updateCurrencyConversion();
        if (showResult) {
          mView.showToast(R.string.toast_currency_updated);
        }
      }
 else {
        mView.showUnitsList(Conversions.getInstance().getById(Conversion.CURRENCY));
      }
    }
    @Override public void onFailure(    Call<CurrencyResponse> call,    Throwable t){
      if (!Conversions.getInstance().hasCurrency()) {
        mView.showLoadingError(R.string.error_loading_currency);
      }
 else       if (showResult) {
        mView.showToastError(R.string.toast_error_updating_currency);
      }
    }
  }
);
}

Fixed version (ground truth):
public void onUpdateCurrencyConversions(){
  FixerApi.getInstance().getService().getLatestRates().enqueue(new Callback<CurrencyResponse>(){
    @Override public void onResponse(    Call<CurrencyResponse> call,    Response<CurrencyResponse> response){
      boolean hadCurrency=Conversions.getInstance().hasCurrency();
      Preferences.getInstance(mView.getContext()).saveLatestCurrency(response.body());
      Conversions.getInstance().updateCurrencyConversions(mView.getContext());
      Conversions.getInstance().setCurrencyUpdated(true);
      mView.showToast(R.string.toast_currency_updated);
      if (hadCurrency) {
        mView.updateCurrencyConversion();
      }
 else {
        mView.showUnitsList(Conversions.getInstance().getById(Conversion.CURRENCY));
      }
    }
    @Override public void onFailure(    Call<CurrencyResponse> call,    Throwable t){
      if (!Conversions.getInstance().hasCurrency()) {
        mView.showLoadingError(R.string.error_loading_currency);
      }
 else {
        mView.showToastError(R.string.toast_error_updating_currency);
      }
    }
  }
);
}
Program: 117252
Project: 117252
Buggy source:
private Conversions(){
  getAreaConversions();
  getCookingConversions();
  getStorageConversions();
  getEnergyConversions();
  getFuelConversions();
  getLengthConversions();
  getMassConversions();
  getPowerConversions();
  getPressureConversions();
  getSpeedConversions();
  getTemperatureConversions();
  getTimeConversions();
  getTorqueConversions();
  getVolumeConversions();
}

Fixed version (ground truth):
private Conversions(){
  getAreaConversions();
  getCookingConversions();
  getStorageConversions();
  getEnergyConversions();
  getFuelConversions();
  getLengthConversions();
  getMassConversions();
  getPowerConversions();
  getPressureConversions();
  getSpeedConversions();
  getTemperatureConversions();
  getTimeConversions();
  getTorqueConversions();
  getVolumeConversions();
  mCurrencyUpdated=false;
}
Program: 117253
Project: 117253
Buggy source:
private void getStorageConversions(){
  List<Unit> units=new ArrayList<Unit>();
  units.add(new Unit(BIT,R.string.bit,0.00000011920928955078,8388608.0));
  units.add(new Unit(BYTE,R.string.Byte,0.00000095367431640625,1048576.0));
  units.add(new Unit(KILOBIT,R.string.kilobit,0.0001220703125,8192.0));
  units.add(new Unit(KILOBYTE,R.string.kilobyte,0.0009765625,1024.0));
  units.add(new Unit(MEGABIT,R.string.megabit,1.0,1.0));
  units.add(new Unit(MEGABYTE,R.string.megabyte,0.83612736,1.19599004630108026));
  units.add(new Unit(GIGABIT,R.string.gigabit,128.0,0.0078125));
  units.add(new Unit(GIGABYTE,R.string.gigabyte,1024.0,0.0009765625));
  units.add(new Unit(TERABIT,R.string.terabit,131072.0,0.00000762939453125));
  units.add(new Unit(TERABYTE,R.string.terabyte,1048576.0,0.00000095367431640625));
  addConversion(Conversion.STORAGE,new Conversion(Conversion.STORAGE,R.string.storage,units));
}

Fixed version (ground truth):
private void getStorageConversions(){
  List<Unit> units=new ArrayList<Unit>();
  units.add(new Unit(BIT,R.string.bit,0.00000011920928955078,8388608.0));
  units.add(new Unit(BYTE,R.string.Byte,0.00000095367431640625,1048576.0));
  units.add(new Unit(KILOBIT,R.string.kilobit,0.0001220703125,8192.0));
  units.add(new Unit(KILOBYTE,R.string.kilobyte,0.0009765625,1024.0));
  units.add(new Unit(MEGABIT,R.string.megabit,0.125,8.0));
  units.add(new Unit(MEGABYTE,R.string.megabyte,1.0,1.0));
  units.add(new Unit(GIGABIT,R.string.gigabit,128.0,0.0078125));
  units.add(new Unit(GIGABYTE,R.string.gigabyte,1024.0,0.0009765625));
  units.add(new Unit(TERABIT,R.string.terabit,131072.0,0.00000762939453125));
  units.add(new Unit(TERABYTE,R.string.terabyte,1048576.0,0.00000095367431640625));
  addConversion(Conversion.STORAGE,new Conversion(Conversion.STORAGE,R.string.storage,units));
}
Program: 117254
Project: 117254
Buggy source:
@Test public void testStorage(){
  Conversion storage=mConversions.getById(Conversion.STORAGE);
  mPresenter.convert(4.0,storage.getUnitById(BYTE),storage.getUnitById(BIT));
  verify(view,atLeastOnce()).showResult(eq(32.0));
  mPresenter.convert(4.0,storage.getUnitById(KILOBIT),storage.getUnitById(BYTE));
  verify(view,atLeastOnce()).showResult(eq(512.0));
  mPresenter.convert(4.0,storage.getUnitById(KILOBYTE),storage.getUnitById(KILOBIT));
  verify(view,atLeastOnce()).showResult(eq(32.0));
  mPresenter.convert(4.0,storage.getUnitById(MEGABIT),storage.getUnitById(KILOBYTE));
  verify(view,atLeastOnce()).showResult(eq(512.0));
  mPresenter.convert(4.0,storage.getUnitById(MEGABYTE),storage.getUnitById(MEGABIT));
  verify(view,atLeastOnce()).showResult(eq(32.0));
  mPresenter.convert(4.0,storage.getUnitById(GIGABIT),storage.getUnitById(MEGABYTE));
  verify(view,atLeastOnce()).showResult(eq(512.0));
  mPresenter.convert(4.0,storage.getUnitById(GIGABYTE),storage.getUnitById(GIGABIT));
  verify(view,atLeastOnce()).showResult(eq(32.0));
  mPresenter.convert(4.0,storage.getUnitById(TERABIT),storage.getUnitById(GIGABYTE));
  verify(view,atLeastOnce()).showResult(eq(512.0));
  mPresenter.convert(4.0,storage.getUnitById(TERABIT),storage.getUnitById(TERABYTE));
  verify(view,atLeastOnce()).showResult(eq(0.5));
  mPresenter.convert(4.0,storage.getUnitById(BIT),storage.getUnitById(BYTE));
  verify(view,atLeastOnce()).showResult(eq(0.5));
}

Fixed version (ground truth):
@Test public void testStorage(){
  Conversion storage=mConversions.getById(Conversion.STORAGE);
  mPresenter.convert(4.0,storage.getUnitById(BYTE),storage.getUnitById(BIT));
  verify(view,atLeastOnce()).showResult(eq(32.0));
  mPresenter.convert(4.0,storage.getUnitById(KILOBIT),storage.getUnitById(BYTE));
  verify(view,atLeastOnce()).showResult(eq(512.0));
  mPresenter.convert(4.0,storage.getUnitById(KILOBYTE),storage.getUnitById(KILOBIT));
  verify(view,atLeastOnce()).showResult(eq(32.0));
  mPresenter.convert(4.0,storage.getUnitById(MEGABIT),storage.getUnitById(KILOBYTE));
  verify(view,atLeastOnce()).showResult(eq(512.0));
  mPresenter.convert(4.0,storage.getUnitById(MEGABYTE),storage.getUnitById(MEGABIT));
  verify(view,atLeastOnce()).showResult(eq(32.0));
  mPresenter.convert(4.0,storage.getUnitById(GIGABIT),storage.getUnitById(MEGABYTE));
  verify(view,atLeastOnce()).showResult(eq(512.0));
  mPresenter.convert(4.0,storage.getUnitById(GIGABYTE),storage.getUnitById(GIGABIT));
  verify(view,atLeastOnce()).showResult(eq(32.0));
  mPresenter.convert(4.0,storage.getUnitById(TERABIT),storage.getUnitById(GIGABYTE));
  verify(view,atLeastOnce()).showResult(eq(512.0));
  mPresenter.convert(4.0,storage.getUnitById(TERABIT),storage.getUnitById(TERABYTE));
  verify(view,atLeastOnce()).showResult(eq(0.5));
  mPresenter.convert(4.0,storage.getUnitById(BIT),storage.getUnitById(BYTE));
  verify(view,atLeastOnce()).showResult(eq(0.5));
  mPresenter.convert(1.0,storage.getUnitById(GIGABYTE),storage.getUnitById(MEGABYTE));
  verify(view,atLeastOnce()).showResult(eq(1024.0));
}