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

Customer rating test class Help?
Hi,
Can you please help me with test class
public class OV_CustomerTierCtrl {
//To get ultimate parent customer tier,Total leasearea for current account
@AuraEnabled public static OV_CustomerTierWrapper getCustomerTier(String id){
OV_CustomerTierWrapper dbw = new OV_CustomerTierWrapper();
Account acc = [Select Ultimate_Parent_Account_ID_t__c from Account where Id =:id];
getLeaseArea(id,dbw,'Local');
addCustomerTier(dbw.totalLeaseSQFT,'Local',dbw);
getLeaseArea(acc.Ultimate_Parent_Account_ID_t__c,dbw,'Global');
addCustomerTier(dbw.totalUltimateLeaseSQFT,'Global',dbw);
return dbw;
}
//To get total lease area for entire hirarchy
private static void getLeaseArea(String id , OV_CustomerTierWrapper dbw,String tierType){
String acctIds =OV_BAUtility.getAcctIds(id);
String leaseSQFTQuery = 'select sum(Lease_Area_SF__c) from Lease__c where isActive__c= \'yes\' AND Account_Name__r.Id IN '+acctIds;
Decimal leaseSQFT=0;
try{
AggregateResult[] acct = database.query(leaseSQFTQuery);
if(acct[0].get('expr0')!=null){
leaseSQFT = (Decimal)acct[0].get('expr0');
}
if(tierType=='Global'){
dbw.totalUltimateLeaseSQFT=leaseSQFT;
}else{
dbw.totalLeaseSQFT=leaseSQFT;
}
}catch(Exception e){
}
}
//To update ultimate parent customer tier based on total lease area
private static void addCustomerTier(Decimal leaseArea,String tierType,OV_CustomerTierWrapper dbw ){
String customerTier='';
CustomerTier__c tier =[SELECT Bronze_Level__c,Gold_Level__c,Platinum_Level__c,Silver_Level__c FROM CustomerTier__c];
if(leaseArea < tier.Bronze_Level__c){
customerTier='Bronze';
}else if(leaseArea>=tier.Bronze_Level__c && leaseArea<tier.Silver_Level__c){
customerTier='Silver';
}else if(leaseArea>=tier.Silver_Level__c && leaseArea<tier.Gold_Level__c){
customerTier='Gold';
}else{
customerTier='Platinum';
}
if(tierType=='Global'){
dbw.globalUltimateTier=customerTier;
}else{
dbw.customerTier=customerTier;
}
}
public class OV_CustomerTierWrapper{
@AuraEnabled public Decimal totalLeaseSQFT{get;set;}
@AuraEnabled public Decimal totalUltimateLeaseSQFT{get;set;}
@AuraEnabled public String customerTier{get;set;}
@AuraEnabled public String globalUltimateTier{get;set;}
}
}
Can you please help me with test class
public class OV_CustomerTierCtrl {
//To get ultimate parent customer tier,Total leasearea for current account
@AuraEnabled public static OV_CustomerTierWrapper getCustomerTier(String id){
OV_CustomerTierWrapper dbw = new OV_CustomerTierWrapper();
Account acc = [Select Ultimate_Parent_Account_ID_t__c from Account where Id =:id];
getLeaseArea(id,dbw,'Local');
addCustomerTier(dbw.totalLeaseSQFT,'Local',dbw);
getLeaseArea(acc.Ultimate_Parent_Account_ID_t__c,dbw,'Global');
addCustomerTier(dbw.totalUltimateLeaseSQFT,'Global',dbw);
return dbw;
}
//To get total lease area for entire hirarchy
private static void getLeaseArea(String id , OV_CustomerTierWrapper dbw,String tierType){
String acctIds =OV_BAUtility.getAcctIds(id);
String leaseSQFTQuery = 'select sum(Lease_Area_SF__c) from Lease__c where isActive__c= \'yes\' AND Account_Name__r.Id IN '+acctIds;
Decimal leaseSQFT=0;
try{
AggregateResult[] acct = database.query(leaseSQFTQuery);
if(acct[0].get('expr0')!=null){
leaseSQFT = (Decimal)acct[0].get('expr0');
}
if(tierType=='Global'){
dbw.totalUltimateLeaseSQFT=leaseSQFT;
}else{
dbw.totalLeaseSQFT=leaseSQFT;
}
}catch(Exception e){
}
}
//To update ultimate parent customer tier based on total lease area
private static void addCustomerTier(Decimal leaseArea,String tierType,OV_CustomerTierWrapper dbw ){
String customerTier='';
CustomerTier__c tier =[SELECT Bronze_Level__c,Gold_Level__c,Platinum_Level__c,Silver_Level__c FROM CustomerTier__c];
if(leaseArea < tier.Bronze_Level__c){
customerTier='Bronze';
}else if(leaseArea>=tier.Bronze_Level__c && leaseArea<tier.Silver_Level__c){
customerTier='Silver';
}else if(leaseArea>=tier.Silver_Level__c && leaseArea<tier.Gold_Level__c){
customerTier='Gold';
}else{
customerTier='Platinum';
}
if(tierType=='Global'){
dbw.globalUltimateTier=customerTier;
}else{
dbw.customerTier=customerTier;
}
}
public class OV_CustomerTierWrapper{
@AuraEnabled public Decimal totalLeaseSQFT{get;set;}
@AuraEnabled public Decimal totalUltimateLeaseSQFT{get;set;}
@AuraEnabled public String customerTier{get;set;}
@AuraEnabled public String globalUltimateTier{get;set;}
}
}
Thanks let us know if it helps you