1

I'm trying to create test class for a custom object called "Partner Involvement" under opportunity, which identify the associated reseller or partner for the opportunity. it was working fine with previous sandbox but returning below errors when uploading to new sandbox environment.. could somebody advise me what is wrong with the coding?

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PartnerInvolvementTriggerAll: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 0063K0000025KUXQA2; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityTrigger: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityTrigger: execution of AfterUpdate caused by: System.QueryException: unexpected token: 'FROM' Class.OpportunityRenewalCreation.createRenewalOpportunityWithProducts: line 71, column 1 Class.OpportunityTriggerHandler.processAfterUpdateWithList: line Stack Trace: Class.PartnerInvolvementTriggerAllTest.testCreateByJPCommunity: line 145, column 1

the Apex class is:

@isTest public class PartnerInvolvementTriggerAllTest { @isTest public static void testOpportunityUpdate() { Account acc = new Account (Name = 'newAcc1', BillingCountry ='United Kingdom', Industry = 'Others', RecordTypeId = '01236000000OGv1' );
insert acc;

    Account acc1 = new Account (Name = 'newAcc2',
                               BillingCountry ='Uganda',
                               Industry = 'Others',
                               RecordTypeId = '01236000001UOmp'
                              );        
    insert acc1;

    Opportunity o = new Opportunity(Accountid = acc.id,
                                    StageName = 'Proposal',
                                    CloseDate = system.today(),
                                    Name = 'Test Op',
                                    Type = 'Upsell',
                                    Deal_Type__c = 'Resale',
                                    CurrencyIsoCode = 'EUR',
                                    Led_by__c = 'Direct Led',
                                    LeadSource = 'Partner'                                                                               
                                   );        
    insert o;

    Partner_Involvement__c pic = new Partner_Involvement__c(Partner_Delivery_Role__c = 'Primary

Implementation', Partner_Sales_Role__c = 'Sold to Partner (Buying Directly from UiPath)', Partner_Account_Name__c = acc1.Id,

                                                            CurrencyIsoCode = 'USD',
                                                            PartnerOpp_Name__c = o.Id,
                                                            Partner_Engagement__c = 'Fulfillment'
                                                           );

    test.startTest();

    insert pic; 

    //pic.Partner_Account_Name__c = acc1.Id;
    //pic.Partner_Role__c = 'VAR/Reseller';

    //update pic;

    test.stopTest();

    Opportunity oppTest = [select Id, Sold_to_Partner__c, Implementation_Partner__c from Opportunity where Id =

:pic.PartnerOpp_Name__c];

    System.assertEquals(oppTest.Sold_to_Partner__c, acc1.Id);
    System.assertEquals(oppTest.Implementation_Partner__c, acc1.Id);

    delete pic;
}

@isTest
public static void testCreateByJPCommunity() {
    //user
    String nowStr1 = String.valueOf(Datetime.now()).remove(':').remove(' ').remove('-') +

'1'; Account u_acc = new Account( Name = 'u_hogeAccount' + nowStr1, Country__c = 'Japan', Industry = 'Chemicals' ); insert u_acc;

    Contact u_con = new Contact(
        LastName = 'u_hogeContact' + nowStr1,
        AccountId = u_acc.id
    );
    insert u_con;

    Profile u_prf = [SELECT Id, Name FROM Profile WHERE Name = 'UiPath Japan Partner Community' LIMIT 1];

    User u = new User(
        Email = 'testCreByJP' + nowStr1 + '@example.com',
        profileid = u_prf.id,
        UserName = 'testCreByJP' + nowStr1 + '@example.com',
        Alias = 'testJP',
        TimeZoneSidKey='Asia/Tokyo',
        EmailEncodingKey='UTF-8',
        LocaleSidKey='ja_JP',
        LanguageLocaleKey='ja',
        ContactId = u_con.Id,
        PortalRole = 'Manager',
        FirstName = 'FirstName',
        LastName = 'LastName'
    );
    insert u;

    //account
    String nowStr2 = String.valueOf(Datetime.now()).remove(':').remove(' ').remove('-') +

'2'; RecordType rt = [SELECT Id, SobjectType, DeveloperName FROM RecordType WHERE SobjectType = 'Account' AND DeveloperName = 'Partner' LIMIT 1]; Account acc1 = new Account( Name = 'testCreByJPAcc1' + nowStr2, Country__c = 'Uganda', Industry = 'Chemicals', OwnerId = u.Id, RecordTypeId = rt.Id ); insert acc1;

    Account acc2 = new Account(
        Name = 'testCreByJPAcc2' + nowStr2,
        Country__c = 'Japan',
        Industry = 'Chemicals',
        OwnerId = u.Id,
        RecordTypeId = rt.Id
    );
    insert acc2;

    //opportunity
    Opportunity opp = new Opportunity(
        Accountid = acc1.id,
        StageName = 'Proposal',
        CloseDate = system.today(),
        Name = 'testCreByJPOpp',
        Type = 'Upsell',
        Deal_Type__c = 'Resale',
        CurrencyIsoCode = 'EUR',
        Led_by__c = 'Direct Led',
        LeadSource = 'Partner',
        OwnerId = u.Id
    );
    insert opp;

    //partnerinvolvement
    Partner_Involvement__c pi = new Partner_Involvement__c(
        Partner_Delivery_Role__c = '',
        Partner_Sales_Role__c = 'Sold to Partner (Buying Directly from UiPath)',
        Partner_Account_Name__c = acc2.Id,
        CurrencyIsoCode = 'USD',
        PartnerOpp_Name__c = opp.Id,
        Partner_Engagement__c = '',
        OwnerId = u.Id
    );

    test.startTest();

    System.runAs(u) {
        insert pi;
    }

    test.stopTest();
} }

Thank you and your help is much appreciated!!

0

This is the class you should be looking into: OpportunityRenewalCreation look for a malformed SOQL query on line 71

unexpected token: 'FROM' Class.OpportunityRenewalCreation.createRenewalOpportunityWithProducts: line 71, column 1 Class.OpportunityTriggerHandler.processAfterUpdateWithList

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.