I am working on a class that makes a callout to a third party API. The third party API needs to be authenticated with a OpenID Connect Auth token. So, in my class, I am making a callout to the OpenID Connect Auth service to get a bearer token and then I am making a callout to the third party API with the bearer token from OpenID Connect API. The third party API is providing some additional information about the fields on the Account object and I am updating the values on the Account object. There are multiple scenarios in this case.
- The values on the Account object is different from what is retrieved from the third party API. In this case, the values on the Account object are updated.
- The values on the Account object is same as what is retrieved from the third party API. In this case, the account is not updated.
- The third party API returns a blank response. So, the response body contains . In this case, I am skipping the account.
The apex class is working fine. However, I need some help in building a test class for this. I am sure I need to use MultiStaticResourceCalloutMock stub class to build the test class, but I have some questions around it. My questions are below.
- Do I need to write three test methods, one for each scenario?
- In each of the test methods, I assume I need to use MultiStaticResourceCalloutMock with two end points, one for OpenID Connect Auth and one for third party API, correct?
- I also need three static resources, one for successful response, one for blank response (the static resource file will contain  only, and one with the response where the values are exactly same as what is on the Account, correct?
Can someone help?