function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Giancarlo AmatiGiancarlo Amati 

changeset validation error on CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

Dear All,
I'm developing a UnitTest class for a legacy Apex class. In the developer console from the full sandbox I get 77% code coverage and no error. When I try to move it to production I get the following error messages:

1. Class Name: UnitTest_MIPLibray, Method Name: testCreateTask:
System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CLDR.OpportunityModified: execution of AfterInsert caused by: System.QueryException: List has no rows for assignment to SObject Trigger.CLDR.OpportunityModified: line 22, column 1: []
Stack Trace: Class.MIPLibrary.createOpportunity: line 1116, column 1 Class.UnitTest_MIPLibrary.testCreateTask: line 574, column 1


2. ClassName: UnitTest_MIPLibrary, Method: testGetContact:
System.StringException: Invalid id: null
Stack Trace: Class.MIPLibrary.hasContactModified: line 820, column 1 Class.MIPLibrary.hasContactModified: line 689, column 1 Class.UnitTest_MIPLibrary.testGetContact: line 481, column 1

I don't understand how to fix it. To me, it all looks legit. The Outbound changeset (from FULL -> Prod), contains both the MIPLibrary and the UnitTest_MIPLibrary, and I validate the deployment only towards the UnitTest_MIPLibrary.

For the (1), this is the code in the unitTest class:
 
static testMethod void testCreateTask() {
        Account testAccount = null;
            testAccount = new Account();
            testAccount.Name = 'TestAccount';
            testAccount.Business_Unit__c = 'Digital Marketing';
            testAccount.Edition_Setup__c = 'Basic';
            testAccount.Naming_rights__c = 'NO';
            testAccount.Naming_Rights_Type__c = 'Full';
            
            Id userId = UserInfo.getUserId();
            User userObj = MIPLibrary.getUsersInfo(userId);
            
            
            
            /*MIPLibrary.createTask(testAccount, userObj, userObj, null, 'MQL', userId, userId, '', '', 'blah', '', '');
            MIPLibrary.createTask(testAccount, userObj, userObj, null, 'SQL', userId, userId, '', '', 'blah', '', '');*/
            MIPLibrary.createTask(testAccount, userObj, userObj, null, 'SAL', userId, userId, '', '', 'blah', '', '');
            
            Opportunity tmpOp = new Opportunity();
            Contact c1 = new Contact();
             c1.lastname = 'TestSALReleaseLastName1';
        c1.Stage_Once__c = 'Prospect';
        c1.Stage_Video_Cloud__c = 'Name';
        c1.accountId = testAccount.id;
        c1.Stage_Once__c = 'Name'; 
        c1.Stage_Video_Cloud__c = 'Prospect'; 
        Set<String> tmpProd = new Set<String>();
        tmpProd.add(MIPLibrary.VIDEO_CLOUD);
        
            MIPLibrary.createOpportunity(tmpOp, MIPLibrary.getOpportunityExistingBusinessRecordTypeId(), testAccount.id, c1.id, 'new opty', '0 - Prospecting',tmpProd, userId );
            
    }

For (2): 
static testMethod void testGetContact() {
       Contact ContactObj2;
        Id currentLoginUserId = UserInfo.getUserId();
        Account testAccount = UnitTest_MIPLibrary.insertAccount('TestSALReleaseModal');
        
        ContactObj2 = new Contact();
        ContactObj2.lastname = 'TestSALReleaseLastName1';
        ContactObj2.Stage_Once__c = 'Prospect';
        ContactObj2.Stage_Video_Cloud__c = 'Name';
        ContactObj2.accountId = testAccount.id;
        ContactObj2.Stage_Once__c = 'Name'; 
        ContactObj2.Stage_Video_Cloud__c = 'Prospect';   
        ContactObj2.MailingStreet = 'Street1';
        ContactObj2.MailingCity = 'City1';
        ContactObj2.MailingState = 'CA';
        ContactObj2.MailingPostalCode = '94588';
        ContactObj2.MailingCountry = 'USA';    
    
        MIPLibrary.getContact(ContactObj2.id, true); 
               
        MIPLibrary.getContact(ContactObj2.id, false); 
        MIPLibrary.hasContactModified(ContactObj2, ContactObj2 );
        
        ContactObj2.Stage_Video_Cloud__c = 'SAL'; 
        
        MIPLibrary.hasContactModified(ContactObj2.id, 'MQL', 'SAL', '');
        
        MIPLibrary.submitQualifying(ContactObj2.id);
        Id tempId = ContactObj2.id;
        MIPLibrary.updateContactRolesStr(tempId);
        
        MIPLibrary.checkContactEligibility(ContactObj2.id,'MQL');
         
    }

Thank you for any help.
GC


 
Omar Rajab 94Omar Rajab 94
Hi Giancarlo, 

Could you please share us the classes you are testing?

regards,
Omar