Program: 59574
Project: 59574
Buggy source:
private void resolve(){
  final Map<String,EdmEntityType.Builder> allEetsByFQName=Enumerable.create(dataServices.getEntityTypes()).toMap(new Func1<EdmEntityType.Builder,String>(){
    public String apply(    EdmEntityType.Builder input){
      return input.getFQAliasName() != null ? input.getFQAliasName() : input.getFullyQualifiedTypeName();
    }
  }
);
  final Map<String,EdmAssociation.Builder> allEasByFQName=Enumerable.create(dataServices.getAssociations()).toMap(new Func1<EdmAssociation.Builder,String>(){
    public String apply(    EdmAssociation.Builder input){
      return input.getFQAliasName() != null ? input.getFQAliasName() : input.getFQNamespaceName();
    }
  }
);
  for (  EdmSchema.Builder edmSchema : dataServices.getSchemas()) {
    for (int i=0; i < edmSchema.getAssociations().size(); i++) {
      EdmAssociation.Builder tmpAssociation=edmSchema.getAssociations().get(i);
      tmpAssociation.getEnd1().setType(allEetsByFQName.get(tmpAssociation.getEnd1().getTypeName()));
      tmpAssociation.getEnd2().setType(allEetsByFQName.get(tmpAssociation.getEnd2().getTypeName()));
    }
    for (    EdmEntityType.Builder eet : edmSchema.getEntityTypes()) {
      List<EdmNavigationProperty.Builder> navProps=eet.getNavigationProperties();
      for (int i=0; i < navProps.size(); i++) {
        final EdmNavigationProperty.Builder tmp=navProps.get(i);
        final EdmAssociation.Builder ea=allEasByFQName.get(tmp.getRelationshipName());
        List<EdmAssociationEnd.Builder> finalEnds=Enumerable.create(tmp.getFromRoleName(),tmp.getToRoleName()).select(new Func1<String,EdmAssociationEnd.Builder>(){
          public EdmAssociationEnd.Builder apply(          String input){
            if (ea.getEnd1().getRole().equals(input))             return ea.getEnd1();
            if (ea.getEnd2().getRole().equals(input))             return ea.getEnd2();
            throw new IllegalArgumentException("String_Node_Str" + input);
          }
        }
).toList();
        tmp.setRelationship(ea).setFromTo(finalEnds.get(0),finalEnds.get(1));
      }
    }
    for (    EdmEntityContainer.Builder edmEntityContainer : edmSchema.getEntityContainers()) {
      for (int i=0; i < edmEntityContainer.getEntitySets().size(); i++) {
        final EdmEntitySet.Builder tmpEes=edmEntityContainer.getEntitySets().get(i);
        EdmEntityType.Builder eet=allEetsByFQName.get(tmpEes.getEntityTypeName());
        if (eet == null)         throw new IllegalArgumentException("String_Node_Str" + tmpEes.getEntityTypeName());
        edmEntityContainer.getEntitySets().set(i,EdmEntitySet.newBuilder().setName(tmpEes.getName()).setEntityType(eet));
      }
    }
    for (    final EdmEntityContainer.Builder edmEntityContainer : edmSchema.getEntityContainers()) {
      for (int i=0; i < edmEntityContainer.getAssociationSets().size(); i++) {
        final EdmAssociationSet.Builder tmpEas=edmEntityContainer.getAssociationSets().get(i);
        final EdmAssociation.Builder ea=allEasByFQName.get(tmpEas.getAssociationName());
        List<EdmAssociationSetEnd.Builder> finalEnds=Enumerable.create(tmpEas.getEnd1(),tmpEas.getEnd2()).select(new Func1<EdmAssociationSetEnd.Builder,EdmAssociationSetEnd.Builder>(){
          public EdmAssociationSetEnd.Builder apply(          final EdmAssociationSetEnd.Builder input){
            EdmAssociationEnd.Builder eae=ea.getEnd1().getRole().equals(input.getRoleName()) ? ea.getEnd1() : ea.getEnd2().getRole().equals(input.getRoleName()) ? ea.getEnd2() : null;
            if (eae == null)             throw new IllegalArgumentException("String_Node_Str" + input.getRoleName());
            EdmEntitySet.Builder ees=Enumerable.create(edmEntityContainer.getEntitySets()).first(OPredicates.nameEquals(EdmEntitySet.Builder.class,input.getEntitySetName()));
            return EdmAssociationSetEnd.newBuilder().setRole(eae).setEntitySet(ees);
          }
        }
).toList();
        tmpEas.setAssociation(ea).setEnds(finalEnds.get(0),finalEnds.get(1));
      }
    }
    for (    final EdmEntityContainer.Builder edmEntityContainer : edmSchema.getEntityContainers()) {
      for (int i=0; i < edmEntityContainer.getFunctionImports().size(); i++) {
        final EdmFunctionImport.Builder tmpEfi=edmEntityContainer.getFunctionImports().get(i);
        EdmEntitySet.Builder ees=Enumerable.create(edmEntityContainer.getEntitySets()).firstOrNull(new Predicate1<EdmEntitySet.Builder>(){
          public boolean apply(          EdmEntitySet.Builder input){
            return input.getName().equals(tmpEfi.getEntitySetName());
          }
        }
);
        EdmType.Builder<?,?> typeBuilder=null;
        if (tmpEfi.getReturnTypeName() != null) {
          typeBuilder=dataServices.resolveType(tmpEfi.getReturnTypeName());
          if (typeBuilder == null)           throw new RuntimeException("String_Node_Str" + tmpEfi.getReturnTypeName());
          if (tmpEfi.isCollection()) {
            typeBuilder=EdmCollectionType.newBuilder().setKind(CollectionKind.Collection).setCollectionType(typeBuilder);
          }
        }
        edmEntityContainer.getFunctionImports().set(i,EdmFunctionImport.newBuilder().setName(tmpEfi.getName()).setEntitySet(ees).setReturnType(typeBuilder).setHttpMethod(tmpEfi.getHttpMethod()).addParameters(tmpEfi.getParameters()));
      }
    }
    for (    Entry<String,EdmEntityType.Builder> entry : allEetsByFQName.entrySet()) {
      String baseTypeName=entry.getValue().getFQBaseTypeName();
      if (baseTypeName != null) {
        EdmEntityType.Builder baseType=allEetsByFQName.get(baseTypeName);
        if (baseType == null) {
          throw new IllegalArgumentException("String_Node_Str" + baseTypeName);
        }
        entry.getValue().setBaseType(baseType);
      }
    }
  }
}

Fixed version (ground truth):
private void resolve(){
  final Map<String,EdmEntityType.Builder> allEetsByFQName=Enumerable.create(dataServices.getEntityTypes()).toMap(EdmEntityType.Builder.func1_getFullyQualifiedTypeName());
  final Map<String,EdmAssociation.Builder> allEasByFQName=Enumerable.create(dataServices.getAssociations()).toMap(EdmAssociation.Builder.func1_getFQNamespaceName());
  for (  EdmSchema.Builder edmSchema : dataServices.getSchemas()) {
    for (int i=0; i < edmSchema.getAssociations().size(); i++) {
      EdmAssociation.Builder tmpAssociation=edmSchema.getAssociations().get(i);
      tmpAssociation.getEnd1().setType(allEetsByFQName.get(tmpAssociation.getEnd1().getTypeName()));
      tmpAssociation.getEnd2().setType(allEetsByFQName.get(tmpAssociation.getEnd2().getTypeName()));
    }
    for (    EdmEntityType.Builder eet : edmSchema.getEntityTypes()) {
      List<EdmNavigationProperty.Builder> navProps=eet.getNavigationProperties();
      for (int i=0; i < navProps.size(); i++) {
        final EdmNavigationProperty.Builder tmp=navProps.get(i);
        final EdmAssociation.Builder ea=allEasByFQName.get(tmp.getRelationshipName());
        if (ea == null)         throw new IllegalArgumentException("String_Node_Str" + tmp.getRelationshipName());
        List<EdmAssociationEnd.Builder> finalEnds=Enumerable.create(tmp.getFromRoleName(),tmp.getToRoleName()).select(new Func1<String,EdmAssociationEnd.Builder>(){
          public EdmAssociationEnd.Builder apply(          String input){
            if (ea.getEnd1().getRole().equals(input))             return ea.getEnd1();
            if (ea.getEnd2().getRole().equals(input))             return ea.getEnd2();
            throw new IllegalArgumentException("String_Node_Str" + input);
          }
        }
).toList();
        tmp.setRelationship(ea).setFromTo(finalEnds.get(0),finalEnds.get(1));
      }
    }
    for (    EdmEntityContainer.Builder edmEntityContainer : edmSchema.getEntityContainers()) {
      for (int i=0; i < edmEntityContainer.getEntitySets().size(); i++) {
        final EdmEntitySet.Builder tmpEes=edmEntityContainer.getEntitySets().get(i);
        EdmEntityType.Builder eet=allEetsByFQName.get(tmpEes.getEntityTypeName());
        if (eet == null)         throw new IllegalArgumentException("String_Node_Str" + tmpEes.getEntityTypeName());
        edmEntityContainer.getEntitySets().set(i,EdmEntitySet.newBuilder().setName(tmpEes.getName()).setEntityType(eet));
      }
    }
    for (    final EdmEntityContainer.Builder edmEntityContainer : edmSchema.getEntityContainers()) {
      for (int i=0; i < edmEntityContainer.getAssociationSets().size(); i++) {
        final EdmAssociationSet.Builder tmpEas=edmEntityContainer.getAssociationSets().get(i);
        final EdmAssociation.Builder ea=allEasByFQName.get(tmpEas.getAssociationName());
        List<EdmAssociationSetEnd.Builder> finalEnds=Enumerable.create(tmpEas.getEnd1(),tmpEas.getEnd2()).select(new Func1<EdmAssociationSetEnd.Builder,EdmAssociationSetEnd.Builder>(){
          public EdmAssociationSetEnd.Builder apply(          final EdmAssociationSetEnd.Builder input){
            EdmAssociationEnd.Builder eae=ea.getEnd1().getRole().equals(input.getRoleName()) ? ea.getEnd1() : ea.getEnd2().getRole().equals(input.getRoleName()) ? ea.getEnd2() : null;
            if (eae == null)             throw new IllegalArgumentException("String_Node_Str" + input.getRoleName());
            EdmEntitySet.Builder ees=Enumerable.create(edmEntityContainer.getEntitySets()).first(OPredicates.nameEquals(EdmEntitySet.Builder.class,input.getEntitySetName()));
            return EdmAssociationSetEnd.newBuilder().setRole(eae).setEntitySet(ees);
          }
        }
).toList();
        tmpEas.setAssociation(ea).setEnds(finalEnds.get(0),finalEnds.get(1));
      }
    }
    for (    final EdmEntityContainer.Builder edmEntityContainer : edmSchema.getEntityContainers()) {
      for (int i=0; i < edmEntityContainer.getFunctionImports().size(); i++) {
        final EdmFunctionImport.Builder tmpEfi=edmEntityContainer.getFunctionImports().get(i);
        EdmEntitySet.Builder ees=Enumerable.create(edmEntityContainer.getEntitySets()).firstOrNull(new Predicate1<EdmEntitySet.Builder>(){
          public boolean apply(          EdmEntitySet.Builder input){
            return input.getName().equals(tmpEfi.getEntitySetName());
          }
        }
);
        EdmType.Builder<?,?> typeBuilder=null;
        if (tmpEfi.getReturnTypeName() != null) {
          typeBuilder=dataServices.resolveType(tmpEfi.getReturnTypeName());
          if (typeBuilder == null)           throw new RuntimeException("String_Node_Str" + tmpEfi.getReturnTypeName());
          if (tmpEfi.isCollection()) {
            typeBuilder=EdmCollectionType.newBuilder().setKind(CollectionKind.Collection).setCollectionType(typeBuilder);
          }
        }
        edmEntityContainer.getFunctionImports().set(i,EdmFunctionImport.newBuilder().setName(tmpEfi.getName()).setEntitySet(ees).setReturnType(typeBuilder).setHttpMethod(tmpEfi.getHttpMethod()).addParameters(tmpEfi.getParameters()));
      }
    }
    for (    Entry<String,EdmEntityType.Builder> entry : allEetsByFQName.entrySet()) {
      String baseTypeName=entry.getValue().getFQBaseTypeName();
      if (baseTypeName != null) {
        EdmEntityType.Builder baseType=allEetsByFQName.get(baseTypeName);
        if (baseType == null) {
          throw new IllegalArgumentException("String_Node_Str" + baseTypeName);
        }
        entry.getValue().setBaseType(baseType);
      }
    }
  }
}