You need to sign in to do that
Don't have an account?
Navya sree 4
Forecast test class Help?
Hi
Test Class Help
public with sharing class ForecastArchiveController {
public String userInfo {get; private set;}
public ForecastArchiveController() {
setUserDetails(this);
}
public static void setUserDetails(ForecastArchiveController controller) {
User userDetail = [SELECT Id, Name, Forecast_OA_Region_Name__c, Forecast_OA_Region_Id__c, UserRole.Name, Profile.Name FROM User WHERE Id =: UserInfo.getUserId()];
UserWrapper userWrap = new UserWrapper(userDetail);
controller.userInfo = JSON.serialize(userWrap);
}
public class UserWrapper {
public String userName;
public String userId;
public String userForecastOARegion;
public String userForecastOARegionId;
public String userRole;
public String userProfile;
public UserWrapper(User user) {
this.userName = user.Name;
this.userId = user.Id;
this.userForecastOARegion = user.Forecast_OA_Region_Name__c;
this.userForecastOARegionId = user.Forecast_OA_Region_Id__c;
this.userRole = user.UserRole.Name;
this.userProfile = user.Profile.Name;
}
}
}
Test Class Help
public with sharing class ForecastArchiveController {
public String userInfo {get; private set;}
public ForecastArchiveController() {
setUserDetails(this);
}
public static void setUserDetails(ForecastArchiveController controller) {
User userDetail = [SELECT Id, Name, Forecast_OA_Region_Name__c, Forecast_OA_Region_Id__c, UserRole.Name, Profile.Name FROM User WHERE Id =: UserInfo.getUserId()];
UserWrapper userWrap = new UserWrapper(userDetail);
controller.userInfo = JSON.serialize(userWrap);
}
public class UserWrapper {
public String userName;
public String userId;
public String userForecastOARegion;
public String userForecastOARegionId;
public String userRole;
public String userProfile;
public UserWrapper(User user) {
this.userName = user.Name;
this.userId = user.Id;
this.userForecastOARegion = user.Forecast_OA_Region_Name__c;
this.userForecastOARegionId = user.Forecast_OA_Region_Id__c;
this.userRole = user.UserRole.Name;
this.userProfile = user.Profile.Name;
}
}
}
Raj Vakati
Try this