You need to sign in to do that
Don't have an account?

Are my URL Parameters being reordered?
In a controller class I have:
p = new PageReference('/apex/CreateContactUpdateRecordStep1?original=' + original.id +
'&contact=' + contact.id + '&id=' + indoubt.id);
In a testing class I have:
String url = nextPage.getUrl();
...
System.assertEquals(url,
'/apex/CreateContactUpdateRecordStep1' +
'?original=' + control.original.id +
'&contact=' + control.contact.id +
'&id=' + control.indoubt.id);
The data is all correct, however the assertion fails because the order of the parameters in the string
returned from the getURL call is different from the order specified in the new PageReference call.
The URL returns '/apex/CreateContactUpdateRecordStep1?contact=xxxxx&id=yyyyy&original=zzzzz'
It's as if the parameters were reordered alphabetically? (Might this be because I'm adding my parameters as part of a string instead of using p.getParameters().put('original',zzzzz) etc?
Now that I write this, I'll test with the put() method... I'll bet the url is returned by dumping the alphabetically ordered parameter Map. (If so, it might help if it were documented somewhere so others
could avoid it.)
-Steve.
p = new PageReference('/apex/CreateContactUpdateRecordStep1?original=' + original.id +
'&contact=' + contact.id + '&id=' + indoubt.id);
In a testing class I have:
String url = nextPage.getUrl();
...
System.assertEquals(url,
'/apex/CreateContactUpdateRecordStep1' +
'?original=' + control.original.id +
'&contact=' + control.contact.id +
'&id=' + control.indoubt.id);
The data is all correct, however the assertion fails because the order of the parameters in the string
returned from the getURL call is different from the order specified in the new PageReference call.
The URL returns '/apex/CreateContactUpdateRecordStep1?contact=xxxxx&id=yyyyy&original=zzzzz'
It's as if the parameters were reordered alphabetically? (Might this be because I'm adding my parameters as part of a string instead of using p.getParameters().put('original',zzzzz) etc?
Now that I write this, I'll test with the put() method... I'll bet the url is returned by dumping the alphabetically ordered parameter Map. (If so, it might help if it were documented somewhere so others
could avoid it.)
-Steve.
I don't think you can rely on an order for these page parameter map items, alpha or otherwise.
And, to check the base of the url, since getUrl() returns the whole thing, with parameters, you have to strip off the parameters yourself to get the base.
Ah well. :-) Thanks, Steve.
kaos = new CreateContactUpdateRecordController(stdcontrol);
pageRefUpdate.getParameters().clear();
pageRefUpdate.getParameters().put('id', c.id);
Test.setCurrentPage(pageRefUpdate);
nextPage = kaos.myFunction(); //
and then checking the URL and Parameter map that has been returned in nextPage? Isn't ApexPages.currentPage() pointing to the same page that has just been returned from my controller? nextPage in this case.
Regardless of where I get the Parameter map from, currentpage(), or one I return myself, I'll still need to check the map one parameter at a time. And if I want to verify that the pageReference returned from a method is '/apex/Pagetwo', I still have to check that against the base of currentpage().getURL(), or nextPage.getURL().
Or have I missed something? The above all seems to work just fine. Thanks, Steve.