Skip to content

Instantly share code, notes, and snippets.

@olopsman
Created October 2, 2019 09:33
Show Gist options
  • Save olopsman/f263440caf19a8835c3ff09849bb6369 to your computer and use it in GitHub Desktop.
Save olopsman/f263440caf19a8835c3ff09849bb6369 to your computer and use it in GitHub Desktop.
Apex MyServiceAPITest Unit Test using GenericRESTMock
@isTest
private class MyServiceAPITest {
@isTest static void getTransactionsTest() {
Test.startTest();
Map<String,String> headers = new Map<String, String>();
headers.put('Accept','application/json');
Test.setMock(HttpCalloutMock.class, new GenericRESTMock(200,'Success','{"Items":[{"Id":"string","Code":"string","EffectiveDate":"2019-07-15T22:03:31.145Z","Type":"APP"]}',headers));
String str = MyServiceAPI.getTransactions('7/15/2019');
Test.stopTest();
system.assertEquals(null, str);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment