You need to sign in to do that
Don't have an account?
Pedro Garcia G
Make a Unit Test to a method which has a callout method inside
I'm running a unit test for a method which include another callout method. The callout method is already tested. How could I make the unit test?
here is the involved code
here is the involved code
@AuraEnabled public static List<CAS_User_Identity__c> requestUserIdentities(String x_api_key){ //THIS IS A CALLOUT METHOD CASConnectorIdentity results = CASConnector.getUserIdentities(x_api_key); if(!String.isEmpty(results.error)){ throw new AuraHandledException('The Connection was not possible. Verify the API KEY!'); } //PARSE THE JSON List<CASConnectorIdentity.user_identities> userIdentities = (List<CASConnectorIdentity.user_identities>) results.user_identities; List<CAS_User_Identity__c> casUserIdentityList = new List<CAS_User_Identity__c>(); for(CASConnectorIdentity.user_identities usid : userIdentities){ CAS_User_Identity__c casUserIdentity = new CAS_User_Identity__c(); casUserIdentity.Id__c = String.valueOf(usid.id); casUserIdentity.institution__c = usid.institution; casUserIdentity.type__c = usid.type; casUserIdentity.organization__c = usid.organization; casUserIdentity.association__c = usid.association; casUserIdentity.cycle__c = usid.cycle; casUserIdentityList.add(casUserIdentity); } //REMOVE ALL RECORDS AND INSERT AGAIN. List<CAS_User_Identity__c> userIdentitiesDB = [Select Id from CAS_User_Identity__c]; if(userIdentities.size() > 0 ){ delete userIdentitiesDB; insert casUserIdentityList; } Insert CASProgram.insertProgram( x_api_key); return casUserIdentityList; }
Thanks everyone!