You need to sign in to do that
Don't have an account?
sfdc007
Apex Test class help needed
Hi,
I am having an apex class where i am not able to cover the following methods for which i need help on it,
Kindly help me pls
METHODS I NEED HELP IN MY APEX CLASS :
global without sharing class VRDInternalAccReqController {
global class AccDetails{
public string accId{get;set;}
public string accSFDCId{get;set;}
public string accName{get;set;}
public string accOwner{get;set;}
}
global class OpptyDetails{
public string OpptyId{get;set;}
public string OpptySFDCId{get;set;}
public string OpptyName{get;set;}
public string OpptyOwner{get;set;}
public string OpptyStage{get;set;}
}
@remoteAction
global static List<AccDetails> fetchAccDetails(string selctdOptn, string impUsrId){
//GSAM Account List
List<String> GSAMMatchAccId=listOfAcctGSAMCheck(impUsrId);
string GSAMacct='';
integer intCnt1 = 0;
for (string gsam:GSAMMatchAccId) {
intCnt1 = intCnt1 + 1;
if(intCnt1==GSAMMatchAccId.size()){
GSAMacct += gsam;
break;
}
GSAMacct += gsam + '\','+'\'';
}
system.debug('GSAMacct==>'+GSAMacct);
//Account team detail
set<id> impacc= new set<id>();
string accteamacc='';
List<String>lsacc =new List<String>();
for(Account_Team__c ip:[SELECT Id, User__c, Account__c from Account_Team__c where User__c=:impUsrId]){
impacc.add(ip.Account__c);
lsacc.add(ip.Account__c);
}
integer intCount = 0;
for (string st:lsacc) {
intCount = intCount + 1;
if(intCount==lsacc.size()){
accteamacc += st;
break;
}
accteamacc += st + '\','+'\'';
}
system.debug('accteamacc==>'+accteamacc);
//Oppty team details
set<id> impopp= new set<id>();
string oppteamoppty='';
string oppteamopptyacc='';
List<String> lstopty=new List<String>();
List<String> lstoptyacc=new List<String>();
for(Opportunity_Sales_Team__c ip1:[SELECT Id, User__c, Opportunity__c,Opportunity__r.Account.id from Opportunity_Sales_Team__c where User__c=:impUsrId]){
impopp.add(ip1.Opportunity__c);
lstopty.add(ip1.Opportunity__c);
lstoptyacc.add(ip1.Opportunity__r.Account.id);
}
integer intCnt = 0;
for (string ost:lstoptyacc) {
intCnt = intCnt + 1;
if(intCnt==lstoptyacc.size()){
oppteamopptyacc += ost;
break;
}
oppteamopptyacc += ost + '\','+'\'';
}
system.debug('oppteamopptyacc==>'+oppteamopptyacc);
string soql;
system.debug('selctdOptn==>'+selctdOptn);
soql ='SELECT Id, Name, SFDC_Account_Id__c, Owner.Name FROM Account where VRD_Internal_Account__c=true';
if(selctdOptn=='NAVRD'){
soql+=' and Id not in (\''+accteamacc+'\')';
soql+=' and Id in (\''+GSAMacct+'\')';
}else if(selctdOptn=='NAOVRD'){
soql+=' and Id in (\''+GSAMacct+'\')';
}else if(selctdOptn=='RSAVRD'){
soql+=' and Id in (\''+accteamacc+'\')';
}else if(selctdOptn=='RSAOVRD'){
soql+=' and Id in (\''+oppteamopptyacc+'\')';
}
system.debug('soql==>'+soql);
List<AccDetails> lstResult = new List<AccDetails>();
if(soql!='' && soql!=null)
{
for(Account acc:Database.query(soql)){
AccDetails oAcc = new AccDetails();
oAcc.accId = acc.Id;
oAcc.accSFDCId = acc.SFDC_Account_Id__c;
oAcc.accName = acc.Name;
oAcc.accOwner = acc.Owner.Name;
lstResult.add(oAcc);
}
}
return lstResult;
}
@remoteAction
global static List<OpptyDetails> fetchOpptyDetails(string selctdOptn, string impUsrId, string acct){
//Oppty team details
set<id> impopp= new set<id>();
string oppteamoppty='';
string oppteamopptyacc='';
List<String> lstopty=new List<String>();
List<String> lstoptyacc=new List<String>();
for(Opportunity_Sales_Team__c ip1:[SELECT Id, User__c, Opportunity__c,Opportunity__r.Account.id from Opportunity_Sales_Team__c where User__c=:impUsrId]){
impopp.add(ip1.Opportunity__c);
lstopty.add(ip1.Opportunity__c);
lstoptyacc.add(ip1.Opportunity__r.Account.id);
}
integer intCt = 0;
for (string ost:lstopty) {
intCt = intCt + 1;
if(intCt==lstopty.size()){
oppteamoppty += ost;
break;
}
oppteamoppty += ost + '\','+'\'';
}
system.debug('oppteamoppty==>'+oppteamoppty);
string soql;
system.debug('selctdOptn==>'+selctdOptn);
if(selctdOptn=='NAVRD'){
}else if(selctdOptn=='NAOVRD'){
soql ='SELECT Id,Name,Owner.Name,SFDC_Opportunity_Id__c,StageName,Account.id FROM Opportunity';
soql+=' where Account.Id=\''+acct+'\'';
}else if(selctdOptn=='RSAVRD'){
}else if(selctdOptn=='RSAOVRD'){
soql ='SELECT Id,Name,Owner.Name,SFDC_Opportunity_Id__c,StageName,Account.id FROM Opportunity';
soql+=' where Id in (\''+oppteamoppty+'\')';
}
system.debug('soql==>'+soql);
List<OpptyDetails> lstResult = new List<OpptyDetails>();
if(soql!='' && soql!=null)
{
for(Opportunity oppty:Database.query(soql)){
OpptyDetails oOpp = new OpptyDetails();
oOpp.OpptyId = oppty.Id;
oOpp.OpptySFDCId = oppty.SFDC_Opportunity_Id__c;
oOpp.OpptyName = oppty.Name;
oOpp.OpptyOwner = oppty.Owner.Name;
oOpp.OpptyStage=oppty.StageName;
lstResult.add(oOpp);
}
}
return lstResult;
}
}
Thanks in Advance
I am having an apex class where i am not able to cover the following methods for which i need help on it,
Kindly help me pls
METHODS I NEED HELP IN MY APEX CLASS :
global without sharing class VRDInternalAccReqController {
global class AccDetails{
public string accId{get;set;}
public string accSFDCId{get;set;}
public string accName{get;set;}
public string accOwner{get;set;}
}
global class OpptyDetails{
public string OpptyId{get;set;}
public string OpptySFDCId{get;set;}
public string OpptyName{get;set;}
public string OpptyOwner{get;set;}
public string OpptyStage{get;set;}
}
@remoteAction
global static List<AccDetails> fetchAccDetails(string selctdOptn, string impUsrId){
//GSAM Account List
List<String> GSAMMatchAccId=listOfAcctGSAMCheck(impUsrId);
string GSAMacct='';
integer intCnt1 = 0;
for (string gsam:GSAMMatchAccId) {
intCnt1 = intCnt1 + 1;
if(intCnt1==GSAMMatchAccId.size()){
GSAMacct += gsam;
break;
}
GSAMacct += gsam + '\','+'\'';
}
system.debug('GSAMacct==>'+GSAMacct);
//Account team detail
set<id> impacc= new set<id>();
string accteamacc='';
List<String>lsacc =new List<String>();
for(Account_Team__c ip:[SELECT Id, User__c, Account__c from Account_Team__c where User__c=:impUsrId]){
impacc.add(ip.Account__c);
lsacc.add(ip.Account__c);
}
integer intCount = 0;
for (string st:lsacc) {
intCount = intCount + 1;
if(intCount==lsacc.size()){
accteamacc += st;
break;
}
accteamacc += st + '\','+'\'';
}
system.debug('accteamacc==>'+accteamacc);
//Oppty team details
set<id> impopp= new set<id>();
string oppteamoppty='';
string oppteamopptyacc='';
List<String> lstopty=new List<String>();
List<String> lstoptyacc=new List<String>();
for(Opportunity_Sales_Team__c ip1:[SELECT Id, User__c, Opportunity__c,Opportunity__r.Account.id from Opportunity_Sales_Team__c where User__c=:impUsrId]){
impopp.add(ip1.Opportunity__c);
lstopty.add(ip1.Opportunity__c);
lstoptyacc.add(ip1.Opportunity__r.Account.id);
}
integer intCnt = 0;
for (string ost:lstoptyacc) {
intCnt = intCnt + 1;
if(intCnt==lstoptyacc.size()){
oppteamopptyacc += ost;
break;
}
oppteamopptyacc += ost + '\','+'\'';
}
system.debug('oppteamopptyacc==>'+oppteamopptyacc);
string soql;
system.debug('selctdOptn==>'+selctdOptn);
soql ='SELECT Id, Name, SFDC_Account_Id__c, Owner.Name FROM Account where VRD_Internal_Account__c=true';
if(selctdOptn=='NAVRD'){
soql+=' and Id not in (\''+accteamacc+'\')';
soql+=' and Id in (\''+GSAMacct+'\')';
}else if(selctdOptn=='NAOVRD'){
soql+=' and Id in (\''+GSAMacct+'\')';
}else if(selctdOptn=='RSAVRD'){
soql+=' and Id in (\''+accteamacc+'\')';
}else if(selctdOptn=='RSAOVRD'){
soql+=' and Id in (\''+oppteamopptyacc+'\')';
}
system.debug('soql==>'+soql);
List<AccDetails> lstResult = new List<AccDetails>();
if(soql!='' && soql!=null)
{
for(Account acc:Database.query(soql)){
AccDetails oAcc = new AccDetails();
oAcc.accId = acc.Id;
oAcc.accSFDCId = acc.SFDC_Account_Id__c;
oAcc.accName = acc.Name;
oAcc.accOwner = acc.Owner.Name;
lstResult.add(oAcc);
}
}
return lstResult;
}
@remoteAction
global static List<OpptyDetails> fetchOpptyDetails(string selctdOptn, string impUsrId, string acct){
//Oppty team details
set<id> impopp= new set<id>();
string oppteamoppty='';
string oppteamopptyacc='';
List<String> lstopty=new List<String>();
List<String> lstoptyacc=new List<String>();
for(Opportunity_Sales_Team__c ip1:[SELECT Id, User__c, Opportunity__c,Opportunity__r.Account.id from Opportunity_Sales_Team__c where User__c=:impUsrId]){
impopp.add(ip1.Opportunity__c);
lstopty.add(ip1.Opportunity__c);
lstoptyacc.add(ip1.Opportunity__r.Account.id);
}
integer intCt = 0;
for (string ost:lstopty) {
intCt = intCt + 1;
if(intCt==lstopty.size()){
oppteamoppty += ost;
break;
}
oppteamoppty += ost + '\','+'\'';
}
system.debug('oppteamoppty==>'+oppteamoppty);
string soql;
system.debug('selctdOptn==>'+selctdOptn);
if(selctdOptn=='NAVRD'){
}else if(selctdOptn=='NAOVRD'){
soql ='SELECT Id,Name,Owner.Name,SFDC_Opportunity_Id__c,StageName,Account.id FROM Opportunity';
soql+=' where Account.Id=\''+acct+'\'';
}else if(selctdOptn=='RSAVRD'){
}else if(selctdOptn=='RSAOVRD'){
soql ='SELECT Id,Name,Owner.Name,SFDC_Opportunity_Id__c,StageName,Account.id FROM Opportunity';
soql+=' where Id in (\''+oppteamoppty+'\')';
}
system.debug('soql==>'+soql);
List<OpptyDetails> lstResult = new List<OpptyDetails>();
if(soql!='' && soql!=null)
{
for(Opportunity oppty:Database.query(soql)){
OpptyDetails oOpp = new OpptyDetails();
oOpp.OpptyId = oppty.Id;
oOpp.OpptySFDCId = oppty.SFDC_Opportunity_Id__c;
oOpp.OpptyName = oppty.Name;
oOpp.OpptyOwner = oppty.Owner.Name;
oOpp.OpptyStage=oppty.StageName;
lstResult.add(oOpp);
}
}
return lstResult;
}
}
MY TEST CLASS /* * Name: VRDInternalAccReqController_Test */ @isTest(seeAllData=true) public class VRDInternalAccReqController_Test { static testMethod void VRDInternalAccReqController_Test1() { User usr = [Select id from User where Id = :UserInfo.getUserId()]; // setup a nasp ALL_NASP_IDs__c AllNasp = new ALL_NASP_IDs__c( NASP1__c = '9XXYY', Name = '9XXYY', NASP_NAME__c = 'NASP 9', GARM_APP_Level__c = 'A16', Generic_NASP__c = 'FALSE', OWNING_AREA__c = 'US ENTERPRISE', DUNS_Number__c = '8888' ); insert AllNasp; // setup an account Utilities_Vaiables.setisvdmsdatefieldtrigger(); Utilities_Vaiables.setForTest(); GSAMUtilityClass.isGSAMAccountValidationChkCalled = true; Utilities_Vaiables.isForTest = true; StaticConstantsUtil.ranChangePtnrMgrOnAccOwnrChange = true; Utilities_Vaiables.isvdmsdatefieldtrigger = true; Utilities_Vaiables.isBBcreated = true; Utilities_Vaiables.setIsPRMTest(); Utilities_Vaiables.skipCTrigger = true; Utilities_Vaiables.isChatterRolechanged = true; Utilities_Vaiables.isCCI = true; GSAMUtilityClass.isGSAMUserObjectTriggerCalled = true; GSAMUtilityClass.GSAMUserAfterTriggermethod = true; SFDCtoECSfromTrigger.isttesting = true; Account act = new Account( Name = 'DLM Account', phone = '7894563256', Organization__c = 'EMEA', Account_NASP_ID__c = AllNasp.id, Primary_Account__c = true, BillingStreet = 'test Billing Street', BillingCity = 'test Billing City', BillingState = 'test Billing State', BillingPostalCode = '600000', BillingCountry = 'USA', Partner_Category__c='cloud', Partner_Primary_Focus__c='Wireless' ); insert act; //set up an account team Account_Team__c atm = new Account_Team__c(); atm.User__c = usr.Id; atm.Account__c=act.Id; insert atm; // setup an opportunity RecordType UpsellRT = [SELECT Id,Name FROM RecordType WHERE sObjectType = 'Opportunity' AND Name = 'Wireline Sales Opportunity' LIMIT 1]; Utilities_Vaiables.isRTcreated = false; SFDCtoECSfromTrigger.setisttest(); EP_Utilities.isOpportunityPRMLOACheckCalled = true; Utilities_Vaiables.setisvdmsdatefieldtrigger(); Utilities_Vaiables.setForTest(); GSAMUtilityClass.isGSAMAccountValidationChkCalled = true; Utilities_Vaiables.isForTest = true; StaticConstantsUtil.ranChangePtnrMgrOnAccOwnrChange = true; Utilities_Vaiables.isvdmsdatefieldtrigger = true; Utilities_Vaiables.isBBcreated = true; Utilities_Vaiables.setIsPRMTest(); Utilities_Vaiables.skipCTrigger = true; Utilities_Vaiables.isChatterRolechanged = true; Utilities_Vaiables.isCCI = true; GSAMUtilityClass.isGSAMUserObjectTriggerCalled = true; GSAMUtilityClass.GSAMUserAfterTriggermethod = true; SFDCtoECSfromTrigger.isttesting = true; OpportunityUpdateIntegration.istest=true; Opportunity opp1 = new Opportunity(); opp1.Name='XXABC'; opp1.AccountId=act.id; opp1.StageName = '0 Identify'; opp1.ForecastCategoryName = 'Funnel'; opp1.CloseDate=date.today(); opp1.NextStep = 'next'; opp1.RecordTypeId = UpsellRT.Id; opp1.Type='Renewal Only'; opp1.subNASP__c='0001'; opp1.Deal_Expire_Update__c=true; insert opp1; opp1.Deal_Expire_Update__c=false; opp1.subNASP__c='0002'; update opp1; ApexPages.StandardController TestNewAAR = new ApexPages.StandardController(atm); VRDInternalAccReqController vrd = new VRDInternalAccReqController(TestNewAAR); vrd.fnSubmit(); vrd.fnCancel(); VRDInternalAccReqController.ChatterFeedPost('test','test1'); } }Kindly help me how to cover those methods in my test class
Thanks in Advance
String s='Base Product';
Class_Name.RemoteMethodName(s);
In the above code 's' is the parameter value that i need to pass to remote method.
Please mark it as a best answer if it helps.
Thanks,