I have built an application that uses Salesforce to Salesforce and have written test cases for the application. I do not determine how to create a test case to simulate a connection. Below is a streamlined example of the code I would like to write a test case for.

 public Id getConnectionId(String connectionName) {

 List<PartnerNetworkConnection> partnerNetConList =
                [Select id from PartnerNetworkConnection where connectionStatus =  'Accepted' and connectionName = :connectionName];

     return partnerNetConList.get(0).Id; }

Many Thanks for your Help!


You'll need to use a mockResponse using setContinuationResponse(requestLabel, mockResponse). See setMock(interfaceType, instance) from the Apex Code Developer's Guide for more on the subject. If you search, you'll find plenty of sample code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.