• Brian Dugan
  • NEWBIE
  • 15 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Our Org is new to creating and editing Apex code. We have run into an issue where the below Apex Class (4 years old) is preventing validation and deployment of any change packages that contain Apex. Based on what we know, this Apex Class is not tied to any Apex Triggers or automation and is purely a validation that was written when our Org was first created. We have checked for any related metadata to this Apex Class and the only related items are the 4 custom fields towards the bottom of the class and they are on the Contract object.

/**
* @author Conga Services
* @date
* @version 1.00
* @description ContractTest  - Test class for the [Name of class being tested] class
*/
@isTest
public with sharing class ContractTest {
    ///////////// ADD JAVA DOC AUTHOR, DATE, AND/OR VERSION TAGS TO METHODS WHEN THE VALUES DIFFER THAN THE CLASS LEVEL TAGS
    /**
    * @description setup - Test data setup method
    */
    @testSetup
    public static void setup(){
        /////// Create your test data here using TestingUtility helper methods
        List<Account> accounts = new List<Account>();
        Account acc = new Account();
        acc.Name = 'Test Account';
        acc.BillingStreet = '1234 Test Street';
        acc.BillingCity = 'Broomfield';
        acc.BillingState = 'CO';
        acc.BillingPostalCode = '80021';
        acc.BillingCountry = 'USA';
        accounts.add(acc);
        Account acc1 = new Account();
        acc1.Name = 'Account Test';
        acc1.BillingStreet = '4321 Test Street';
        acc1.BillingCity = 'Superior';
        acc1.BillingState = 'CO';
        acc1.BillingPostalCode = '80027';
        acc1.BillingCountry = 'USA';
        accounts.add(acc1);
        insert accounts;
        List<Contact> contacts = new List<Contact>();
        Contact contact = new Contact();
        contact.FirstName = 'Test';
        contact.LastName = 'Contact';
        contact.Email = 'test@contact.com';
        contacts.add(contact);
        Contact contact1 = new Contact();
        contact1.FirstName = 'Contact';
        contact1.LastName = 'Test';
        contact1.Email = 'contact@test.com';
        contacts.add(contact1);
        insert contacts;
    }
   
    /**
    * @description testMethod1 - Test Happy Path of code
    */
    public static testMethod void testMethod1() {
        // Get test data
        List<Account> accs = [SELECT Id FROM Account WHERE Name = 'Test Account'];
        List<Contact> cons = [SELECT Id FROM Contact WHERE Email = 'test@contact.com'];
        Contract contract = new Contract();
        contract.Contractor_Consultant_Name__c = 'Test Account';
        contract.BillingStreet = '1234 Test Street';
        contract.BillingCity = 'Broomfield';
        contract.BillingState = 'CO';
        contract.BillingPostalCode = '80021';
        contract.BillingCountry = 'USA';
        contract.Other_Party_Contact_Name__c = 'Test Contact';
        contract.Other_Party_Contact_Email__c = 'test@contact.com';
       
        //ApexPages.StandardController sc = new ApexPages.StandardController(td.Accounts[0]);
        //SubProjectViewController cn = new SubProjectViewController(sc);
        Test.startTest();
        insert contract;
        Contract c = [SELECT AccountId, Other_Party_Contact_Name_Lookup__c FROM Contract WHERE Id = :contract.Id][0];
        System.assertEquals(true, c.AccountId == accs[0].Id,'The fuzzy match did not find the appropriate account');
        System.assertEquals(true, c.Other_Party_Contact_Name_Lookup__c == cons[0].Id,'The fuzzy match did not find the appropriate contact');
        Test.stopTest();//will sync back up with async operations if future/batch called before this
    }  
}


We plan to comment out this code in Production so it will pass validation. The error message we are currently receiving is the following: 

System.UnexpectedException: No more than one executeBatch can be called from within a test method. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.
Stack Trace: External entry point


Given all of this information, are there any obvious concerns we should have before deploying the commented out version in Production? Additionally, are there any tests we should run pre and post update? 

Thanks!
Our Org is new to creating and editing Apex code. We have run into an issue where the below Apex Class (4 years old) is preventing validation and deployment of any change packages that contain Apex. Based on what we know, this Apex Class is not tied to any Apex Triggers or automation and is purely a validation that was written when our Org was first created. We have checked for any related metadata to this Apex Class and the only related items are the 4 custom fields towards the bottom of the class and they are on the Contract object.

/**
* @author Conga Services
* @date
* @version 1.00
* @description ContractTest  - Test class for the [Name of class being tested] class
*/
@isTest
public with sharing class ContractTest {
    ///////////// ADD JAVA DOC AUTHOR, DATE, AND/OR VERSION TAGS TO METHODS WHEN THE VALUES DIFFER THAN THE CLASS LEVEL TAGS
    /**
    * @description setup - Test data setup method
    */
    @testSetup
    public static void setup(){
        /////// Create your test data here using TestingUtility helper methods
        List<Account> accounts = new List<Account>();
        Account acc = new Account();
        acc.Name = 'Test Account';
        acc.BillingStreet = '1234 Test Street';
        acc.BillingCity = 'Broomfield';
        acc.BillingState = 'CO';
        acc.BillingPostalCode = '80021';
        acc.BillingCountry = 'USA';
        accounts.add(acc);
        Account acc1 = new Account();
        acc1.Name = 'Account Test';
        acc1.BillingStreet = '4321 Test Street';
        acc1.BillingCity = 'Superior';
        acc1.BillingState = 'CO';
        acc1.BillingPostalCode = '80027';
        acc1.BillingCountry = 'USA';
        accounts.add(acc1);
        insert accounts;
        List<Contact> contacts = new List<Contact>();
        Contact contact = new Contact();
        contact.FirstName = 'Test';
        contact.LastName = 'Contact';
        contact.Email = 'test@contact.com';
        contacts.add(contact);
        Contact contact1 = new Contact();
        contact1.FirstName = 'Contact';
        contact1.LastName = 'Test';
        contact1.Email = 'contact@test.com';
        contacts.add(contact1);
        insert contacts;
    }
   
    /**
    * @description testMethod1 - Test Happy Path of code
    */
    public static testMethod void testMethod1() {
        // Get test data
        List<Account> accs = [SELECT Id FROM Account WHERE Name = 'Test Account'];
        List<Contact> cons = [SELECT Id FROM Contact WHERE Email = 'test@contact.com'];
        Contract contract = new Contract();
        contract.Contractor_Consultant_Name__c = 'Test Account';
        contract.BillingStreet = '1234 Test Street';
        contract.BillingCity = 'Broomfield';
        contract.BillingState = 'CO';
        contract.BillingPostalCode = '80021';
        contract.BillingCountry = 'USA';
        contract.Other_Party_Contact_Name__c = 'Test Contact';
        contract.Other_Party_Contact_Email__c = 'test@contact.com';
       
        //ApexPages.StandardController sc = new ApexPages.StandardController(td.Accounts[0]);
        //SubProjectViewController cn = new SubProjectViewController(sc);
        Test.startTest();
        insert contract;
        Contract c = [SELECT AccountId, Other_Party_Contact_Name_Lookup__c FROM Contract WHERE Id = :contract.Id][0];
        System.assertEquals(true, c.AccountId == accs[0].Id,'The fuzzy match did not find the appropriate account');
        System.assertEquals(true, c.Other_Party_Contact_Name_Lookup__c == cons[0].Id,'The fuzzy match did not find the appropriate contact');
        Test.stopTest();//will sync back up with async operations if future/batch called before this
    }  
}


We plan to comment out this code in Production so it will pass validation. The error message we are currently receiving is the following: 

System.UnexpectedException: No more than one executeBatch can be called from within a test method. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.
Stack Trace: External entry point


Given all of this information, are there any obvious concerns we should have before deploying the commented out version in Production? Additionally, are there any tests we should run pre and post update? 

Thanks!