Open EmilioGalicia opened 9 years ago
I forgot to say, I have this code working in other dev orgs and tests run fine, this is when I try to deploy to a new dev org, is there something I need to update/change with new Salesforce releases?
https://help.salesforce.com/apex/HTViewSolution?id=000213516&language=en_US
If you have accepted the critical update on those orgs for "Predictable Iteration Order for Apex Unordered Collections", then the test classes will fail because the order no longer matches what is returned. In these cases I would re-order the parameters in the MAP in most of the cases, until we can patch the code.
This is re-ordered to match the URL.
map<string,string> params=new map<string,string>();
params.put('AreaCode','510');
params.put('Contains','51034*****');
Thanks for your response it helped us alot, we followed your steps and the errors are gone
I need to add that we had to add a validation for the orgs that hasn't accepted the update yet in order to work in both scenarios.
static testMethod void testGenerateParamString() {
Boolean firstKey = true;
Boolean isOrdered = false;
Map<String, String> ordMap = new Map<String, String>{'a' => 'b', 'c' => 'd'};
for(String key: ordMap.keySet()){
if(ordMap.get(key) == 'b' && firstKey){ isOrdered = true; }
firstKey = false;
}
if(isOrdered){
//Update accepted
System.assertEquals('', generateParamString(new Map<String,String>()));
System.assertEquals('a=b', generateParamString(new Map<String,String> {'a'=>'b'} ));
System.assertEquals('foo=bar&cat=dog', generateParamString(new Map<String,String> {'foo'=>'bar', 'cat' => 'dog'} ));
System.assertEquals('a=b&c=d&e=f', generateParamString(new Map<String,String> {'a'=>'b', 'c'=>'d', 'e'=>'f' } ));
System.assertEquals('split+key1=split+val1&split+key2=split+val2', generateParamString(new Map<String,String> {'split key1'=>'split val1', 'split key2'=>'split val2'} ));
}else{
//Update not accepted
System.assertEquals('', generateParamString(new Map<String,String>()));
System.assertEquals('a=b', generateParamString(new Map<String,String> {'a'=>'b'} ));
System.assertEquals('cat=dog&foo=bar', generateParamString(new Map<String,String> {'foo'=>'bar', 'cat' => 'dog'} ));
System.assertEquals('e=f&c=d&a=b', generateParamString(new Map<String,String> {'a'=>'b', 'c'=>'d', 'e'=>'f' } ));
System.assertEquals('split+key2=split+val2&split+key1=split+val1', generateParamString(new Map<String,String> {'split key1'=>'split val1', 'split key2'=>'split val2'} ));
}
}
Please reopen this and change
if(ordMap.get(key) == 'b' && firstKey)isOrdered = true;
to
if(ordMap.get(key) == 'b' && firstKey){ isOrdered = true; }
This is the error that created a major security hole in OSX, and best-practice is to use curly brackets for every if statement, even on one line.
I'd be happy to review a pull request for that :)
re-opened issue and updated the comment and our code, thanks for the heads up
I have sent the request
Thank you. Apologies for asking someone else to make the change (faux pas, I know) but I wasn't at a machine that would let me do it myself. Go team!
no prob, I just haven't had enough time to figure out how to remove whitespacing and indentation :P
Hi,
I'm new to this twilio stuff but when I'm trying to deploy I'm getting the same errors in the salesforce production and also we have the update our org with critical updates.
Can you pls let me know on which class I have to update these Lines:
map<string,string> params=new map<string,string>(); params.put('AreaCode','510'); params.put('Contains','51034*****');
Here is the test class failures:
Hi,
You need to modify both files: Twilio_TestApplication and Twilio_TestPhoneNumbers
Is it possible if we can get an updated managed package with this bug fix?
We currently aren't releasing managed packages for salesforce.
Sorry, I meant unmanaged package. Is v4.0.0 with this bug fix?
The latest version has many updates in it, including support for some of our new APIs, and re-ordering the test data expected to the Salesforce Unordered Lists patch which is auto activated on 6/5 by salesforce. However, it also has some restructuring of classes so if you have already installed and are leveraging an older version I would advise you to update the test class yourself versus using v4.0.
To Fix the issue quickly:
1) Re - Order Map values in Twilio_TestApplication class near line no. 130 and 219 as given below: params.put('VoiceMethod','POST'); params.put('FriendlyName','Testapp1');
2) Re - Order Map values in Twilio_TestPhoneNumbers class near line no. 264 as given below: params.put('AreaCode','510'); params.put('Contains','51034*****');
3) Comment the 5 line code from line no. 271 to 275 in TwilioCapability class and all the error will be gone.
@saamabbas very clear on the directions listed above, wanted to comment that this fix worked perfectly.
Hi, I'm getting the following errors when I try to deploy to a dev org using ANT:
All Test Failures:
I have traced the error by running just the Twilio_TestPhoneNumbers.testTwilioAvailablePhoneNumbers_AreaCodeFilter method. What I found is the following message:
"Did not find Resource for GET https://api.twilio.com/2010-04-01/Accounts/ACba8bc05eacf94afdae398e642c9cc32d/AvailablePhoneNumbers/US/Local.json"
And that's because the uri passed to the Twilio_TestHTTPMock Reponse is not contained in the resourceMap.keySet();
Params: (uri:)HTTPS://API.TWILIO.COM/2010-04-01/ACCOUNTS/ACBA8BC05EACF94AFDAE398E642C9CC32D/AVAILABLEPHONENUMBERS/US/LOCAL.JSON
(resourceMap().keySet()) Keys :{HTTPS://API.TWILIO.COM/2010-04-01/ACCOUNTS/ACBA8BC05EACF94AFDAE398E642C9CC32D/AVAILABLEPHONENUMBERS/US/LOCAL.JSON?AREACODE=510&CONTAINS=51034*****
Need help!