Skip to content

Instantly share code, notes, and snippets.

@noeticpenguin
Created September 17, 2013 19:15
Show Gist options
  • Save noeticpenguin/6599287 to your computer and use it in GitHub Desktop.
Save noeticpenguin/6599287 to your computer and use it in GitHub Desktop.
//In a class far far away...
@future
global static void RunMockCalloutForTest(String accountId){
TestRestClient trc = new TestRestClient();
id aId;
try {
aId = (Id) accountId;
} catch (Exception e) {
throw new exception('Failed to cast given accountId into an actual id, Send me a valid id or else.');
}
Account a = [select id, name, stuff, foo, bar from Account where id = :aId];
//make your callout
RestClientHTTPMocks fakeResponse = new RestClientHTTPMocks(200, 'Success', 'Success', new Map<String,String>());
System.AssertNotEquals(fakeResponse, null);
Test.setMock(HttpCalloutMock.class, fakeResponse);
System.AssertNotEquals(trc, null); //this is a lame assertion. I'm sure you can come up with something useful!
String result = trc.get('http://www.google.com');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment