Program: 189669
Project: 189669
Buggy source:
@Test public void integration() throws Exception {
  LocationAttributeType codeAttrType=MetadataUtils.getLocationAttributeType(CommonMetadata._LocationAttributeType.MASTER_FACILITY_CODE);
  ObjectSource<Location> source1=new LocationMflCsvSource("String_Node_Str",codeAttrType);
  AbstractSynchronization synchronization1=new LocationMflSynchronization(source1);
  synchronization1.run();
  Assert.assertThat(synchronization1.getCreatedObjects(),hasSize(3));
  Assert.assertThat(synchronization1.getUpdatedObjects(),hasSize(0));
  Assert.assertThat(synchronization1.getRetiredObjects(),hasSize(0));
  Location modified=locationService.getLocation("String_Node_Str");
  modified.setName("String_Node_Str");
  locationService.saveLocation(modified);
  ObjectSource<Location> source2=new LocationMflCsvSource("String_Node_Str",codeAttrType);
  AbstractSynchronization synchronization2=new LocationMflSynchronization(source2);
  synchronization2.run();
  Assert.assertThat(locationService.getLocation("String_Node_Str"),notNullValue());
  Assert.assertThat(synchronization2.getCreatedObjects(),hasSize(0));
  Assert.assertThat(synchronization2.getUpdatedObjects(),hasSize(1));
  Assert.assertThat(synchronization2.getRetiredObjects(),hasSize(0));
  Location invalid=locationService.getLocation("String_Node_Str");
  invalid.getActiveAttributes(codeAttrType).get(0).setValue("String_Node_Str");
  locationService.saveLocation(invalid);
  ObjectSource<Location> source3=new LocationMflCsvSource("String_Node_Str",codeAttrType);
  AbstractSynchronization synchronization3=new LocationMflSynchronization(source3);
  synchronization3.run();
  Assert.assertThat(synchronization3.getCreatedObjects(),hasSize(1));
  Assert.assertThat(synchronization3.getUpdatedObjects(),hasSize(0));
  Assert.assertThat(synchronization3.getRetiredObjects(),hasSize(1));
  ObjectSource<Location> source4=new LocationMflCsvSource("String_Node_Str",codeAttrType);
  AbstractSynchronization synchronization4=new LocationMflSynchronization(source4);
  synchronization4.run();
  Assert.assertThat(synchronization4.getCreatedObjects(),hasSize(0));
  Assert.assertThat(synchronization4.getUpdatedObjects(),hasSize(0));
  Assert.assertThat(synchronization4.getRetiredObjects(),hasSize(0));
  Context.flushSession();
  Context.clearSession();
  for (  Location loc : locationService.getAllLocations()) {
    List<LocationAttribute> codeAttrs=loc.getActiveAttributes(codeAttrType);
  }
}

Fixed version (ground truth):
@Test public void integration() throws Exception {
  LocationAttributeType codeAttrType=MetadataUtils.getLocationAttributeType(CommonMetadata._LocationAttributeType.MASTER_FACILITY_CODE);
  ObjectSource<Location> source1=new LocationMflCsvSource("String_Node_Str",codeAttrType);
  AbstractSynchronization synchronization1=new LocationMflSynchronization(source1);
  synchronization1.run();
  Assert.assertThat(synchronization1.getCreatedObjects(),hasSize(3));
  Assert.assertThat(synchronization1.getUpdatedObjects(),hasSize(0));
  Assert.assertThat(synchronization1.getRetiredObjects(),hasSize(0));
  Location modified=locationService.getLocation("String_Node_Str");
  modified.setName("String_Node_Str");
  locationService.saveLocation(modified);
  ObjectSource<Location> source2=new LocationMflCsvSource("String_Node_Str",codeAttrType);
  AbstractSynchronization synchronization2=new LocationMflSynchronization(source2);
  synchronization2.run();
  Assert.assertThat(locationService.getLocation("String_Node_Str"),notNullValue());
  Assert.assertThat(synchronization2.getCreatedObjects(),hasSize(0));
  Assert.assertThat(synchronization2.getUpdatedObjects(),hasSize(1));
  Assert.assertThat(synchronization2.getRetiredObjects(),hasSize(0));
  Location invalid=locationService.getLocation("String_Node_Str");
  invalid.getActiveAttributes(codeAttrType).get(0).setValue("String_Node_Str");
  locationService.saveLocation(invalid);
  ObjectSource<Location> source3=new LocationMflCsvSource("String_Node_Str",codeAttrType);
  AbstractSynchronization synchronization3=new LocationMflSynchronization(source3);
  synchronization3.run();
  Assert.assertThat(synchronization3.getCreatedObjects(),hasSize(1));
  Assert.assertThat(synchronization3.getUpdatedObjects(),hasSize(0));
  Assert.assertThat(synchronization3.getRetiredObjects(),hasSize(1));
  ObjectSource<Location> source4=new LocationMflCsvSource("String_Node_Str",codeAttrType);
  AbstractSynchronization synchronization4=new LocationMflSynchronization(source4);
  synchronization4.run();
  Assert.assertThat(synchronization4.getCreatedObjects(),hasSize(0));
  Assert.assertThat(synchronization4.getUpdatedObjects(),hasSize(0));
  Assert.assertThat(synchronization4.getRetiredObjects(),hasSize(0));
  Context.flushSession();
  Context.clearSession();
  for (  Location loc : locationService.getAllLocations()) {
    List<LocationAttribute> codeAttrs=loc.getActiveAttributes(codeAttrType);
    Assert.assertThat(codeAttrs.size(),lessThanOrEqualTo(1));
  }
}