• Mohammed Arshad
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 8
    Replies
I am unable to cover this method in my test class. Can someone please help me out. 

Code: 

  public static CustomerPlans.repayments paymentDetails(List<Payment__c> payments) { 
    System.debug('Enter the Repayments Dragon');
    CustomerPlans.repayments  repayments = new CustomerPlans.repayments();
    List<CustomerPlans.repaymentDetails> transactionDetailsList = new List<CustomerPlans.repaymentDetails>();
    
     Id appId = ApexPages.currentPage().getParameters().get('id');
     Payment__c payment;
     try{
         payment = [select Application__r.Payment_Type__c from Payment__c where Application__r.id=:appId ];
     Integer i=0;
    do {
    for(Payment__c d: payments){
    Offer__c offer = [ select isOffer1_Active__c,isOffer2_Active__c from Offer__c ];
    CustomerPlans.repaymentDetails repaymentDetails = new CustomerPlans.repaymentDetails();
            repaymentDetails.repaymentMethod = d.Payment_Method_Code__c;
                    repaymentDetails.accountHolders = d.Account_Holders__c;
                    
                    if(d.Bank_Name__c!=null) {
                        repaymentDetails.bankName = d.Bank_Name__c;
                    }
                    if(d.Branch_Location__c!=null) {
                        repaymentDetails.branchLocation = d.Branch_Location__c;
                    }
                    if(d.Bank_Code__c!=null) {
                        repaymentDetails.bankCode = d.Bank_Code__c;
                    }
                    if(d.Account_Number__c!=null) {
                        repaymentDetails.accountNumber = d.Account_Number__c;
                    } 
                    
                     if(d.Bank_Number__c != null && d.Branch_Number__c != null){
                        repaymentDetails.bankCode = d.Bank_Number__c + d.Branch_Number__c;
                      }
                      if(d.Suf_Number__c != null){
                        repaymentDetails.suffix = d.Suf_Number__c;
                      }
                      repaymentDetails.repaymentFrequency = d.Frequency_Code__c;
                    
                    if(d.Higher_Amount__c!=null) {
                        repaymentDetails.higherAmount = d.Higher_Amount__c;
                    }
                    if(d.Start_Date__c!=null) {
                        repaymentDetails.startDate = d.Start_Date__c;
                    } else {
                        repaymentDetails.startDate = Date.Today();
                    }                 
                    if(d.Application__r.Brand_Country__c == 'US'){
                              if(d.Application__r.Payment_Type__c == 'Card' && i==1 && (offer.isOffer1_Active__c == true || offer.isOffer1_Active__c == false)){
                                   repaymentDetails.interestRate = 0.0;
                                   repaymentDetails.numberOfTransactions = Decimal.valueOf(Web_Service_Settings__c.getValues('No of Transactions').value__c);
                               }else if(offer.isOffer1_Active__c == true){
                                   repaymentDetails.interestRate = d.Application__r.Offered_Interest_Rate__c;
                                   repaymentDetails.numberOfTransactions = d.Application__r.Loan_Term_Months__c;
                               }else if(offer.isOffer1_Active__c == false){
                                   repaymentDetails.interestRate = d.Application__r.Offered_Interest_Rate__c;
                                   repaymentDetails.numberOfTransactions = d.Application__r.Loan_Term_Months__c;
                               }
                             } else if(d.Application__r.Brand_Country__c == 'CN'){
                             if(d.Application__r.Payment_Type__c == 'Card' && i==1 && offer.isOffer2_Active__c == true ){
                                   repaymentDetails.interestRate = 0.0;
                                   repaymentDetails.numberOfTransactions = Decimal.valueOf(Web_Service_Settings__c.getValues('No of Transactions').value__c);
                               }else if(offer.isOffer2_Active__c == true) {
                                  repaymentDetails.interestRate = d.Application__r.Offered_Interest_Rate__c;
                                  repaymentDetails.numberOfTransactions = d.Application__r.Loan_Term_Months__c;
                               }else if(offer.isOffer2_Active__c == false){
                                   repaymentDetails.interestRate = d.Application__r.Offered_Interest_Rate__c;
                                   repaymentDetails.numberOfTransactions = d.Application__r.Loan_Term_Months__c;
                               }
                               }
                    transactionDetailsList.add(repaymentDetails);
    
    }  
    i++;  
        system.debug('Before While'+i);
    }
    while(i<2 && payment.Application__r.Payment_Type__c == 'Card' );
    System.debug('After While'+i);
    }
     catch(System.QueryException e){
         System.debug('payment Record retrieval exception occured');
     }
     catch(System.NullPointerException e1){
         System.debug('Exception for Null pointer occured');
         System.debug('Product SubType Value' + payment.Application__r.Payment_Type__c);
    }
    system.debug('Repayment Details List ++++++++++++' + transactionDetailsList);
    

    repayments.repayment= transactionDetailsList;
   system.debug('Repayment RepaymentDetails Array +++++'+repayments.repayment);
    return repayments; 
    
    }
    //End of Method
I am trying to apply a style in the <apex:outputText> but it doesn't work.
Below is the code:
<apex:outputText  value="Please refer this link for more information <a href =https://www.w3schools.com/>https://www.w3schools.com</a>"/>

So now i wanted to give some css touch to the above hyperlink by changing the
<apex:outputText  value="Please refer this link for more information <a style=color:antiquewhite;text-decoration:underline;padding:42px; href =https://www.w3schools.com/>https://www.w3schools.com</a>"/> etc... but when i try to put the style in the <a> tag it is not working. Can anyone help me on this. 

Thanks 
Can anyone help me know on how to acheive the below scenario:
1) I have two Objects called BooksDealer__c & BooksDistributor__c 
2) BooksDealer__c has the below fields:-
    a) Name(Text)
    b)LicenseNumber__c(Text)
    c)ActiveFrom__c(Number)
3)BooksDistributor__c has the below fields:-
   a)Dealers__c(Picklist)

So now the requirement is whenever there is a new BooksDealer__c is created then the 'Name' field value should be added in the Dealers__c picklist field.

Note:- Name is a Text field in BooksDealer__c object  and Dealers__c is a Picklist field in BooksDistributor__c Object.
Also these two objects doesn't have any relationships between them.
public with sharing class IS_Retailer{        
    public Decimal TotalCount;
    public IS_Retailer() {
    }

    public List<IS_Checker> check(IS_Retail retail) {
        List<IS_Checker> checkErrors = new List<IS_Checker>();
        if(retail.app.Total_Cash__c < 1000){
            IS_Checker ive = new IS_Checker('check Application', 'Cash is less than 1000');
            checkErrors.add(ive);
        }
        checkErrors.addAll(checkIsAvailable(retail.soapList1,'Atleast 1 ABC is required'));
        checkErrors.addAll(checkIsAvailable(retail.foamList1,'Atleast 1 XYZ is required'));
        if(retail.applicant2 != null){
            checkErrors.addAll(checkIsAvailable(retail.foamList2,'Atleast 1 ABC is required.'));
            checkErrors.addAll(checkIsAvailable(retail.soapList2,'Atleast 1 XYZ is required'));
        }
        Id appId = ApexPages.currentPage().getParameters().get('id');
        List<AggregateResult> groupedResults = [select Count(Application__r.Checker_Count__c) plan,SUM(No_of_Checker_Plans__c) aver from Checker__c where Application__c = :appId];
        Object chplan = groupedResults[0].get('plan');
        Object chCount = groupedResults[0].get('aver');               
        TotalCount = (integer)chplan + (Decimal)chCount;
       if(TotalCount > 30){
        IS_Checker ive = new IS_Checker('', 'Exceeded maximum number of allowed Checks (30)');
            checkErrors.add(ive);
        }
        if((retail.app.Sync__c != true && !retail.app.Code__c.contains('ERR')) && !retail.app.Docs__c){      
            checkErrors.add(new IS_Checker('','Application is updated.'));
        }
        return checkErrors; 
    }    


    public List<IS_Checker> checkIsAvailable(List<SObject> objList, String err) {
        List<IS_Checker> checkErrors = new List<IS_Checker>();
        
        if(objList != null){
            if(objList.isEmpty()){
               IS_Checker ive = new IS_Checker('check Application', err);
               checkErrors.add(ive);           
            }
        }
        return checkErrors;
    }
    
}
 
Hi Guys,

I am unable to write a test class for the below code, Can someone help me:
Controller:
--------------
public with sharing class IS_Retailer {       
    public IS_Retailer() {
    }
    public List<IS_Checker> check(IS_Retail retail) {
        List<IS_Checker> checkErrors= new List<IS_Checker>();
        if(retail.appAmount < 5000){
            IS_Checker ch = new IS_Checker('check', The price is less than Rs:5000');
            checkErrors.add(ch);
        }
        checkErrors.addAll(IsThere(retail.soapList,'Atleast 1 ABC is required'));
        checkErrors.addAll(IsThere(retail.foamList,'Atleast 1 XYZ is required'));
        return checkErrors;
    }
    public List<IS_Checker> IsThere(List<SObject> objList, String err) {
        List<IS_Checker> checkErrors= new List<IS_Checker>(); 
        if(objList != null){
            if(objList.isEmpty()){
               IS_Checker ch = new IS_Checker('Check', err);
               checkErrors.add(ch);          
            }
        }
        return checkErrors;
    }   
}
Apex Class:-
public class Insurance_List{
    public String id {get;set;}
    public Insurance__c insurance {get;set;}
public Insurance_List(ApexPages.StandardController controller) {
    id = ApexPages.currentPage().getParameters().get('id');
    insurance = [select Code__c,ShortName__c,LongName__c,MinValue__c,MaxValue__c,CheckDigitRule__c from Insurance__c where Id = :id];     
    }
}
Test Class:-
@isTest
public class Insurance_List_Test {

    static testMethod void methodOne(){
           
           Application__c app = TestDataBuilder.createApplication();             
           app.Response_Code__c = 'New';
           insert app;
           System.assertNotEquals(null,app.Id);//assert inserted Application__c
           List<Insurance__c> insurances = new List<Insurance__c>();
           Insurance__c insuranceList =TestDataBuilder.createInsurance(app.Id);
           insuranceList.Code__c = '99999';
           insuranceList.ShortName__c = 'Test';
           insuranceList.LongName__c= 'Test';
           insuranceList.MinValue__c= 200;
           insuranceList.MaxValue__c= 1000;
           insuranceList.CheckDigitRule__c='123';     
           dl.add(insuranceList);
           insert insurances;
           ApexPages.StandardController standardController = new ApexPages.StandardController(insuranceList);           
           APP_Disbursement_List appDisbList = new APP_Disbursement_List(standardController);
    }   
}
Error in Test History:

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Application status already Accepted. You are no longer allowed to insert a record.: []
I am trying to apply a style in the <apex:outputText> but it doesn't work.
Below is the code:
<apex:outputText  value="Please refer this link for more information <a href =https://www.w3schools.com/>https://www.w3schools.com</a>"/>

So now i wanted to give some css touch to the above hyperlink by changing the
<apex:outputText  value="Please refer this link for more information <a style=color:antiquewhite;text-decoration:underline;padding:42px; href =https://www.w3schools.com/>https://www.w3schools.com</a>"/> etc... but when i try to put the style in the <a> tag it is not working. Can anyone help me on this. 

Thanks 
Can anyone help me know on how to acheive the below scenario:
1) I have two Objects called BooksDealer__c & BooksDistributor__c 
2) BooksDealer__c has the below fields:-
    a) Name(Text)
    b)LicenseNumber__c(Text)
    c)ActiveFrom__c(Number)
3)BooksDistributor__c has the below fields:-
   a)Dealers__c(Picklist)

So now the requirement is whenever there is a new BooksDealer__c is created then the 'Name' field value should be added in the Dealers__c picklist field.

Note:- Name is a Text field in BooksDealer__c object  and Dealers__c is a Picklist field in BooksDistributor__c Object.
Also these two objects doesn't have any relationships between them.
Hi Guys,

I am unable to write a test class for the below code, Can someone help me:
Controller:
--------------
public with sharing class IS_Retailer {       
    public IS_Retailer() {
    }
    public List<IS_Checker> check(IS_Retail retail) {
        List<IS_Checker> checkErrors= new List<IS_Checker>();
        if(retail.appAmount < 5000){
            IS_Checker ch = new IS_Checker('check', The price is less than Rs:5000');
            checkErrors.add(ch);
        }
        checkErrors.addAll(IsThere(retail.soapList,'Atleast 1 ABC is required'));
        checkErrors.addAll(IsThere(retail.foamList,'Atleast 1 XYZ is required'));
        return checkErrors;
    }
    public List<IS_Checker> IsThere(List<SObject> objList, String err) {
        List<IS_Checker> checkErrors= new List<IS_Checker>(); 
        if(objList != null){
            if(objList.isEmpty()){
               IS_Checker ch = new IS_Checker('Check', err);
               checkErrors.add(ch);          
            }
        }
        return checkErrors;
    }   
}
Apex Class:-
public class Insurance_List{
    public String id {get;set;}
    public Insurance__c insurance {get;set;}
public Insurance_List(ApexPages.StandardController controller) {
    id = ApexPages.currentPage().getParameters().get('id');
    insurance = [select Code__c,ShortName__c,LongName__c,MinValue__c,MaxValue__c,CheckDigitRule__c from Insurance__c where Id = :id];     
    }
}
Test Class:-
@isTest
public class Insurance_List_Test {

    static testMethod void methodOne(){
           
           Application__c app = TestDataBuilder.createApplication();             
           app.Response_Code__c = 'New';
           insert app;
           System.assertNotEquals(null,app.Id);//assert inserted Application__c
           List<Insurance__c> insurances = new List<Insurance__c>();
           Insurance__c insuranceList =TestDataBuilder.createInsurance(app.Id);
           insuranceList.Code__c = '99999';
           insuranceList.ShortName__c = 'Test';
           insuranceList.LongName__c= 'Test';
           insuranceList.MinValue__c= 200;
           insuranceList.MaxValue__c= 1000;
           insuranceList.CheckDigitRule__c='123';     
           dl.add(insuranceList);
           insert insurances;
           ApexPages.StandardController standardController = new ApexPages.StandardController(insuranceList);           
           APP_Disbursement_List appDisbList = new APP_Disbursement_List(standardController);
    }   
}
Error in Test History:

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Application status already Accepted. You are no longer allowed to insert a record.: []