nus-yam/ex-repair huggingface dataset:
Program: 27071
Project: 27071
Buggy source:
@Override public void write(JavaWriter javaWriter) throws IOException {
  javaWriter.beginControlFlow("String_Node_Str");
  for (  TableEndpointDefinition tableEndpointDefinition : contentProviderDefinition.endpointDefinitions) {
    for (    ContentUriDefinition uriDefinition : tableEndpointDefinition.contentUriDefinitions) {
      if (uriDefinition.deleteEnabled) {
        javaWriter.beginControlFlow("String_Node_Str",uriDefinition.name);
        SqlQueryBuilder queryBuilder=new SqlQueryBuilder("String_Node_Str").appendDelete().appendFromTable(contentProviderDefinition.databaseName,tableEndpointDefinition.tableName).appendWhere().appendPathSegments(uriDefinition.segments).appendCount();
        javaWriter.emitStatement(queryBuilder.getQuery());
        new NotifyWriter(tableEndpointDefinition,uriDefinition,Notify.Method.DELETE).write(javaWriter);
        javaWriter.emitStatement("String_Node_Str");
        javaWriter.endControlFlow();
      }
    }
  }
  javaWriter.beginControlFlow("String_Node_Str").emitStatement("String_Node_Str").endControlFlow();
  javaWriter.endControlFlow();
}

Fixed version (ground truth):
@Override public void write(JavaWriter javaWriter) throws IOException {
  javaWriter.beginControlFlow("String_Node_Str");
  for (  TableEndpointDefinition tableEndpointDefinition : contentProviderDefinition.endpointDefinitions) {
    for (    ContentUriDefinition uriDefinition : tableEndpointDefinition.contentUriDefinitions) {
      if (uriDefinition.deleteEnabled) {
        javaWriter.beginControlFlow("String_Node_Str",uriDefinition.name);
        SqlQueryBuilder queryBuilder=new SqlQueryBuilder("String_Node_Str").appendDelete().appendFromTable(contentProviderDefinition.databaseName,tableEndpointDefinition.tableName).appendWhere().appendPathSegments(manager,contentProviderDefinition.databaseName,tableEndpointDefinition.tableName,uriDefinition.segments).appendCount();
        javaWriter.emitStatement(queryBuilder.getQuery());
        new NotifyWriter(tableEndpointDefinition,uriDefinition,Notify.Method.DELETE).write(javaWriter);
        javaWriter.emitStatement("String_Node_Str");
        javaWriter.endControlFlow();
      }
    }
  }
  javaWriter.beginControlFlow("String_Node_Str").emitStatement("String_Node_Str").endControlFlow();
  javaWriter.endControlFlow();
}
Program: 27072
Project: 27072
Buggy source:
public DeleteWriter(ContentProviderDefinition contentProviderDefinition){
  this.contentProviderDefinition=contentProviderDefinition;
}

Fixed version (ground truth):
public DeleteWriter(ContentProviderDefinition contentProviderDefinition,ProcessorManager manager){
  this.contentProviderDefinition=contentProviderDefinition;
  this.manager=manager;
}
Program: 27073
Project: 27073
Buggy source:
public QueryWriter(ContentProviderDefinition contentProviderDefinition){
  this.contentProviderDefinition=contentProviderDefinition;
}

Fixed version (ground truth):
public QueryWriter(ContentProviderDefinition contentProviderDefinition,ProcessorManager manager){
  this.contentProviderDefinition=contentProviderDefinition;
  this.manager=manager;
}
Program: 27074
Project: 27074
Buggy source:
@Override public void write(JavaWriter javaWriter) throws IOException {
  javaWriter.emitStatement("String_Node_Str");
  javaWriter.beginControlFlow("String_Node_Str",ContentProviderDefinition.URI_MATCHER);
  for (  TableEndpointDefinition tableEndpointDefinition : contentProviderDefinition.endpointDefinitions) {
    for (    ContentUriDefinition uriDefinition : tableEndpointDefinition.contentUriDefinitions) {
      if (uriDefinition.queryEnabled) {
        javaWriter.beginControlFlow("String_Node_Str",uriDefinition.name);
        SqlQueryBuilder select=new SqlQueryBuilder("String_Node_Str").appendSelect().appendFromTable(contentProviderDefinition.databaseName,tableEndpointDefinition.tableName).appendWhere().appendPathSegments(uriDefinition.segments).appendQuery();
        javaWriter.emitStatement(select.getQuery());
        javaWriter.emitStatement("String_Node_Str");
        javaWriter.endControlFlow();
      }
    }
  }
  javaWriter.endControlFlow();
  javaWriter.beginControlFlow("String_Node_Str");
  javaWriter.emitStatement("String_Node_Str");
  javaWriter.endControlFlow();
  javaWriter.emitEmptyLine();
  javaWriter.emitStatement("String_Node_Str");
}

Fixed version (ground truth):
@Override public void write(JavaWriter javaWriter) throws IOException {
  javaWriter.emitStatement("String_Node_Str");
  javaWriter.beginControlFlow("String_Node_Str",ContentProviderDefinition.URI_MATCHER);
  for (  TableEndpointDefinition tableEndpointDefinition : contentProviderDefinition.endpointDefinitions) {
    for (    ContentUriDefinition uriDefinition : tableEndpointDefinition.contentUriDefinitions) {
      if (uriDefinition.queryEnabled) {
        javaWriter.beginControlFlow("String_Node_Str",uriDefinition.name);
        SqlQueryBuilder select=new SqlQueryBuilder("String_Node_Str").appendSelect().appendFromTable(contentProviderDefinition.databaseName,tableEndpointDefinition.tableName).appendWhere().appendPathSegments(manager,contentProviderDefinition.databaseName,tableEndpointDefinition.tableName,uriDefinition.segments).appendQuery();
        javaWriter.emitStatement(select.getQuery());
        javaWriter.emitStatement("String_Node_Str");
        javaWriter.endControlFlow();
      }
    }
  }
  javaWriter.endControlFlow();
  javaWriter.beginControlFlow("String_Node_Str");
  javaWriter.emitStatement("String_Node_Str");
  javaWriter.endControlFlow();
  javaWriter.emitEmptyLine();
  javaWriter.emitStatement("String_Node_Str");
}
Program: 27075
Project: 27075
Buggy source:
@Override public void write(JavaWriter javaWriter) throws IOException {
  javaWriter.beginControlFlow("String_Node_Str");
  for (  TableEndpointDefinition tableEndpointDefinition : contentProviderDefinition.endpointDefinitions) {
    for (    ContentUriDefinition uriDefinition : tableEndpointDefinition.contentUriDefinitions) {
      if (uriDefinition.updateEnabled) {
        javaWriter.beginControlFlow("String_Node_Str",uriDefinition.name);
        javaWriter.emitStatement("String_Node_Str",contentProviderDefinition.databaseName,tableEndpointDefinition.tableName);
        SqlQueryBuilder sqlQueryBuilder=new SqlQueryBuilder("String_Node_Str").appendUpdate().appendUpdateConflictAction().appendTable(contentProviderDefinition.databaseName,tableEndpointDefinition.tableName).appendSet().appendWhere().appendPathSegments(uriDefinition.segments).appendCount();
        javaWriter.emitStatement(sqlQueryBuilder.getQuery());
        new NotifyWriter(tableEndpointDefinition,uriDefinition,Notify.Method.UPDATE).write(javaWriter);
        javaWriter.emitStatement("String_Node_Str");
        javaWriter.endControlFlow();
      }
    }
  }
  javaWriter.beginControlFlow("String_Node_Str").emitStatement("String_Node_Str").endControlFlow();
  javaWriter.endControlFlow();
}

Fixed version (ground truth):
@Override public void write(JavaWriter javaWriter) throws IOException {
  javaWriter.beginControlFlow("String_Node_Str");
  for (  TableEndpointDefinition tableEndpointDefinition : contentProviderDefinition.endpointDefinitions) {
    for (    ContentUriDefinition uriDefinition : tableEndpointDefinition.contentUriDefinitions) {
      if (uriDefinition.updateEnabled) {
        javaWriter.beginControlFlow("String_Node_Str",uriDefinition.name);
        javaWriter.emitStatement("String_Node_Str",contentProviderDefinition.databaseName,tableEndpointDefinition.tableName);
        SqlQueryBuilder sqlQueryBuilder=new SqlQueryBuilder("String_Node_Str").appendUpdate().appendUpdateConflictAction().appendTable(contentProviderDefinition.databaseName,tableEndpointDefinition.tableName).appendSet().appendWhere().appendPathSegments(manager,contentProviderDefinition.databaseName,tableEndpointDefinition.tableName,uriDefinition.segments).appendCount();
        javaWriter.emitStatement(sqlQueryBuilder.getQuery());
        new NotifyWriter(tableEndpointDefinition,uriDefinition,Notify.Method.UPDATE).write(javaWriter);
        javaWriter.emitStatement("String_Node_Str");
        javaWriter.endControlFlow();
      }
    }
  }
  javaWriter.beginControlFlow("String_Node_Str").emitStatement("String_Node_Str").endControlFlow();
  javaWriter.endControlFlow();
}
Program: 27076
Project: 27076
Buggy source:
public UpdateWriter(ContentProviderDefinition contentProviderDefinition){
  this.contentProviderDefinition=contentProviderDefinition;
}

Fixed version (ground truth):
public UpdateWriter(ContentProviderDefinition contentProviderDefinition,ProcessorManager manager){
  this.contentProviderDefinition=contentProviderDefinition;
  this.manager=manager;
}
Program: 27077
Project: 27077
Buggy source:
@ContentUri(path=ENDPOINT + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str",type=ContentUri.ContentType.VND_SINGLE + ContentProviderModel.ENDPOINT,segments={@ContentUri.PathSegment(column="String_Node_Str",segment=1)}) public static Uri fromList(long id){
  return buildUri(ENDPOINT,"String_Node_Str",String.valueOf(id));
}

Fixed version (ground truth):
@ContentUri(path=ENDPOINT + "String_Node_Str",type=ContentUri.ContentType.VND_SINGLE + ContentProviderModel.ENDPOINT,segments={@ContentUri.PathSegment(column="String_Node_Str",segment=2)}) public static Uri fromList(long id){
  return buildUri(ENDPOINT,"String_Node_Str",String.valueOf(id));
}
Program: 27079
Project: 27079
Buggy source:
public void testSelectStatement(){
  Where<TestModel1> where=new Select("String_Node_Str").from(TestModel1.class).where(Condition.column("String_Node_Str").is("String_Node_Str"));
  assertEquals("String_Node_Str",where.getQuery().trim());
  where.query();
  Where<TestModel3> where1=new Select("String_Node_Str","String_Node_Str").from(TestModel3.class).where(Condition.column("String_Node_Str").is("String_Node_Str"),Condition.column("String_Node_Str").is("String_Node_Str"));
  assertEquals("String_Node_Str",where1.getQuery().trim());
  Where<TestModel3> where2=new Select().distinct().from(TestModel3.class).where();
  assertEquals("String_Node_Str",where2.getQuery().trim());
  where2.query();
  Where<TestModel3> where3=new Select().count().from(TestModel3.class).where();
  assertEquals("String_Node_Str",where3.getQuery().trim());
  where3.query();
}

Fixed version (ground truth):
public void testSelectStatement(){
  Where<TestModel1> where=new Select("String_Node_Str").from(TestModel1.class).where(Condition.column("String_Node_Str").is("String_Node_Str"));
  assertEquals("String_Node_Str",where.getQuery().trim());
  where.query();
  Where<TestModel3> where1=new Select("String_Node_Str","String_Node_Str").from(TestModel3.class).where(Condition.column("String_Node_Str").is("String_Node_Str"),Condition.column("String_Node_Str").is("String_Node_Str"));
  assertEquals("String_Node_Str",where1.getQuery().trim());
  Where<TestModel3> where2=new Select().distinct().from(TestModel3.class).where();
  assertEquals("String_Node_Str",where2.getQuery().trim());
  where2.query();
  Where<TestModel3> where3=new Select().count().from(TestModel3.class).where();
  assertEquals("String_Node_Str",where3.getQuery().trim());
  where3.query();
  Where<TestModel3> where4=new Select().from(TestModel3.class).where("String_Node_Str","String_Node_Str").and(Condition.column(TestModel3$Table.TYPE).is("String_Node_Str"));
  assertEquals("String_Node_Str",where4.getQuery().trim());
}
Program: 27080
Project: 27080
Buggy source:
/** 
 * Sets the last condition to use the separator specified
 * @param separator AND, OR, etc.
 */
protected void setPreviousSeparator(String separator){
  if (mParams.size() > 0) {
    mParams.get(mParams.size() - 1).separator(separator);
  }
}

Fixed version (ground truth):
/** 
 * Sets the last condition to use the separator specified
 * @param separator AND, OR, etc.
 */
protected void setPreviousSeparator(String separator){
  if (mParams.size() > 0) {
    mParams.get(mParams.size() - 1).separator(separator);
  }
 else   if (mWhereRaw != null && mWhereRaw.length() > 0) {
    mWhereRaw=new QueryBuilder<>(mWhereRaw).appendSpaceSeparated(separator).getQuery();
  }
}
Program: 27081
Project: 27081
Buggy source:
/** 
 * Adds a param to the WHERE clause with the custom   {@link com.raizlabs.android.dbflow.sql.builder.Condition}
 * @param condition The {@link com.raizlabs.android.dbflow.sql.builder.Condition} to use
 * @return
 */
public Where<ModelClass> and(Condition condition){
  mConditionQueryBuilder.putCondition(condition);
  return this;
}

Fixed version (ground truth):
/** 
 * Adds a param to the WHERE clause with the custom   {@link com.raizlabs.android.dbflow.sql.builder.Condition}
 * @param condition The {@link com.raizlabs.android.dbflow.sql.builder.Condition} to use
 * @return
 */
public Where<ModelClass> and(Condition condition){
  mConditionQueryBuilder.and(condition);
  return this;
}
Program: 27082
Project: 27082
Buggy source:
/** 
 * Specifies a set of content values to append to this SET as Conditions
 * @param contentValues The set of values to append.
 * @return This instance.
 */
public Set<ModelClass> conditionValues(ContentValues contentValues){
  java.util.Set<String> contentKeys=contentValues.keySet();
  for (  String key : contentKeys) {
    mConditionQueryBuilder.putCondition(Condition.columnRaw(key).is(contentValues.get(key)));
  }
  return this;
}

Fixed version (ground truth):
/** 
 * Specifies a set of content values to append to this SET as Conditions
 * @param contentValues The set of values to append.
 * @return This instance.
 */
public Set<ModelClass> conditionValues(ContentValues contentValues){
  java.util.Set<String> contentKeys=contentValues.keySet();
  for (  String key : contentKeys) {
    mConditionQueryBuilder.putCondition(Condition.column(key).is(contentValues.get(key)));
  }
  return this;
}
Program: 27083
Project: 27083
Buggy source:
protected ModelAdapter getModelAdapter(){
  return mModelAdapter;
}

Fixed version (ground truth):
public ModelAdapter getModelAdapter(){
  return mModelAdapter;
}
Program: 27084
Project: 27084
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public void load(ConditionQueryBuilder<TableClass> whereConditions,String orderBy,String... columns){
  Cursor cursor=ContentUtils.query(FlowManager.getContext().getContentResolver(),getQueryUri(),(Class<TableClass>)getClass(),whereConditions,orderBy,columns);
  getModelAdapter().loadFromCursor(cursor,this);
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public void load(){
  load(getModelAdapter().getPrimaryModelWhere(this),"String_Node_Str");
}
Program: 27085
Project: 27085
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public void load(ConditionQueryBuilder<TableClass> whereConditions,String orderBy,String... columns){
  Cursor cursor=ContentUtils.query(FlowManager.getContext().getContentResolver(),getQueryUri(),(Class<TableClass>)getClass(),whereConditions,orderBy,columns);
  getModelAdapter().loadFromCursor(cursor,this);
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public void load(){
  load(getModelAdapter().getPrimaryModelWhere(this),"String_Node_Str");
}
Program: 27086
Project: 27086
Buggy source:
/** 
 * Queries the   {@link android.content.ContentResolver} of the app based on the passed parameters andpopulates this object with the first row from the returned data.
 * @param whereConditions The set of {@link com.raizlabs.android.dbflow.sql.builder.Condition} to filter the query by.
 * @param orderBy         The order by without the ORDER BY
 * @param columns         The list of columns to select. Leave blank for 
 */
public void load(ConditionQueryBuilder<TableClass> whereConditions,String orderBy,String... columns);

Fixed version (ground truth):
/** 
 * Queries the   {@link android.content.ContentResolver} of the app based on the primary keys of the object and populatesthis object with the first row from the returned data.
 */
public void load();
Program: 27087
Project: 27087
Buggy source:
/** 
 * Replaces a query string with the specified params as part of this query. Note: appending any extra condition will invalidate this statement.
 * @param selection     The string query to select with ? bindings
 * @param selectionArgs The arguments that correspond to it. Will be type-converted into proper string values.
 * @return This builder.
 */
public ConditionQueryBuilder<ModelClass> append(String selection,Object... selectionArgs){
  String toAppend=selection;
  if (selection != null && selectionArgs != null) {
    for (    Object o : selectionArgs) {
      toAppend=toAppend.replaceFirst("String_Node_Str",convertValueToString(o));
    }
  }
  mWhereRaw=toAppend;
  return super.append(toAppend);
}

Fixed version (ground truth):
/** 
 * Replaces a query string with the specified params as part of this query. Note: appending any extra condition will invalidate this statement.
 * @param selection     The string query to select with ? bindings
 * @param selectionArgs The arguments that correspond to it. Will be type-converted into proper string values.
 * @return This builder.
 */
public ConditionQueryBuilder<ModelClass> append(String selection,Object... selectionArgs){
  if (selection != null) {
    String toAppend=selection;
    if (selectionArgs != null) {
      for (      Object o : selectionArgs) {
        toAppend=toAppend.replaceFirst("String_Node_Str",convertValueToString(o));
      }
    }
    mWhereRaw=toAppend;
    return super.append(toAppend);
  }
 else {
    return this;
  }
}
Program: 27088
Project: 27088
Buggy source:
/** 
 * Executes a SQL statement that retrieves the count of results in the DB.
 * @return The number of rows this query returns
 */
public long count(){
  long count;
  if (mWhereBase.getQueryBuilderBase() instanceof Update || mWhereBase.getQueryBuilderBase() instanceof Delete) {
    SQLiteStatement sqLiteStatement=mManager.getWritableDatabase().compileStatement(getQuery());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      count=sqLiteStatement.executeUpdateDelete();
    }
 else {
      count=sqLiteStatement.executeUpdateDelete();
    }
  }
 else {
    count=DatabaseUtils.longForQuery(mManager.getWritableDatabase(),getQuery(),null);
  }
  return count;
}

Fixed version (ground truth):
/** 
 * Executes a SQL statement that retrieves the count of results in the DB.
 * @return The number of rows this query returns
 */
public long count(){
  long count;
  if (((mWhereBase.getQueryBuilderBase() instanceof From) && (((From)mWhereBase.getQueryBuilderBase()).getQueryBuilderBase()) instanceof Update) || mWhereBase.getQueryBuilderBase() instanceof Delete) {
    SQLiteStatement sqLiteStatement=mManager.getWritableDatabase().compileStatement(getQuery());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      count=sqLiteStatement.executeUpdateDelete();
    }
 else {
      count=sqLiteStatement.executeUpdateDelete();
    }
  }
 else {
    count=DatabaseUtils.longForQuery(mManager.getWritableDatabase(),getQuery(),null);
  }
  return count;
}
Program: 27089
Project: 27089
Buggy source:
@Override public void update(boolean async){
  ContentUtils.update(getUpdateUri(),this);
}

Fixed version (ground truth):
@Override public void update(boolean async){
  int count=ContentUtils.update(getUpdateUri(),this);
  if (count == 0) {
    FlowLog.log(FlowLog.Level.W,"String_Node_Str" + getClass());
  }
}
Program: 27090
Project: 27090
Buggy source:
/** 
 * Updates the model through the   {@link android.content.ContentResolver}. Uses the updateUri to resolve the reference and the model to convert its data in   {@link android.content.ContentValues}
 * @param contentResolver The content resolver to use (if different from {@link com.raizlabs.android.dbflow.config.FlowManager#getContext()})
 * @param updateUri       A {@link android.net.Uri} from the {@link com.raizlabs.android.dbflow.annotation.provider.ContentProvider}
 * @param model           The model to update
 * @param < TableClass >    The class that implements {@link com.raizlabs.android.dbflow.structure.Model}
 * @return The number of rows updated.
 */
@SuppressWarnings("String_Node_Str") public static <TableClass extends Model>int update(ContentResolver contentResolver,Uri updateUri,TableClass model){
  ModelAdapter<TableClass> adapter=(ModelAdapter<TableClass>)FlowManager.getModelAdapter(model.getClass());
  checkModel(model,adapter);
  ContentValues contentValues=new ContentValues();
  adapter.bindToContentValues(contentValues,model);
  return contentResolver.update(updateUri,contentValues,null,null);
}

Fixed version (ground truth):
/** 
 * Updates the model through the   {@link android.content.ContentResolver}. Uses the updateUri to resolve the reference and the model to convert its data in   {@link android.content.ContentValues}
 * @param contentResolver The content resolver to use (if different from {@link com.raizlabs.android.dbflow.config.FlowManager#getContext()})
 * @param updateUri       A {@link android.net.Uri} from the {@link com.raizlabs.android.dbflow.annotation.provider.ContentProvider}
 * @param model           The model to update
 * @param < TableClass >    The class that implements {@link com.raizlabs.android.dbflow.structure.Model}
 * @return The number of rows updated.
 */
@SuppressWarnings("String_Node_Str") public static <TableClass extends Model>int update(ContentResolver contentResolver,Uri updateUri,TableClass model){
  ModelAdapter<TableClass> adapter=(ModelAdapter<TableClass>)FlowManager.getModelAdapter(model.getClass());
  checkModel(model,adapter);
  ContentValues contentValues=new ContentValues();
  adapter.bindToContentValues(contentValues,model);
  return contentResolver.update(updateUri,contentValues,adapter.getPrimaryModelWhere(model).getQuery(),null);
}
Program: 27091
Project: 27091
Buggy source:
@Override public Long getDBValue(Calendar model){
  return model.getTimeInMillis();
}

Fixed version (ground truth):
@Override public Long getDBValue(Calendar model){
  return model == null ? null : model.getTimeInMillis();
}
Program: 27092
Project: 27092
Buggy source:
@Override public Calendar getModelValue(Long data){
  Calendar calendar=Calendar.getInstance();
  calendar.setTimeInMillis(data);
  return calendar;
}

Fixed version (ground truth):
@Override public Calendar getModelValue(Long data){
  if (data != null) {
    Calendar calendar=Calendar.getInstance();
    calendar.setTimeInMillis(data);
    return calendar;
  }
 else {
    return null;
  }
}
Program: 27093
Project: 27093
Buggy source:
@Override public Long getDBValue(Date model){
  return model.getTime();
}

Fixed version (ground truth):
@Override public Long getDBValue(Date model){
  return model == null ? null : model.getTime();
}
Program: 27094
Project: 27094
Buggy source:
@Override public Date getModelValue(Long data){
  return new Date(data);
}

Fixed version (ground truth):
@Override public Date getModelValue(Long data){
  return data == null ? null : new Date(data);
}
Program: 27095
Project: 27095
Buggy source:
@Override public Long getDBValue(Date model){
  return model.getTime();
}

Fixed version (ground truth):
@Override public Long getDBValue(Date model){
  return model == null ? null : model.getTime();
}
Program: 27096
Project: 27096
Buggy source:
@Override public Date getModelValue(Long data){
  return new Date(data);
}

Fixed version (ground truth):
@Override public Date getModelValue(Long data){
  return data == null ? null : new Date(data);
}
Program: 27097
Project: 27097
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public String getQuery(){
  return new QueryBuilder("String_Node_Str").append(isUnique ? "String_Node_Str" : "String_Node_Str").append("String_Node_Str").appendQuoted(mIndex).append("String_Node_Str").appendQuoted(FlowManager.getTableName(mTable)).append("String_Node_Str").appendList(mColumns).append("String_Node_Str").getQuery();
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public String getQuery(){
  return new QueryBuilder("String_Node_Str").append(isUnique ? "String_Node_Str" : "String_Node_Str").append("String_Node_Str").appendQuoted(mIndex).append("String_Node_Str").appendQuoted(FlowManager.getTableName(mTable)).append("String_Node_Str").appendQuotedList(mColumns).append("String_Node_Str").getQuery();
}
Program: 27098
Project: 27098
Buggy source:
/** 
 * Adds a column to the underlying INDEX
 * @param columnName The name of the column to add to the Index
 * @return This migration
 */
public IndexMigration<ModelClass> addColumn(String columnName){
  mIndex.and(columnName);
  return this;
}

Fixed version (ground truth):
/** 
 * Adds a column to the underlying INDEX
 * @param columnName The name of the column to add to the Index
 * @return This migration
 */
public IndexMigration<ModelClass> addColumn(String columnName){
  getIndex().and(columnName);
  return this;
}
Program: 27099
Project: 27099
Buggy source:
/** 
 * @return The index object based on the contents of this migration.
 */
public Index<ModelClass> getIndex(){
  return mIndex;
}

Fixed version (ground truth):
/** 
 * @return The index object based on the contents of this migration.
 */
public Index<ModelClass> getIndex(){
  if (mIndex == null) {
    mIndex=new Index<ModelClass>(mName).on(mOnTable);
  }
  return mIndex;
}
Program: 27100
Project: 27100
Buggy source:
/** 
 * Sets the INDEX to UNIQUE
 * @return This migration.
 */
public IndexMigration<ModelClass> unique(){
  mIndex.unique(true);
  return this;
}

Fixed version (ground truth):
/** 
 * Sets the INDEX to UNIQUE
 * @return This migration.
 */
public IndexMigration<ModelClass> unique(){
  getIndex().unique(true);
  return this;
}
Program: 27101
Project: 27101
Buggy source:
@Override public void onPreMigrate(){
  super.onPreMigrate();
  mIndex=new Index<ModelClass>(mName).on(mOnTable);
}

Fixed version (ground truth):
@Override public void onPreMigrate(){
  super.onPreMigrate();
  mIndex=getIndex();
}
Program: 27102
Project: 27102
Buggy source:
@Override public void write(JavaWriter javaWriter) throws IOException {
  ColumnDefinition columnDefinition=((TableDefinition)tableDefinition).autoIncrementDefinition;
  AdapterQueryBuilder queryBuilder=new AdapterQueryBuilder().append(ModelUtils.getVariable(isModelContainerDefinition));
  if (!isModelContainerDefinition) {
    queryBuilder.append("String_Node_Str").append(columnDefinition.columnFieldName).append("String_Node_Str").appendCast(columnDefinition.columnFieldType).append(params[3]).append("String_Node_Str");
  }
 else {
    queryBuilder.appendPut(columnDefinition.columnFieldName).append(params[3]).append("String_Node_Str");
  }
  javaWriter.emitStatement(queryBuilder.getQuery());
}

Fixed version (ground truth):
@Override public void write(JavaWriter javaWriter) throws IOException {
  ColumnDefinition columnDefinition=((TableDefinition)tableDefinition).autoIncrementDefinition;
  AdapterQueryBuilder queryBuilder=new AdapterQueryBuilder().append(ModelUtils.getVariable(isModelContainerDefinition));
  if (!isModelContainerDefinition) {
    queryBuilder.append("String_Node_Str").append(columnDefinition.columnFieldName).append("String_Node_Str").appendCast(columnDefinition.columnFieldType).append(params[3]).append("String_Node_Str");
  }
 else {
    String containerKeyName=columnDefinition.columnFieldName;
    if (columnDefinition.containerKeyName != null) {
      containerKeyName=columnDefinition.containerKeyName;
    }
    queryBuilder.appendPut(containerKeyName).append(params[3]).append("String_Node_Str");
  }
  javaWriter.emitStatement(queryBuilder.getQuery());
}
Program: 27104
Project: 27104
Buggy source:
public void appendForeignKeys(ForeignKeyReference[] references){
  QueryBuilder queryBuilder;
  List<QueryBuilder> queryBuilders=new ArrayList<QueryBuilder>();
  for (  ForeignKeyReference foreignKeyReference : references) {
    queryBuilder=new QueryBuilder().append(foreignKeyReference.columnName()).appendSpace().appendType(ModelUtils.getClassFromAnnotation(foreignKeyReference));
    queryBuilders.add(queryBuilder);
  }
  appendList(queryBuilders);
}

Fixed version (ground truth):
public void appendForeignKeys(ForeignKeyReference[] references){
  QueryBuilder queryBuilder;
  List<QueryBuilder> queryBuilders=new ArrayList<QueryBuilder>();
  for (  ForeignKeyReference foreignKeyReference : references) {
    queryBuilder=new QueryBuilder().appendQuoted(foreignKeyReference.columnName()).appendSpace().appendType(ModelUtils.getClassFromAnnotation(foreignKeyReference));
    queryBuilders.add(queryBuilder);
  }
  appendList(queryBuilders);
}
Program: 27106
Project: 27106
Buggy source:
public void testInOperators(){
  Condition.In in=Condition.column(ConditionModel$Table.NAME).in("String_Node_Str").and("String_Node_Str").and("String_Node_Str");
  ConditionQueryBuilder<ConditionModel> conditionQueryBuilder=new ConditionQueryBuilder<>(ConditionModel.class,in);
  assertEquals(conditionQueryBuilder.getQuery().trim(),"String_Node_Str");
  Condition.In notIn=Condition.column(ConditionModel$Table.NAME).notIn("String_Node_Str").and("String_Node_Str").and("String_Node_Str");
  conditionQueryBuilder=new ConditionQueryBuilder<>(ConditionModel.class,notIn);
  assertEquals(conditionQueryBuilder.getQuery().trim(),"String_Node_Str");
}

Fixed version (ground truth):
public void testInOperators(){
  Condition.In in=Condition.column(ConditionModel$Table.NAME).in("String_Node_Str").and("String_Node_Str").and("String_Node_Str");
  ConditionQueryBuilder<ConditionModel> conditionQueryBuilder=new ConditionQueryBuilder<>(ConditionModel.class,in);
  assertEquals("String_Node_Str",conditionQueryBuilder.getQuery().trim());
  Condition.In notIn=Condition.column(ConditionModel$Table.NAME).notIn("String_Node_Str").and("String_Node_Str").and("String_Node_Str");
  conditionQueryBuilder=new ConditionQueryBuilder<>(ConditionModel.class,notIn);
  assertEquals("String_Node_Str",conditionQueryBuilder.getQuery().trim());
}
Program: 27107
Project: 27107
Buggy source:
public void testMigration(){
  List<String> columnNames=Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  AlterTableMigration<MigrationModel> renameMigration=new AlterTableMigration<>(MigrationModel.class).renameFrom("String_Node_Str");
  renameMigration.onPreMigrate();
  assertEquals("String_Node_Str",renameMigration.getRenameQuery());
  renameMigration.onPostMigrate();
  AlterTableMigration<MigrationModel> alterTableMigration=new AlterTableMigration<>(MigrationModel.class);
  alterTableMigration.addColumn(float.class,"String_Node_Str").addColumn(long.class,"String_Node_Str").addColumn(String.class,"String_Node_Str").addColumn(int.class,"String_Node_Str").addColumn(byte[].class,"String_Node_Str");
  alterTableMigration.onPreMigrate();
  List<String> columnDefinitions=alterTableMigration.getColumnDefinitions();
  for (int i=0; i < columnDefinitions.size(); i++) {
    assertEquals("String_Node_Str" + columnNames.get(i),columnDefinitions.get(i));
  }
  alterTableMigration.migrate(FlowManager.getDatabaseForTable(MigrationModel.class).getWritableDatabase());
  Cursor cursor=new Select().from(MigrationModel.class).where().query();
  String[] columns=cursor.getColumnNames();
  assertTrue(columns.length == columnNames.size() + 2);
  for (int i=0; i < columnNames.size(); i++) {
    assertTrue(cursor.getColumnIndex(columnNames.get(i).split("String_Node_Str")[0]) != -1);
  }
  alterTableMigration.onPostMigrate();
}

Fixed version (ground truth):
public void testMigration(){
  List<String> columnNames=Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  List<String> columns=Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  AlterTableMigration<MigrationModel> renameMigration=new AlterTableMigration<>(MigrationModel.class).renameFrom("String_Node_Str");
  renameMigration.onPreMigrate();
  assertEquals("String_Node_Str",renameMigration.getRenameQuery());
  renameMigration.onPostMigrate();
  AlterTableMigration<MigrationModel> alterTableMigration=new AlterTableMigration<>(MigrationModel.class);
  alterTableMigration.addColumn(float.class,"String_Node_Str").addColumn(long.class,"String_Node_Str").addColumn(String.class,"String_Node_Str").addColumn(int.class,"String_Node_Str").addColumn(byte[].class,"String_Node_Str");
  alterTableMigration.onPreMigrate();
  List<String> columnDefinitions=alterTableMigration.getColumnDefinitions();
  for (int i=0; i < columnDefinitions.size(); i++) {
    assertEquals("String_Node_Str" + columnNames.get(i),columnDefinitions.get(i));
  }
  alterTableMigration.migrate(FlowManager.getDatabaseForTable(MigrationModel.class).getWritableDatabase());
  Cursor cursor=new Select().from(MigrationModel.class).where().query();
  assertTrue(cursor.getColumnNames().length == columnNames.size() + 2);
  for (int i=0; i < columns.size(); i++) {
    assertTrue(cursor.getColumnIndex(columns.get(i)) != -1);
  }
  alterTableMigration.onPostMigrate();
}
Program: 27108
Project: 27108
Buggy source:
public void testPrimaryWhereQuery(){
  ConditionQueryBuilder<TestPrimaryWhere> primaryWhere=FlowManager.getPrimaryWhereQuery(TestPrimaryWhere.class);
  assertEquals(primaryWhere.getQuery(),"String_Node_Str");
}

Fixed version (ground truth):
public void testPrimaryWhereQuery(){
  ConditionQueryBuilder<TestPrimaryWhere> primaryWhere=FlowManager.getPrimaryWhereQuery(TestPrimaryWhere.class);
  assertEquals("String_Node_Str",primaryWhere.getQuery());
}
Program: 27109
Project: 27109
Buggy source:
public void setTestModel1(TestModel1 model1){
  testModel1=new ForeignKeyContainer<TestModel1>(TestModel1.class);
  Map<String,Object> map=new HashMap<>();
  map.put(TestModel1$Table.NAME,model1.name);
  testModel1.setData(map);
}

Fixed version (ground truth):
public void setTestModel1(TestModel1 model1){
  testModel1=new ForeignKeyContainer<>(TestModel1.class);
  Map<String,Object> map=new HashMap<>();
  map.put(TestModel1$Table.NAME,model1.name);
  testModel1.setData(map);
}
Program: 27110
Project: 27110
Buggy source:
public void testForeignKeyModel(){
  ForeignInteractionModel foreignInteractionModel=new ForeignInteractionModel();
}

Fixed version (ground truth):
public void testForeignKeyModel(){
  Delete.tables(ForeignInteractionModel.class,TestModel1.class);
  ForeignInteractionModel foreignInteractionModel=new ForeignInteractionModel();
  TestModel1 testModel1=new TestModel1();
  testModel1.name="String_Node_Str";
  foreignInteractionModel.setTestModel1(testModel1);
  foreignInteractionModel.name="String_Node_Str";
  foreignInteractionModel.save(false);
  assertTrue(foreignInteractionModel.exists());
  assertTrue(foreignInteractionModel.testModel1.exists());
  Delete.tables(TestModel1.class,ForeignInteractionModel.class);
}
Program: 27111
Project: 27111
Buggy source:
/** 
 * Sets the data for this container
 * @param data The data object that backs this container
 */
@Override public void setData(DataClass data){
  mData=data;
}

Fixed version (ground truth):
/** 
 * Sets the data for this container
 * @param data The data object that backs this container
 */
@Override public void setData(DataClass data){
  mData=data;
  mModel=null;
}
Program: 27112
Project: 27112
Buggy source:
public BaseModelContainer(Class<ModelClass> table,DataClass data){
  mModelAdapter=FlowManager.getModelAdapter(table);
  mContainerAdapter=FlowManager.getContainerAdapter(table);
  mData=data;
  if (mContainerAdapter == null) {
    throw new InvalidDBConfiguration("String_Node_Str" + FlowManager.getTableName(table) + "String_Node_Str"+ "String_Node_Str");
  }
}

Fixed version (ground truth):
public BaseModelContainer(Class<ModelClass> table,DataClass data){
  this(table);
  mData=data;
}
Program: 27113
Project: 27113
Buggy source:
public void testForeignKeyModel(){
  Delete.tables(ForeignInteractionModel.class,TestModel1.class);
  ForeignInteractionModel foreignInteractionModel=new ForeignInteractionModel();
  TestModel1 testModel1=new TestModel1();
  testModel1.name="String_Node_Str";
  foreignInteractionModel.setTestModel1(testModel1);
  foreignInteractionModel.name="String_Node_Str";
  foreignInteractionModel.save(false);
  assertTrue(foreignInteractionModel.exists());
  assertTrue(foreignInteractionModel.testModel1.exists());
  Delete.tables(TestModel1.class,ForeignInteractionModel.class);
}

Fixed version (ground truth):
public void testForeignKeyModel(){
  Delete.tables(TestModel1.class,ForeignInteractionModel.class);
  ForeignInteractionModel foreignInteractionModel=new ForeignInteractionModel();
  TestModel1 testModel1=new TestModel1();
  testModel1.name="String_Node_Str";
  testModel1.save(false);
  foreignInteractionModel.setTestModel1(testModel1);
  foreignInteractionModel.name="String_Node_Str";
  foreignInteractionModel.save(false);
  assertTrue(foreignInteractionModel.exists());
  assertTrue(foreignInteractionModel.testModel1.exists());
  foreignInteractionModel=Select.byId(ForeignInteractionModel.class,"String_Node_Str");
  assertNotNull(foreignInteractionModel);
  assertNotNull(foreignInteractionModel.testModel1);
  TestModel1 testModel11=foreignInteractionModel.getTestModel1();
  assertNotNull(testModel1);
  assertEquals("String_Node_Str",testModel11.name);
  Delete.tables(TestModel1.class,ForeignInteractionModel.class);
}
Program: 27114
Project: 27114
Buggy source:
/** 
 * Syncs the model to the database depending on it's save mode.
 * @param async
 * @param model
 * @param contentValues
 * @param mode
 * @param < ModelClass >
 */
public static <ModelClass extends Model>void sync(boolean async,ModelClass model,ModelAdapter<ModelClass> modelAdapter,@SaveMode int mode){
  if (!async) {
    BaseDatabaseDefinition flowManager=FlowManager.getDatabaseForTable(model.getClass());
    final SQLiteDatabase db=flowManager.getWritableDatabase();
    boolean exists=false;
    BaseModel.Action action=BaseModel.Action.SAVE;
    if (mode == SAVE_MODE_DEFAULT) {
      exists=modelAdapter.exists(model);
    }
 else     if (mode == SAVE_MODE_UPDATE) {
      exists=true;
      action=BaseModel.Action.UPDATE;
    }
 else {
      action=BaseModel.Action.INSERT;
    }
    if (exists) {
      exists=update(false,model,modelAdapter);
    }
    if (!exists) {
      insert(false,model,modelAdapter);
    }
    notifyModelChanged(model.getClass(),action);
  }
 else {
    TransactionManager.getInstance().save(ProcessModelInfo.withModels(model).info(DBTransactionInfo.createSave()));
  }
}

Fixed version (ground truth):
/** 
 * Syncs the model to the database depending on it's save mode.
 * @param async
 * @param model
 * @param contentValues
 * @param mode
 * @param < ModelClass >
 */
public static <ModelClass extends Model>void sync(boolean async,ModelClass model,ModelAdapter<ModelClass> modelAdapter,@SaveMode int mode){
  if (!async) {
    if (model == null) {
      throw new IllegalArgumentException("String_Node_Str" + modelAdapter.getModelClass() + "String_Node_Str");
    }
    BaseDatabaseDefinition flowManager=FlowManager.getDatabaseForTable(model.getClass());
    final SQLiteDatabase db=flowManager.getWritableDatabase();
    boolean exists=false;
    BaseModel.Action action=BaseModel.Action.SAVE;
    if (mode == SAVE_MODE_DEFAULT) {
      exists=modelAdapter.exists(model);
    }
 else     if (mode == SAVE_MODE_UPDATE) {
      exists=true;
      action=BaseModel.Action.UPDATE;
    }
 else {
      action=BaseModel.Action.INSERT;
    }
    if (exists) {
      exists=update(false,model,modelAdapter);
    }
    if (!exists) {
      insert(false,model,modelAdapter);
    }
    notifyModelChanged(model.getClass(),action);
  }
 else {
    TransactionManager.getInstance().save(ProcessModelInfo.withModels(model).info(DBTransactionInfo.createSave()));
  }
}
Program: 27115
Project: 27115
Buggy source:
public void testContentObserver(){
  FlowContentObserver flowContentObserver=new FlowContentObserver();
  flowContentObserver.registerForContentChanges(getContext(),TestModel1.class);
  final Boolean[] methodcalled={false,false,false,false};
  FlowContentObserver.ModelChangeListener modelChangeListener=new FlowContentObserver.ModelChangeListener(){
    @Override public void onModelChanged(){
      for (int i=0; i < methodcalled.length; i++) {
        methodcalled[i]=true;
      }
    }
    @Override public void onModelSaved(){
      methodcalled[0]=true;
    }
    @Override public void onModelDeleted(){
      methodcalled[1]=true;
    }
    @Override public void onModelInserted(){
      methodcalled[2]=true;
    }
    @Override public void onModelUpdated(){
      methodcalled[3]=true;
    }
  }
;
  flowContentObserver.addModelChangeListener(modelChangeListener);
  TestModel1 testModel1=new TestModel1();
  testModel1.name="String_Node_Str";
  testModel1.insert(false);
  testModel1.update(false);
  testModel1.save(false);
  testModel1.delete(false);
  flowContentObserver.removeModelChangeListener(modelChangeListener);
  assertTrue(methodcalled[0]);
  assertTrue(methodcalled[1]);
  assertTrue(methodcalled[2]);
  assertTrue(methodcalled[3]);
  flowContentObserver.unregisterForContentChanges(getContext());
}

Fixed version (ground truth):
public void testContentObserver(){
  Delete.table(TestModel1.class);
  FlowContentObserver flowContentObserver=new FlowContentObserver();
  flowContentObserver.registerForContentChanges(getContext(),TestModel1.class);
  final Boolean[] methodcalled={false,false,false,false};
  FlowContentObserver.ModelChangeListener modelChangeListener=new FlowContentObserver.ModelChangeListener(){
    @Override public void onModelChanged(){
      for (int i=0; i < methodcalled.length; i++) {
        methodcalled[i]=true;
      }
    }
    @Override public void onModelSaved(){
      methodcalled[0]=true;
    }
    @Override public void onModelDeleted(){
      methodcalled[1]=true;
    }
    @Override public void onModelInserted(){
      methodcalled[2]=true;
    }
    @Override public void onModelUpdated(){
      methodcalled[3]=true;
    }
  }
;
  flowContentObserver.addModelChangeListener(modelChangeListener);
  TestModel1 testModel1=new TestModel1();
  testModel1.name="String_Node_Str";
  testModel1.insert(false);
  testModel1.update(false);
  testModel1.save(false);
  testModel1.delete(false);
  flowContentObserver.removeModelChangeListener(modelChangeListener);
  assertTrue(methodcalled[0]);
  assertTrue(methodcalled[1]);
  assertTrue(methodcalled[2]);
  assertTrue(methodcalled[3]);
  flowContentObserver.unregisterForContentChanges(getContext());
}
Program: 27116
Project: 27116
Buggy source:
public void testListeners(){
  ListenerModel listenerModel=new ListenerModel();
  listenerModel.name="String_Node_Str";
  final boolean[] called=new boolean[]{false,false,false};
  listenerModel.registerListeners(new SQLiteStatementListener(){
    @Override public void onBindToStatement(    SQLiteStatement sqLiteStatement){
      called[1]=true;
    }
  }
,new ContentValuesListener(){
    @Override public void onBindToContentValues(    ContentValues contentValues){
      called[2]=true;
    }
  }
);
  listenerModel.insert(false);
  listenerModel.update(false);
  ModelAdapter<ListenerModel> modelModelAdapter=FlowManager.getModelAdapter(ListenerModel.class);
  Cursor cursor=new Select().from(ListenerModel.class).where(Condition.column(ListenerModel$Table.NAME).is("String_Node_Str")).query();
  assertNotNull(cursor);
  modelModelAdapter.loadFromCursor(cursor,listenerModel);
  cursor.close();
  for (  boolean call : called) {
    assertTrue(call);
  }
}

Fixed version (ground truth):
public void testListeners(){
  Delete.table(ListenerModel.class);
  ListenerModel listenerModel=new ListenerModel();
  listenerModel.name="String_Node_Str";
  final boolean[] called=new boolean[]{false,false,false};
  listenerModel.registerListeners(new SQLiteStatementListener(){
    @Override public void onBindToStatement(    SQLiteStatement sqLiteStatement){
      called[1]=true;
    }
  }
,new ContentValuesListener(){
    @Override public void onBindToContentValues(    ContentValues contentValues){
      called[2]=true;
    }
  }
);
  listenerModel.registerLoadFromCursorListener(new LoadFromCursorListener(){
    @Override public void onLoadFromCursor(    Cursor cursor){
      called[0]=true;
    }
  }
);
  listenerModel.insert(false);
  listenerModel.update(false);
  ModelAdapter<ListenerModel> modelModelAdapter=FlowManager.getModelAdapter(ListenerModel.class);
  Cursor cursor=new Select().from(ListenerModel.class).where(Condition.column(ListenerModel$Table.NAME).is("String_Node_Str")).query();
  assertNotNull(cursor);
  assertTrue(cursor.moveToFirst());
  modelModelAdapter.loadFromCursor(cursor,listenerModel);
  listenerModel.delete(false);
  cursor.close();
  for (  boolean call : called) {
    assertTrue(call);
  }
}
Program: 27117
Project: 27117
Buggy source:
/** 
 * Called when the model has been inserted. This is only available to   {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public void onModelInserted();

Fixed version (ground truth):
@Override public void onModelInserted(){
  onModelStateChanged();
}
Program: 27118
Project: 27118
Buggy source:
/** 
 * Called when the model has changed. This is only called in versions below   {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}.
 */
public void onModelChanged();

Fixed version (ground truth):
@Override public void onModelChanged(){
  onModelStateChanged();
}
Program: 27119
Project: 27119
Buggy source:
/** 
 * Called when the model has been saved. This is only available to   {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public void onModelSaved();

Fixed version (ground truth):
@Override public void onModelSaved(){
  onModelStateChanged();
}
Program: 27120
Project: 27120
Buggy source:
/** 
 * Called when the model has been updated. This is only available to   {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public void onModelUpdated();

Fixed version (ground truth):
@Override public void onModelUpdated(){
  onModelStateChanged();
}
Program: 27121
Project: 27121
Buggy source:
/** 
 * Called when model has been deleted. This is only available to   {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public void onModelDeleted();

Fixed version (ground truth):
@Override public void onModelDeleted(){
  onModelStateChanged();
}