You need to sign in to do that
Don't have an account?

TestClass coverage
public with sharing class Tes_SWAssetController {
public string SWAssertNameLable {get;set;}
public Account currentAccount;//variable to hold current Account
public List<Software_Asset__c> lstSWI; //{set;get;}
public List<Software_Asset__c> lstSWI_All; //{set;get;}
public PageManager objPageManager {get;set;}
public boolean displayPagenation {get;set;}
/*
* Constructor
*/
public Tes_SWAssetController(ApexPages.StandardController controller) {
currentAccount = (Account) controller.getRecord();
List<account> lstAcc = [SELECT ID, Party_Number__c, Global_DUNS_Entity_Hub__c, IsCustomerPortal FROM Account WHERE ID =: currentAccount.ID];
if(lstAcc.size() == 1){
currentAccount = lstAcc[0];
}
//currentAccount = [SELECT ID, Party_Number__c, Global_DUNS_Entity_Hub__c, IsCustomerPortal FROM Account WHERE ID =: currentAccount.ID];
System.debug('*** currentAccount = ' + currentAccount);
Map<String, Schema.SobjectField> fields = Software_Asset__c.getSObjectType().getDescribe().fields.getMap();
SWAssertNameLable = fields.get('Name').getDescribe().getLabel();
//If Account is CPA query with Party Number
if(currentAccount.IsCustomerPortal){// IF Account is CPA account
lstSWI_All = [SELECT s.Id, s.Description_formula__c, s.Name, s.Product_Line__c, s.Account__c, s.Account_City__c, s.Status__c, s.Unit_of_Measure__c, s.Entitled__c, s.Activated__c, s.Available__c FROM Software_Asset__c s WHERE s.Account__r.Global_DUNS_Entity_Hub__c =: currentAccount.Global_DUNS_Entity_Hub__c AND s.Status__c != 'Expir' ORDER BY s.Account__c, s.Account_City__c, s.Product_Line__c, s.Description__c limit 1000 ];
} else {// IF Account is Non-CPA account
lstSWI_All = [SELECT s.Id, s.Description_formula__c, s.Name, s.Product_Line__c, s.Account__c, s.Account_City__c, s.Status__c, s.Unit_of_Measure__c, s.Entitled__c, s.Activated__c, s.Available__c FROM Software_Asset__c s WHERE s.Account__r.Party_Number__c =: currentAccount.Party_Number__c AND s.Status__c != 'Expir' ORDER BY s.Account__c, s.Account_City__c, s.Product_Line__c, s.Description__c limit 1000];
}
displayPagenation = (lstSWI_All.size() == 0 ? false : true);
objPageManager = new PageManager(10);
objPageManager.numberOfRows = lstSWI_All.size();
}
/*
* Method to query and return lstSWI list to show in VF page
* Query defers based on Account type(CPA/NON-CPA)
*/
public List<Software_Asset__c> getlstSWI(){
List<Software_Asset__c> toReturn = new List<Software_Asset__c>();
for(integer i=objPageManager.startIndex;i<objPageManager.endIndex&&i<lstSWI_All.size();i++)
{
toReturn.add(lstSWI_All.get(i));
}
return toReturn;
}
}
public string SWAssertNameLable {get;set;}
public Account currentAccount;//variable to hold current Account
public List<Software_Asset__c> lstSWI; //{set;get;}
public List<Software_Asset__c> lstSWI_All; //{set;get;}
public PageManager objPageManager {get;set;}
public boolean displayPagenation {get;set;}
/*
* Constructor
*/
public Tes_SWAssetController(ApexPages.StandardController controller) {
currentAccount = (Account) controller.getRecord();
List<account> lstAcc = [SELECT ID, Party_Number__c, Global_DUNS_Entity_Hub__c, IsCustomerPortal FROM Account WHERE ID =: currentAccount.ID];
if(lstAcc.size() == 1){
currentAccount = lstAcc[0];
}
//currentAccount = [SELECT ID, Party_Number__c, Global_DUNS_Entity_Hub__c, IsCustomerPortal FROM Account WHERE ID =: currentAccount.ID];
System.debug('*** currentAccount = ' + currentAccount);
Map<String, Schema.SobjectField> fields = Software_Asset__c.getSObjectType().getDescribe().fields.getMap();
SWAssertNameLable = fields.get('Name').getDescribe().getLabel();
//If Account is CPA query with Party Number
if(currentAccount.IsCustomerPortal){// IF Account is CPA account
lstSWI_All = [SELECT s.Id, s.Description_formula__c, s.Name, s.Product_Line__c, s.Account__c, s.Account_City__c, s.Status__c, s.Unit_of_Measure__c, s.Entitled__c, s.Activated__c, s.Available__c FROM Software_Asset__c s WHERE s.Account__r.Global_DUNS_Entity_Hub__c =: currentAccount.Global_DUNS_Entity_Hub__c AND s.Status__c != 'Expir' ORDER BY s.Account__c, s.Account_City__c, s.Product_Line__c, s.Description__c limit 1000 ];
} else {// IF Account is Non-CPA account
lstSWI_All = [SELECT s.Id, s.Description_formula__c, s.Name, s.Product_Line__c, s.Account__c, s.Account_City__c, s.Status__c, s.Unit_of_Measure__c, s.Entitled__c, s.Activated__c, s.Available__c FROM Software_Asset__c s WHERE s.Account__r.Party_Number__c =: currentAccount.Party_Number__c AND s.Status__c != 'Expir' ORDER BY s.Account__c, s.Account_City__c, s.Product_Line__c, s.Description__c limit 1000];
}
displayPagenation = (lstSWI_All.size() == 0 ? false : true);
objPageManager = new PageManager(10);
objPageManager.numberOfRows = lstSWI_All.size();
}
/*
* Method to query and return lstSWI list to show in VF page
* Query defers based on Account type(CPA/NON-CPA)
*/
public List<Software_Asset__c> getlstSWI(){
List<Software_Asset__c> toReturn = new List<Software_Asset__c>();
for(integer i=objPageManager.startIndex;i<objPageManager.endIndex&&i<lstSWI_All.size();i++)
{
toReturn.add(lstSWI_All.get(i));
}
return toReturn;
}
}
What is your question in above class?
Is this a test class? I do not see @isTest annotation in this class.
Please refer this link (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_isTest.htm) to explore more about test classes.
If this post is your solution, kindly mark this as the solution to the post so that others may benefit.
Regards,
Praful G.