1

When I try to deploy a simple apex trigger and test class, I can't seem to pass due to third party app called accounting books. I tried to pass these trigger and test class from other Salesforce instance and had 100% coverage. What ever trigger or test classes I write, I get these errors.

All these tests that are failing are from the third party app called accounting books. Any idea what these errors are about and how I can fix them? enter image description here

enter image description here

 @isTest(SeeAllData=true)
private class DonationToSalesReceiptTest {
  static testMethod void test() {
    List<AVAB__GL_Account__c> glAccountList=new List<AVAB__GL_Account__c>();
    List<Retreat__c> retreatObjList=new List<Retreat__c>();
    List<SFDC_Retreat_Staff__c> retreatStaffList=new List<SFDC_Retreat_Staff__c>();
    List<Opportunity> oppObjList=new List<Opportunity>();

    RecordType rtObj = [select id, Name from RecordType where Name =:'Sales Receipt'];
    system.assertEquals('Sales Receipt',rtObj.Name);

        Account accountObj=new Account(Name ='TestSoAcc',BillingStreet='ABC Street',BillingState='Tamilnadu',BillingPostalCode='636010',BillingCountry='India',BillingCity='Chennai');
        insert accountObj;

        Contact contactObj=new Contact(LastName='TestLastName',FirstName='TestFirstName',Contact_Type__c='Individual',AccountId=accountObj.Id);
        insert contactObj;

        AVAB__GL_Account__c glAccount1= new AVAB__GL_Account__c(AVAB__Account_Type__c='Income',Name='4281.1 - Winter Retreat Registration Inc');
        glAccountList.add(glAccount1);

        AVAB__GL_Account__c glAccount2= new AVAB__GL_Account__c(AVAB__Account_Type__c='Income',Name='4282.1 - Spring Retreat Registration Inc');
        glAccountList.add(glAccount2);

        AVAB__GL_Account__c glAccount3= new AVAB__GL_Account__c(AVAB__Account_Type__c='Income',Name='4283.1 - Summer Retreat Registration Inc');
        glAccountList.add(glAccount3);

        AVAB__GL_Account__c glAccount4= new AVAB__GL_Account__c(AVAB__Account_Type__c='Income',Name='4284.1 - Fall Retreat Registration Income');
        glAccountList.add(glAccount4);

        AVAB__GL_Account__c glAccount5= new AVAB__GL_Account__c(AVAB__Account_Type__c='Income',Name='4082 - Grants');
        glAccountList.add(glAccount5);

        AVAB__GL_Account__c glAccount6= new AVAB__GL_Account__c(AVAB__Account_Type__c='Income',Name='4056 - Unbudgeted Projects');
        glAccountList.add(glAccount6);

        AVAB__GL_Account__c glAccount7= new AVAB__GL_Account__c(AVAB__Account_Type__c='Income',Name='4081 - Marketplace Partners');
        glAccountList.add(glAccount7);

        AVAB__GL_Account__c glAccount8= new AVAB__GL_Account__c(AVAB__Account_Type__c='Income',Name='4055 - Donations - General Fund');
        glAccountList.add(glAccount8);


        insert glAccountList;

        Retreat__c retreatObj1=new Retreat__c(Season__c='Winter',Name='Test Winter Retreat',GL_Account__c=glAccount1.Id,Retreat_Type__c='THRIVE',
          Retreat_Speaker_Last_Name__c='TestWinterSpeaker',Retreat_Speaker_Info__c='XYZ',Retreat_Email_Address__c='Winter@gmail.com',
          Retreat_Coordinator_Title__c='Speaker',Retreat_Coordinator_Name__c='Bals.s',Retreat_Speaker_First_Name__c='Bala',Current_Retreat__c=true);

        retreatObjList.add(retreatObj1);

        Retreat__c retreatObj2=new Retreat__c(Season__c='Spring',Name='Test Spring Retreat',GL_Account__c=glAccount2.Id,Retreat_Type__c='THRIVE',
          Retreat_Speaker_Last_Name__c='TestSpringSpeaker',Retreat_Speaker_Info__c='XYZ',Retreat_Email_Address__c='Spring@gmail.com',
          Retreat_Coordinator_Title__c='Speaker',Retreat_Coordinator_Name__c='Bals.s',Retreat_Speaker_First_Name__c='Bala',Current_Retreat__c=true);

        retreatObjList.add(retreatObj2);


        Retreat__c retreatObj3=new Retreat__c(Season__c='Summer',Name='Test Summer Retreat',GL_Account__c=glAccount3.Id,Retreat_Type__c='THRIVE',
          Retreat_Speaker_Last_Name__c='TestSummerSpeaker',Retreat_Speaker_Info__c='XYZ',Retreat_Email_Address__c='Summer@gmail.com',
          Retreat_Coordinator_Title__c='Speaker',Retreat_Coordinator_Name__c='Bals.s',Retreat_Speaker_First_Name__c='Bala',Current_Retreat__c=true);

        retreatObjList.add(retreatObj3);


        Retreat__c retreatObj4=new Retreat__c(Season__c='Fall',Name='Test Winter Retreat',GL_Account__c=glAccount4.Id,Retreat_Type__c='THRIVE',
          Retreat_Speaker_Last_Name__c='TestFallSpeaker',Retreat_Speaker_Info__c='XYZ',Retreat_Email_Address__c='Fall@gmail.com',
          Retreat_Coordinator_Title__c='Speaker',Retreat_Coordinator_Name__c='Bals.s',Retreat_Speaker_First_Name__c='Bala',Current_Retreat__c=true);

        retreatObjList.add(retreatObj4);

        /*
        Retreat__c retreatObj5=new Retreat__c(Season__c='Thrive300',Name='Test Thrive300 Retreat',GL_Account__c=glAccount5.Id,Retreat_Type__c='THRIVE',
          Retreat_Speaker_Last_Name__c='TestThrive300Speaker',Retreat_Speaker_Info__c='XYZ',Retreat_Email_Address__c='Thrive300@gmail.com',
          Retreat_Coordinator_Title__c='Speaker',Retreat_Coordinator_Name__c='Bals.s',Retreat_Speaker_First_Name__c='Bala',Current_Retreat__c=true);

        retreatObjList.add(retreatObj5);
        */

        insert retreatObjList;



        SFDC_Retreat_Staff__c retreatStaffObj1=new SFDC_Retreat_Staff__c(Skills__c='Color Analyst',Approval_Status__c='Approved',
          Retreat__c=retreatObj1.Id,Contact__c=contactObj.Id);

        retreatStaffList.add(retreatStaffObj1);

        SFDC_Retreat_Staff__c retreatStaffObj2=new SFDC_Retreat_Staff__c(Skills__c='Color Analyst',Approval_Status__c='Approved',
          Retreat__c=retreatObj2.Id,Contact__c=contactObj.Id);

        retreatStaffList.add(retreatStaffObj2);

        SFDC_Retreat_Staff__c retreatStaffObj3=new SFDC_Retreat_Staff__c(Skills__c='Color Analyst',Approval_Status__c='Approved',
          Retreat__c=retreatObj3.Id,Contact__c=contactObj.Id);

        retreatStaffList.add(retreatStaffObj3);  

        SFDC_Retreat_Staff__c retreatStaffObj4=new SFDC_Retreat_Staff__c(Skills__c='Color Analyst',Approval_Status__c='Approved',
          Retreat__c=retreatObj4.Id,Contact__c=contactObj.Id);

        retreatStaffList.add(retreatStaffObj4);  



        insert retreatStaffList;

        //Donation Type:Retreat Specific

        Opportunity oppObject1=new Opportunity(Name='Testopp1',AccountId=accountObj.Id,Amount=90,StageName='Posted',Retreat__c=retreatObj1.Id,
          Retreat_Staff__c=retreatStaffObj1.Id,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Retreat Specific',Donation_Description__c='Attendee Registration Fee');

        oppObjList.add(oppObject1);

        Opportunity oppObject2=new Opportunity(Name='Testopp2',AccountId=accountObj.Id,Amount=90,StageName='Posted',Retreat__c=retreatObj2.Id,
          Retreat_Staff__c=retreatStaffObj2.Id,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Retreat Specific',Donation_Description__c='Attendee Registration Fee');

        oppObjList.add(oppObject2);

        Opportunity oppObject3=new Opportunity(Name='Testopp3',AccountId=accountObj.Id,Amount=90,StageName='Posted',Retreat__c=retreatObj3.Id,
          Retreat_Staff__c=retreatStaffObj3.Id,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Retreat Specific',Donation_Description__c='Attendee Registration Fee');

        oppObjList.add(oppObject3);

        Opportunity oppObject4=new Opportunity(Name='Testopp4',AccountId=accountObj.Id,Amount=90,StageName='Posted',Retreat__c=retreatObj4.Id,
          Retreat_Staff__c=retreatStaffObj4.Id,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Retreat Specific',Donation_Description__c='Attendee Registration Fee');

        oppObjList.add(oppObject4);

        Opportunity oppObject5=new Opportunity(Name='Testopp5',AccountId=accountObj.Id,Amount=90,StageName='Posted',
          CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='General Income',Donation_Description__c='Grants');

        oppObjList.add(oppObject5);


        //Donation Type:General Income

         Opportunity oppObject6=new Opportunity(Name='Testopp6',AccountId=accountObj.Id,Amount=90,StageName='Posted',
           CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='General Income',Donation_Description__c='SMEP');

        oppObjList.add(oppObject6);

        Opportunity oppObject7=new Opportunity(Name='Testopp7',AccountId=accountObj.Id,Amount=90,StageName='Posted',
           CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='General Income',Donation_Description__c='Candace Ream-Support');

        oppObjList.add(oppObject7);

        Opportunity oppObject8=new Opportunity(Name='Testopp8',AccountId=accountObj.Id,Amount=90,StageName='Posted',
           CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='General Income',Donation_Description__c='Health Insurance');

        oppObjList.add(oppObject8);

        Opportunity oppObject9=new Opportunity(Name='Testopp9',AccountId=accountObj.Id,Amount=90,StageName='Posted',
           CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='General Income',Donation_Description__c='Carter - Support');

        oppObjList.add(oppObject9);

        Opportunity oppObject10=new Opportunity(Name='Testopp10',AccountId=accountObj.Id,Amount=90,StageName='Posted',
           CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='General Income',Donation_Description__c='Interest Income');

        oppObjList.add(oppObject10);

         Opportunity oppObject11=new Opportunity(Name='Testopp11',AccountId=accountObj.Id,Amount=90,StageName='Posted'
           ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='General Income',Donation_Description__c='Kristy Wacek-Support');

        oppObjList.add(oppObject11);

         Opportunity oppObject12=new Opportunity(Name='Testopp12',AccountId=accountObj.Id,Amount=90,StageName='Posted'
           ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='General Income',Donation_Description__c='Non Budgeted Projects');

        oppObjList.add(oppObject12);

         Opportunity oppObject13=new Opportunity(Name='Testopp13',AccountId=accountObj.Id,Amount=90,StageName='Posted'
           ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='General Income',Donation_Description__c='Special Projects');

        oppObjList.add(oppObject13);

        //Donation Type:Donation one Time     


         Opportunity oppObject14=new Opportunity(Name='Testopp14',AccountId=accountObj.Id,Amount=90,StageName='Posted'
           ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation One Time',Donation_Description__c='Agency Gift');

        oppObjList.add(oppObject14);

         Opportunity oppObject15=new Opportunity(Name='Testopp15',AccountId=accountObj.Id,Amount=90,StageName='Posted'
           ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation One Time',Donation_Description__c='Alumni');

        oppObjList.add(oppObject15);

        Opportunity oppObject16=new Opportunity(Name='Testopp16',AccountId=accountObj.Id,Amount=90,StageName='Posted'
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation One Time',Donation_Description__c='Annual Celebration Event');

        oppObjList.add(oppObject16);

        Opportunity oppObject17=new Opportunity(Name='Testopp17',AccountId=accountObj.Id,Amount=90,StageName='Posted'
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation One Time',Donation_Description__c='Church Gifts');

        oppObjList.add(oppObject17);

        Opportunity oppObject18=new Opportunity(Name='Testopp18',AccountId=accountObj.Id,Amount=90,StageName='Posted'
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation One Time',Donation_Description__c='General');

        oppObjList.add(oppObject18);

        Opportunity oppObject19=new Opportunity(Name='Testopp19',AccountId=accountObj.Id,Amount=90,StageName='Posted'
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation One Time',Donation_Description__c='General');

        oppObjList.add(oppObject19);

        Opportunity oppObject20=new Opportunity(Name='Testopp20',AccountId=accountObj.Id,Amount=90,StageName='Posted'
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation One Time',Donation_Description__c='General');

        oppObjList.add(oppObject20);

        Opportunity oppObject21=new Opportunity(Name='Testopp21',AccountId=accountObj.Id,Amount=90,StageName='Posted'
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation One Time',Donation_Description__c='Marketplace Partners');

        oppObjList.add(oppObject21);

        Opportunity oppObject22=new Opportunity(Name='Testopp22',AccountId=accountObj.Id,Amount=90,StageName='Posted'
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation One Time',Donation_Description__c='Matching Challenge');

        oppObjList.add(oppObject22);

        Opportunity oppObject23=new Opportunity(Name='Testopp23',AccountId=accountObj.Id,Amount=90,StageName='Posted'
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation Recurring',Donation_Description__c='President'+'\'s Circle');

        oppObjList.add(oppObject23);


        Opportunity oppObject24=new Opportunity(Name='Testopp24',AccountId=accountObj.Id,Amount=90,StageName='Posted'
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation Recurring',Donation_Description__c='President'+'\'s Associate');

        oppObjList.add(oppObject24);

        Opportunity oppObject25=new Opportunity(Name='Testopp25',AccountId=accountObj.Id,Amount=90,StageName='Posted'
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation Recurring',Donation_Description__c='Recurring Pledge');

        oppObjList.add(oppObject25);

        Opportunity oppObject26=new Opportunity(Name='Testopp26',AccountId=accountObj.Id,Amount=90,StageName='Posted'
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation Recurring',Donation_Description__c='Giving First');

        oppObjList.add(oppObject26);

        Opportunity oppObject27=new Opportunity(Name='Testopp27',AccountId=accountObj.Id,Amount=90,StageName='Posted',Retreat__c = retreatObj1.id
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Retreat Specific',Donation_Description__c='Attendee Sponsor');

        oppObjList.add(oppObject27);

        Opportunity oppObject28=new Opportunity(Name='Testopp28',AccountId=accountObj.Id,Amount=90,StageName='Posted',Retreat__c = retreatObj2.id
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Retreat Specific',Donation_Description__c='Attendee Sponsor');

        oppObjList.add(oppObject28);

        Opportunity oppObject29=new Opportunity(Name='Testopp29',AccountId=accountObj.Id,Amount=90,StageName='Posted',Retreat__c = retreatObj3.id
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Retreat Specific',Donation_Description__c='Attendee Sponsor');

        oppObjList.add(oppObject29);

        Opportunity oppObject30=new Opportunity(Name='Testopp30',AccountId=accountObj.Id,Amount=90,StageName='Posted',Retreat__c = retreatObj4.id
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Retreat Specific',Donation_Description__c='Attendee Sponsor');

        oppObjList.add(oppObject30);

        Opportunity oppObject31=new Opportunity(Name='Testopp31',AccountId=accountObj.Id,Amount=90,StageName='Posted'
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Donation One Time',Donation_Description__c='Year End Donation');

        oppObjList.add(oppObject31);        

        Opportunity oppObject32=new Opportunity(Name='Testopp32',AccountId=accountObj.Id,Amount=90,StageName='Posted',Retreat__c = retreatObj1.id
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Retreat Specific',Donation_Description__c='Volunteer Staff Sponsor');

        oppObjList.add(oppObject32);

        Opportunity oppObject33=new Opportunity(Name='Testopp33',AccountId=accountObj.Id,Amount=90,StageName='Posted',Retreat__c = retreatObj2.id
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Retreat Specific',Donation_Description__c='Volunteer Staff Sponsor');

        oppObjList.add(oppObject33);

        Opportunity oppObject34=new Opportunity(Name='Testopp34',AccountId=accountObj.Id,Amount=90,StageName='Posted',Retreat__c = retreatObj3.id
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Retreat Specific',Donation_Description__c='Volunteer Staff Sponsor');

        oppObjList.add(oppObject34);

        Opportunity oppObject35=new Opportunity(Name='Testopp35',AccountId=accountObj.Id,Amount=90,StageName='Posted',Retreat__c = retreatObj4.id
          ,CloseDate=System.now().date(),ForecastCategoryName='Closed',Type='Retreat Specific',Donation_Description__c='Volunteer Staff Sponsor');

        oppObjList.add(oppObject35);
        //Donation Type:Donation one Time   

        insert oppObjList;

        delete oppObjList;
        //oppObject.StageName = 'Posted';
        //oppObject.ForecastCategoryName = 'Closed';

        //update oppObject;


    }

}
  • Can you post code of one of your triggers, say triggerDonationToSalesRecepit. This error is Typically in cases when you update or insert a record with some required field missing. Also check this salesforce.stackexchange.com/questions/31118/… – A-d Sep 16 '14 at 6:48
  • I added the DonationToSalesReceiptTest, and this wasn't written by me but the third party app. – Anthony Gawon Lee Sep 16 '14 at 7:00
  • Test class is not of much help. The issue seems to be in SalesReceiptService class line number 347 which is being called from triggerDonationToSalesRecepit trigger. Check if the variable you are upserting in line 347 has field AVAB__Journal_Entry__c or not? – A-d Sep 16 '14 at 7:31
1

All of the test failures reported are caused by the field AVAB__Journal_Entry__c. It is a required field, but is not populated in the test data created in all of the failing tests. This often happens when a field that was not required when the code was installed is made into a required field subsequently.

You can possibly (not sure if managed package fields allow this) unset the field's "Required" flag, then deploy, then set it back again. Or you can fix the tests so that whatever is creating the record with the field AVAB__Journal_Entry__c populates that field.

  • Thanks Dominic, I will try to contact the third party app developers since they are managed apps. – Anthony Gawon Lee Sep 17 '14 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.