You need to sign in to do that
Don't have an account?
Sarah Robertson
code coverage for get user method
Hi I'm quite new to apex and wondering if someone can help me getting code coverage for this method would be greatly appreciated.
Here's my apex method :
global Auth.UserData getUserInfo(Map<string,string> authProviderConfiguration, Auth.AuthProviderTokenResponse response) {
String token = response.oauthToken;
HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + token);
String accessTokenUrl = authProviderConfiguration.get('LoginURL__c');
req.setEndpoint(accessTokenUrl);
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
String responseBody = res.getBody();
final Auth.UserData userData = new Auth.UserData(
null // identifier
, null // firstName
, null // lastName
, null // fullName
,null // email
, null // link
, null // userName
, null //locale
, 'SireneAuth' //provider
, null // siteLoginUrl
, new Map<String,String>());
return userdata;
}
Here is what i have so far for my test class :
@isTest
static testmethod void testGetUserIfo(){
Map<String,String> authProviderConfiguration =
setupAuthProviderConfig();
System.Test.setMock(HttpCalloutMock.class, new SireneMockHttpResponseGenerator());
SireneAuth SireneAuthCls = new SireneAuth();
SireneAuthCls.accessTokenUrl = authProviderConfiguration.get
('LoginUrl_c');
}
Here's my apex method :
global Auth.UserData getUserInfo(Map<string,string> authProviderConfiguration, Auth.AuthProviderTokenResponse response) {
String token = response.oauthToken;
HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + token);
String accessTokenUrl = authProviderConfiguration.get('LoginURL__c');
req.setEndpoint(accessTokenUrl);
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
String responseBody = res.getBody();
final Auth.UserData userData = new Auth.UserData(
null // identifier
, null // firstName
, null // lastName
, null // fullName
,null // email
, null // link
, null // userName
, null //locale
, 'SireneAuth' //provider
, null // siteLoginUrl
, new Map<String,String>());
return userdata;
}
Here is what i have so far for my test class :
@isTest
static testmethod void testGetUserIfo(){
Map<String,String> authProviderConfiguration =
setupAuthProviderConfig();
System.Test.setMock(HttpCalloutMock.class, new SireneMockHttpResponseGenerator());
SireneAuth SireneAuthCls = new SireneAuth();
SireneAuthCls.accessTokenUrl = authProviderConfiguration.get
('LoginUrl_c');
}