Program: 60784
Project: 60784
Buggy source:
/** 
 * @see http://code.google.com/p/syncope/issues/detail?id=42
 */
@Test public final void issue42(){
  USchema userId=schemaDAO.find("String_Node_Str",USchema.class);
  Set<SchemaMapping> beforeUserIdMappings=new HashSet<SchemaMapping>();
  for (  SchemaMapping mapping : resourceDAO.findAllMappings()) {
    if (userId.getName().equals(mapping.getIntAttrName()) && mapping.getIntMappingType() == IntMappingType.UserSchema) {
      beforeUserIdMappings.add(mapping);
    }
  }
  SchemaMappingTO schemaMappingTO=new SchemaMappingTO();
  schemaMappingTO.setIntAttrName("String_Node_Str");
  schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
  schemaMappingTO.setExtAttrName("String_Node_Str");
  schemaMappingTO.setAccountid(true);
  schemaMappingTO.setPassword(false);
  schemaMappingTO.setMandatoryCondition("String_Node_Str");
  List<SchemaMappingTO> schemaMappingTOs=new ArrayList<SchemaMappingTO>();
  schemaMappingTOs.add(schemaMappingTO);
  ResourceTO resourceTO=new ResourceTO();
  resourceTO.setName("String_Node_Str");
  resourceTO.setConnectorId(100L);
  resourceTO.setMappings(schemaMappingTOs);
  resourceTO.setPropagationMode(PropagationMode.SYNC);
  resourceTO.setForceMandatoryConstraint(true);
  ExternalResource resource=resourceDataBinder.create(resourceTO);
  resource=resourceDAO.save(resource);
  resourceDAO.flush();
  ExternalResource actual=resourceDAO.find("String_Node_Str");
  assertEquals(resource,actual);
  userId=schemaDAO.find("String_Node_Str",USchema.class);
  Set<SchemaMapping> afterUserIdMappings=new HashSet<SchemaMapping>();
  for (  SchemaMapping mapping : resourceDAO.findAllMappings()) {
    if (userId.getName().equals(mapping.getIntAttrName()) && mapping.getIntMappingType() == IntMappingType.UserSchema) {
      afterUserIdMappings.add(mapping);
    }
  }
  assertEquals(beforeUserIdMappings.size(),afterUserIdMappings.size() - 1);
}

Fixed version (ground truth):
/** 
 * @see http://code.google.com/p/syncope/issues/detail?id=42
 */
@Test public final void issue42(){
  USchema userId=schemaDAO.find("String_Node_Str",USchema.class);
  Set<SchemaMapping> beforeUserIdMappings=new HashSet<SchemaMapping>();
  for (  SchemaMapping mapping : resourceDAO.findAllMappings()) {
    if (userId.getName().equals(mapping.getIntAttrName()) && mapping.getIntMappingType() == IntMappingType.UserSchema) {
      beforeUserIdMappings.add(mapping);
    }
  }
  SchemaMappingTO schemaMappingTO=new SchemaMappingTO();
  schemaMappingTO.setIntAttrName("String_Node_Str");
  schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
  schemaMappingTO.setExtAttrName("String_Node_Str");
  schemaMappingTO.setAccountid(true);
  schemaMappingTO.setPassword(false);
  schemaMappingTO.setMandatoryCondition("String_Node_Str");
  List<SchemaMappingTO> schemaMappingTOs=new ArrayList<SchemaMappingTO>();
  schemaMappingTOs.add(schemaMappingTO);
  ResourceTO resourceTO=new ResourceTO();
  resourceTO.setName("String_Node_Str");
  resourceTO.setConnectorId(100L);
  resourceTO.setMappings(schemaMappingTOs);
  resourceTO.setPropagationMode(PropagationMode.ONE_PHASE);
  resourceTO.setForceMandatoryConstraint(true);
  ExternalResource resource=resourceDataBinder.create(resourceTO);
  resource=resourceDAO.save(resource);
  resourceDAO.flush();
  ExternalResource actual=resourceDAO.find("String_Node_Str");
  assertEquals(resource,actual);
  userId=schemaDAO.find("String_Node_Str",USchema.class);
  Set<SchemaMapping> afterUserIdMappings=new HashSet<SchemaMapping>();
  for (  SchemaMapping mapping : resourceDAO.findAllMappings()) {
    if (userId.getName().equals(mapping.getIntAttrName()) && mapping.getIntMappingType() == IntMappingType.UserSchema) {
      afterUserIdMappings.add(mapping);
    }
  }
  assertEquals(beforeUserIdMappings.size(),afterUserIdMappings.size() - 1);
}