Program: 141996
Project: 141996
Buggy source:
@Test public void testDbWriteAndUpdate(){
  HybridFileBackedSqlStorageMock.alwaysPutInDatabase();
  UnencryptedHybridFileBackedSqlStorageMock.alwaysPutInDatabase();
  UnencryptedHybridFileBackedSqlStorage<FormInstance> appFixtureStorage=CommCareApplication.instance().getCurrentApp().getFileBackedStorage("String_Node_Str",FormInstance.class);
  FormInstance appLevelFixture=appFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  appLevelFixture.setID(-1);
  appLevelFixture.initialize(null,"String_Node_Str");
  appFixtureStorage.write(appLevelFixture);
  appFixtureStorage.read(appLevelFixture.getID());
  String newName="String_Node_Str";
  appLevelFixture.setName(newName);
  appFixtureStorage.update(appLevelFixture.getID(),appLevelFixture);
  appLevelFixture=appFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertEquals(newName,appLevelFixture.getName());
  HybridFileBackedSqlStorage<FormInstance> userFixtureStorage=CommCareApplication.instance().getFileBackedUserStorage("String_Node_Str",FormInstance.class);
  FormInstance userLevelFixture=userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  userLevelFixture.setID(-1);
  userLevelFixture.initialize(null,"String_Node_Str");
  userFixtureStorage.write(userLevelFixture);
  userFixtureStorage.read(userLevelFixture.getID());
  userLevelFixture.setName(newName);
  userFixtureStorage.update(userLevelFixture.getID(),userLevelFixture);
  userLevelFixture=userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertEquals(newName,userLevelFixture.getName());
}

Fixed version (ground truth):
@Test public void testDbWriteAndUpdate(){
  HybridFileBackedSqlStorageMock.alwaysPutInDatabase();
  UnencryptedHybridFileBackedSqlStorageMock.alwaysPutInDatabase();
  UnencryptedHybridFileBackedSqlStorage<FormInstance> appFixtureStorage=CommCareApplication.instance().getCurrentApp().getFileBackedStorage("String_Node_Str",FormInstance.class);
  FormInstance appLevelFixture=appFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  appLevelFixture.setID(-1);
  appLevelFixture.initialize(null,"String_Node_Str");
  appFixtureStorage.write(appLevelFixture);
  appFixtureStorage.read(appLevelFixture.getID());
  String newName="String_Node_Str";
  appLevelFixture.setName(newName);
  appFixtureStorage.update(appLevelFixture.getID(),appLevelFixture);
  appLevelFixture=appFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertEquals(newName,appLevelFixture.getName());
  HybridFileBackedSqlStorage<FormInstance> userFixtureStorage=CommCareApplication.instance().getFileBackedUserStorage(HybridFileBackedSqlStorage.FIXTURE_STORAGE_TABLE_NAME,FormInstance.class);
  FormInstance userLevelFixture=userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  userLevelFixture.setID(-1);
  userLevelFixture.initialize(null,"String_Node_Str");
  userFixtureStorage.write(userLevelFixture);
  userFixtureStorage.read(userLevelFixture.getID());
  userLevelFixture.setName(newName);
  userFixtureStorage.update(userLevelFixture.getID(),userLevelFixture);
  userLevelFixture=userFixtureStorage.getRecordForValues(new String[]{FormInstance.META_ID},new String[]{"String_Node_Str"});
  Assert.assertEquals(newName,userLevelFixture.getName());
}