You need to sign in to do that
Don't have an account?

Admin needs help Testing integration
Hello,
I'm an admin that has just written my first integration. The code makes a call to an external service, receives some json, and then parses it and places it into a custom object. The json could either contain new records or update an existing record from a previous run...this is being done with upsert dml statement. This process runs on a schedule.
My question is regarding testing. There are no problems with testing the insert of new records. There is a test method that sets up all of the needed test data and a json string that makes use of that test data. The method returns that string and is used as a mockHTTPResponse. This tests everything except for the branch of code that updates existing records. This is where I'm challenged...I don't see how I can make another json string that uses first set of test data.
So, I'm hoping that someone out there has been through this before and can offers some suggestions.
I am presuming your mock class name is mockHTTPResponse, you can create another class like mockHTTPUpdateResponse and add the key value in the response with the value already existed.
I hope I understood your need correctly and was able to make my point. If not give me some more details with example. Thanks.
All Answers
I am presuming your mock class name is mockHTTPResponse, you can create another class like mockHTTPUpdateResponse and add the key value in the response with the value already existed.
I hope I understood your need correctly and was able to make my point. If not give me some more details with example. Thanks.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_testsetup_using.htm