• halopez
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies

Hi all,

 

I have the following error:

 

System.AssertException: Assertion Failed: Expected: ProductModelController:[contents=12345, creator=cchap@testconfigit.com, name=AltivarSample.configuration, referencePM=SEP_ATVCBL_V14_CTO.vt, visibility=true], Actual: ProductModelController:[contents=12345, creator=cchap@testconfigit.com, name=AltivarSample.configuration, referencePM=SEP_ATVCBL_V14_CTO.vt, visibility=true]

 

What I am doing in the test is simply creating two objects and comparing them. The code coverage hits the equals() method in the class, but when I am trying to assert whether two custom objects are the same, apex fails.

 

Is it just me, or that should be an error in the Apex compiler?

 

Cheers,

 

HA

Hi all, 

 

Sorry in advance for such a newbie question, but I am currently having problems when using the set methods when comparing custom classes, and I can't seem to find the error. I have the following class:

 

 

 

 

public class ProductModelerController{
	public String name {get{return name;} set {name = value;}}
    public String role {get{return role;} set {role = value;}}

    private Set<ProductModelController> assignedModels;
    private integer identifier;


    
    public void updateProductModels(Set<ProductModelController> updatedModels){
        //Compare each of the product models and verify it has the most updated information
        
        if(!this.assignedModels.isEmpty()){
            for(ProductModelController model: updatedModels){
                //Search for the model in the list of assignedModels
                    for(ProductModelController storedModel: this.assignedModels){
                        //If the model name is the same, update its contents
                        if (model.name == storedModel.name){
                            
                            storedModel.updateProductModel(model);
                        }
                }
            }
            if (!this.assignedModels.containsAll(updatedModels)){
             //Updates the set of available models with the recently added models
                
                Set<ProductModelController> newModels = updatedModels.clone();
                newModels.removeAll(this.assignedModels);
                this.assignedModels.addAll(newModels);
            }
            
        }
        else{
        	this.assignedModels = updatedModels;
        }
    }
}

 

When testing it, I am getting an error in the moment the code reach  

if (!this.assignedModels.containsAll(updatedModels)){

The error is: System.UnexpectedException: User defined type found in unsupported code path.

 

I haven't seen something like that before, and perhaps any of you have a clue what's wrong here? any help would be greatly appreciated!

 

Thanks and again sorry for the newbie question

Recently I have been playing around with Canvas, a technology that seems quite promising for the integration of third party applications within salesforce.

 

The canvas JavaScript API provides ways of making cross domain http request at an asynchronous level. I am interested in having synchronous method calls, and I don´t know whether that can be achieved. 

 

The following is the JavaScript example (combining the two examples given in the manual)

 

 

        function displayChatterUsers() {
          var NumberUsers = 0;
          // Reference the Chatter user's URL from Context.Links object.
          var chatterUsersUrl = canvasContext.context.links.chatterUsersUrl;

          // Make an XHR call back to salesforce through the supplied browser proxy.
          Sfdc.canvas.client.ajax(chatterUsersUrl,
            {
              token: canvasContext.oauthToken,
              success: function (data) {
                // Make sure the status code is OK.
                if (data.status === 200) {
                  numberUsers = data.payload.users.length;
                  // Alert with how many Chatter users were returned.
                  alert( "Got back " + numberUsers +
                    " users"); // Returned 2 users
                }
              }
            });
          alert( "Test for the number of users is " + numberUsers );
            var url = canvasContext.context.links.chatterFeedsUrl + "/news/" + canvasContext.context.user.userId + "/feed-items";
            var body = { body: { messageSegments: [{ type: "Text", text: "The number of users is " + numberUsers}]} };
          Sfdc.canvas.client.ajax( url,
            {
              token: canvasContext.oauthToken,
              method: 'POST',
              contentType: "application/json",
              data: JSON.stringify( body ),
              success: function( data ) {
                if ( 201 === data.status ) {
                  alert( "Success" );
                }
              }
            } );
        }

 When running the above mentioned example, you could see that the Sfdc.canvas.client.ajax get delayed in its execution, disallowing me from use of the results of the method call in outer levels of nesting (for instance, in the top level alert()).

I tried adding async:true as part of the values for the method call (as one might infer from the canvas-all.js specification) with no luck.

 

Any hints are greatly appreciated.

 

Andy

Hi all, 

 

Sorry in advance for such a newbie question, but I am currently having problems when using the set methods when comparing custom classes, and I can't seem to find the error. I have the following class:

 

 

 

 

public class ProductModelerController{
	public String name {get{return name;} set {name = value;}}
    public String role {get{return role;} set {role = value;}}

    private Set<ProductModelController> assignedModels;
    private integer identifier;


    
    public void updateProductModels(Set<ProductModelController> updatedModels){
        //Compare each of the product models and verify it has the most updated information
        
        if(!this.assignedModels.isEmpty()){
            for(ProductModelController model: updatedModels){
                //Search for the model in the list of assignedModels
                    for(ProductModelController storedModel: this.assignedModels){
                        //If the model name is the same, update its contents
                        if (model.name == storedModel.name){
                            
                            storedModel.updateProductModel(model);
                        }
                }
            }
            if (!this.assignedModels.containsAll(updatedModels)){
             //Updates the set of available models with the recently added models
                
                Set<ProductModelController> newModels = updatedModels.clone();
                newModels.removeAll(this.assignedModels);
                this.assignedModels.addAll(newModels);
            }
            
        }
        else{
        	this.assignedModels = updatedModels;
        }
    }
}

 

When testing it, I am getting an error in the moment the code reach  

if (!this.assignedModels.containsAll(updatedModels)){

The error is: System.UnexpectedException: User defined type found in unsupported code path.

 

I haven't seen something like that before, and perhaps any of you have a clue what's wrong here? any help would be greatly appreciated!

 

Thanks and again sorry for the newbie question