Program: 60929
Project: 60929
Buggy source:
/** 
 * Build an UserTO out of connector object attributes and schema mapping.
 * @param obj connector object
 * @param mappings schema mappings
 * @param roles default roles to be assigned
 * @param resources default resources to be assigned
 * @return UserTO for the user to be created
 */
private UserTO getUserTO(final ConnectorObject obj,final List<SchemaMapping> mappings,final Set<Long> roles,final Set<String> resources){
  final UserTO userTO=new UserTO();
  userTO.setResources(resources);
  MembershipTO membershipTO;
  for (  Long roleId : roles) {
    membershipTO=new MembershipTO();
    membershipTO.setRoleId(roleId);
    userTO.addMembership(membershipTO);
  }
  Attribute attribute;
  List<Object> values;
  AttributeTO attributeTO;
  for (  SchemaMapping mapping : mappings) {
    attribute=obj.getAttributeByName(mapping.getExtAttrName());
    values=attribute == null ? Collections.EMPTY_LIST : attribute.getValue();
switch (mapping.getIntMappingType()) {
case SyncopeUserId:
      break;
case Password:
    attribute=obj.getAttributeByName("String_Node_Str");
  userTO.setPassword(getPassword(attribute == null ? Collections.EMPTY_LIST : attribute.getValue()));
break;
case UserSchema:
attributeTO=new AttributeTO();
attributeTO.setSchema(mapping.getIntAttrName());
for (Object value : values) {
attributeTO.addValue(value.toString());
}
userTO.addAttribute(attributeTO);
break;
case UserDerivedSchema:
attributeTO=new AttributeTO();
attributeTO.setSchema(mapping.getIntAttrName());
userTO.addDerivedAttribute(attributeTO);
break;
case UserVirtualSchema:
attributeTO=new AttributeTO();
attributeTO.setSchema(mapping.getIntAttrName());
userTO.addVirtualAttribute(attributeTO);
break;
default :
}
}
return userTO;
}

Fixed version (ground truth):
/** 
 * Build an UserTO out of connector object attributes and schema mapping.
 * @param obj connector object
 * @param mappings schema mappings
 * @param roles default roles to be assigned
 * @param resources default resources to be assigned
 * @return UserTO for the user to be created
 */
private UserTO getUserTO(final ConnectorObject obj,final List<SchemaMapping> mappings,final Set<Long> roles,final Set<String> resources){
  final UserTO userTO=new UserTO();
  userTO.setResources(resources);
  MembershipTO membershipTO;
  for (  Long roleId : roles) {
    membershipTO=new MembershipTO();
    membershipTO.setRoleId(roleId);
    userTO.addMembership(membershipTO);
  }
  Attribute attribute;
  List<Object> values;
  AttributeTO attributeTO;
  for (  SchemaMapping mapping : mappings) {
    if (mapping.isAccountid()) {
      attribute=obj.getAttributeByName(Name.NAME);
    }
 else     if (mapping.isPassword()) {
      attribute=obj.getAttributeByName(OperationalAttributes.PASSWORD_NAME);
    }
 else {
      attribute=obj.getAttributeByName(mapping.getExtAttrName());
    }
    values=attribute == null ? Collections.EMPTY_LIST : attribute.getValue();
switch (mapping.getIntMappingType()) {
case SyncopeUserId:
      break;
case Password:
    userTO.setPassword(getPassword(attribute == null ? Collections.EMPTY_LIST : attribute.getValue()));
  break;
case UserSchema:
attributeTO=new AttributeTO();
attributeTO.setSchema(mapping.getIntAttrName());
for (Object value : values) {
attributeTO.addValue(value.toString());
}
userTO.addAttribute(attributeTO);
break;
case UserDerivedSchema:
attributeTO=new AttributeTO();
attributeTO.setSchema(mapping.getIntAttrName());
userTO.addDerivedAttribute(attributeTO);
break;
case UserVirtualSchema:
attributeTO=new AttributeTO();
attributeTO.setSchema(mapping.getIntAttrName());
userTO.addVirtualAttribute(attributeTO);
break;
default :
}
}
return userTO;
}