I am using an app exchange package in my code, they have exposed a few global methods that I can use to get my job done. It all works beautifully. The issue comes with testing.
I want to test positive, negative test scenarios to see my code handle's App Exchange packages' response elegantly.
That app exchange package does callout and parses, I don't know the actual HTTP Response JSON structure or mock so I cannot use Test.setMock
.
The next thing I investigated is to use Stub API. Which sounded perfect but when I tried this mock I got an exception.
System.TypeException: Test.createStub() can only be called with classes in the current namespace
AppExchange Package Code:
AppExchangePackage.Api api = new AppExchangePackage.Api();
AppExchangePackage.ApiData.ScreenResponse response = api.screen(entityId); //Can be PersonAccount , Lead, Contact Id
Is there an elegant way to mock api.screen
method so that I get my desired ScreenResponse
in test context?