Posts

Showing posts from December, 2015

Test apex rest class Callouts using StaticResourceCalloutMock

Everybody googles about covering the rest callouts and ends up using almost one solution, i.e., creating a Mockup service class and use it in the test class. But there is an easy way and its been out there for quite sometime. It is really so simple that you can end up writing the test class in less than a minute, you need to have the response JSON of the callout that you are making in your actual class. You will have to catch that from either  system.debug(res.getBody()) or get it from the other system. That would look something like this: {"status":"OK","message":"Search request completed successfully","result":{"appId":110,"requestId":225877959,"resultCount":9,"pageInfo":{"pageSize":10,"requestedPage":2,"totalPages":2,"totalResults":19},"nextPage":false,"sourceItemIds":"1101-1110-1111"}} 1. Catch that response in a text

Passing URL parameters to controller in Lightning components/ AURA

Image
The following example helps you understand how to pass parameters from URL to components. In AURA/ Salesforce1 platform, it is made easy to pass the parameters to the controllers. We know that we can create attributes in the components as variables and they are meant for the scope of the components. So we create application attributes for the entire scope of application. So when we need to get the values from the URL, it is easy to pass them to application attributes, in other words, application attributes can take the values from URL directly. Here is a simple example: 1. Create an application - 'URLApp' 2. Create an attribute in the application XML. <aura:application> <aura:attribute name="fromURL" type="String" default="this is default value"/> Value in Attribute: {!v.fromURL}! </aura:application> Save the XML and run it, your output should be: Now, If you just pass a value to the url the