You need to sign in to do that
Don't have an account?

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, UpdateEscalation: execution of BeforeInsert .. Class.TestCloseParentCase.TestCloseParentCase: line 143, column 1
Hai i am getting this error while i test the test class...please anyone help me on this ........
below is my test class
@isTest
Private class TestCloseParentCase{
static testMethod void TestCloseParentCase() {
Profile p = [select id from Profile where name = 'Custom - RSE'];
User TestUser = new User(Alias = 'newUser', Email='newuser@testorg.com',
EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles', UserName='newuser@test.philips.com', I3_Username__c = 'TestUser');
insert TestUser;
System.runAs(TestUser){
OneEmsRecordTypes__c cs = new OneEmsRecordTypes__c(name='Case',Active__c = true, Description__c = 'Test Data' );
insert cs;
OneEmsRecordTypes__c cs1 = new OneEmsRecordTypes__c(name='Closed Case',Active__c = true, Description__c = 'Test Data' );
insert cs1;
OneEmsRecordTypes__c cs2 = new OneEmsRecordTypes__c(name='Case - New',Active__c = true, Description__c = 'Test Data' );
insert cs2;
OneEmsRecordTypes__c cs3 = new OneEmsRecordTypes__c(name='Case - SubCase',Active__c = true, Description__c = 'Test Data' );
insert cs3;
Account Acc = new Account( Name='Test Account', Credit_status__c='Good',Account_Group__c = '0001' );
insert Acc;
Contact Con = new Contact( FirstName = 'Test', LastName ='Contact', AccountID = Acc.id, Phone ='1234567890');
insert Con;
Functional_Location__c FnLocation = new Functional_Location__c(Name='TestFunctionalLocation');
insert FnLocation;
Asset Assets = new Asset( Name = 'Test Asset',Plant__c = 'US', AccountId = Acc.Id, Main_Workcenter__c = 'Test', Functional_Location__c = FnLocation.id);
insert Assets;
Product2 prd=new Product2(name='Test Product');
insert prd;
ServiceContract Scon = new ServiceContract(Name='Test Service contract',AccountId=Acc.Id,ContactId=Con.Id);
insert Scon;
Line_Item__c LineItem = new Line_Item__c(Name ='Test line Item',
Ship_To__c = Acc.Id,
Bill_To__c = Acc.Id,
Payor__c = Acc.Id,
Sold_To__c = Acc.Id,
Start_Date__c = system.Today(),
End_Date__c = system.Today().addDays(30),
Service_Contract__c = Scon.ID);
insert LineItem;
Entitlement Ent = new Entitlement(
Name = 'Test Entitlement',
AssetId = Assets.Id,
AccountId = Acc.id,
Line_Item__c = LineItem.Id,
Case_Priorities_Covered__c = 'Priority 1-2'
);
insert Ent;
Id RecordTypId = [select id from RecordType where Name =:'Case' limit 1].Id;
Id SubcaseRecordTypId = [select id from RecordType where Name =:'Case - SubCase' limit 1].Id;
Id subCaseActionPlanRes = [select id from RecordType where Name =: 'Subcase Response' limit 1].Id;
Id subCaseActionPlan = [select id from RecordType where Name =: 'Subcase Action Plan' limit 1].Id;
OneEMSTriggerHelper.CaseFieldUpdatesExecuted();
OneEMSTriggerHelper.CaseAfterUpsertTriggerExecuted();
Case ParentCase= new Case(
Entitlement_Category__c ='Contract',
AccountID=Acc.id,
AssetID = Assets.id,
RecordTypeId = RecordTypId,
ContactID= Con.Id,
Priority = '1-Critical Need',
Description = 'Test Data' ,
//Status='New',
Type='Email',
Origin='Email',
Credit_Status_Override__c=false,
ProductId=prd.Id,
Service_Contract__c =Scon.Id,
Customer_Unable_to_Provide__c = True,
Reason='Application Support',
EntitlementId = Ent.Id
);
insert ParentCase;
System.Debug('#Parent Case : '+ParentCase);
Case subcase=new Case(
ParentId =ParentCase.Id,
AccountID=Acc.id,
RecordTypeId = SubcaseRecordTypId,
Problem_Description__c='test',
Previous_Actions__c='test',
Replaced_Parts__c='test',
Status='New',
Problem_Occurrence__c=system.now(),
Priority = '1-Critical Need',
Customer_Unable_to_Provide__c = True);
insert subcase;
System.Debug('#Sub Case : '+subcase);
Action_Plan__c actionPlan = new Action_Plan__c(
Name = 'Test Action Plan',
Status__c = 'New',
Action_Plan_Executor_Role__c ='L1 Owner',
Sub_Case__c = subcase.Id,
Information_Only__c = false,
RecordTypeId = subCaseActionPlan,
Next_PAO__c = TestUser.Id,
Next_Action_Due_Date__c = System.Today()
);
insert actionPlan;
actionPlan.Status__c = 'Submitted';
update actionPlan;
/***calling starttest() to start test to avoid hitting SOQL Row limit ***/
Test.starttest();
Action_Plan__c actionPlanResp = new Action_Plan__c(
Name = 'Test Action Plan',
Status__c = 'New',
Action_Plan__c = actionPlan.Id,
RecordTypeId = subCaseActionPlanRes ,
Action_Plan_Executor_Role__c ='L1 Owner',
Sub_Case__c = subcase.Id
//Information_Only__c = false,
//Next_Action_Due_Date__c = null
);
insert actionPlanResp;
actionPlanResp.Status__c = 'Submitted';
update actionPlanResp;
try{
subcase.Status = 'Closed';
update subcase;
}catch(Exception e){
System.Debug('#Exception'+e);
System.assertEquals('FIELD_CUSTOM_VALIDATION_EXCEPTION', e.getDmlStatusCode(0));
}
ParentCase.Status = 'Fixed';
ParentCase.Reason = 'Void';
update ParentCase;
Test.stoptest();
/***calling stoptest() to avoid hitting SOQL Row limit ***/
}
}
}
below is my test class
@isTest
Private class TestCloseParentCase{
static testMethod void TestCloseParentCase() {
Profile p = [select id from Profile where name = 'Custom - RSE'];
User TestUser = new User(Alias = 'newUser', Email='newuser@testorg.com',
EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles', UserName='newuser@test.philips.com', I3_Username__c = 'TestUser');
insert TestUser;
System.runAs(TestUser){
OneEmsRecordTypes__c cs = new OneEmsRecordTypes__c(name='Case',Active__c = true, Description__c = 'Test Data' );
insert cs;
OneEmsRecordTypes__c cs1 = new OneEmsRecordTypes__c(name='Closed Case',Active__c = true, Description__c = 'Test Data' );
insert cs1;
OneEmsRecordTypes__c cs2 = new OneEmsRecordTypes__c(name='Case - New',Active__c = true, Description__c = 'Test Data' );
insert cs2;
OneEmsRecordTypes__c cs3 = new OneEmsRecordTypes__c(name='Case - SubCase',Active__c = true, Description__c = 'Test Data' );
insert cs3;
Account Acc = new Account( Name='Test Account', Credit_status__c='Good',Account_Group__c = '0001' );
insert Acc;
Contact Con = new Contact( FirstName = 'Test', LastName ='Contact', AccountID = Acc.id, Phone ='1234567890');
insert Con;
Functional_Location__c FnLocation = new Functional_Location__c(Name='TestFunctionalLocation');
insert FnLocation;
Asset Assets = new Asset( Name = 'Test Asset',Plant__c = 'US', AccountId = Acc.Id, Main_Workcenter__c = 'Test', Functional_Location__c = FnLocation.id);
insert Assets;
Product2 prd=new Product2(name='Test Product');
insert prd;
ServiceContract Scon = new ServiceContract(Name='Test Service contract',AccountId=Acc.Id,ContactId=Con.Id);
insert Scon;
Line_Item__c LineItem = new Line_Item__c(Name ='Test line Item',
Ship_To__c = Acc.Id,
Bill_To__c = Acc.Id,
Payor__c = Acc.Id,
Sold_To__c = Acc.Id,
Start_Date__c = system.Today(),
End_Date__c = system.Today().addDays(30),
Service_Contract__c = Scon.ID);
insert LineItem;
Entitlement Ent = new Entitlement(
Name = 'Test Entitlement',
AssetId = Assets.Id,
AccountId = Acc.id,
Line_Item__c = LineItem.Id,
Case_Priorities_Covered__c = 'Priority 1-2'
);
insert Ent;
Id RecordTypId = [select id from RecordType where Name =:'Case' limit 1].Id;
Id SubcaseRecordTypId = [select id from RecordType where Name =:'Case - SubCase' limit 1].Id;
Id subCaseActionPlanRes = [select id from RecordType where Name =: 'Subcase Response' limit 1].Id;
Id subCaseActionPlan = [select id from RecordType where Name =: 'Subcase Action Plan' limit 1].Id;
OneEMSTriggerHelper.CaseFieldUpdatesExecuted();
OneEMSTriggerHelper.CaseAfterUpsertTriggerExecuted();
Case ParentCase= new Case(
Entitlement_Category__c ='Contract',
AccountID=Acc.id,
AssetID = Assets.id,
RecordTypeId = RecordTypId,
ContactID= Con.Id,
Priority = '1-Critical Need',
Description = 'Test Data' ,
//Status='New',
Type='Email',
Origin='Email',
Credit_Status_Override__c=false,
ProductId=prd.Id,
Service_Contract__c =Scon.Id,
Customer_Unable_to_Provide__c = True,
Reason='Application Support',
EntitlementId = Ent.Id
);
insert ParentCase;
System.Debug('#Parent Case : '+ParentCase);
Case subcase=new Case(
ParentId =ParentCase.Id,
AccountID=Acc.id,
RecordTypeId = SubcaseRecordTypId,
Problem_Description__c='test',
Previous_Actions__c='test',
Replaced_Parts__c='test',
Status='New',
Problem_Occurrence__c=system.now(),
Priority = '1-Critical Need',
Customer_Unable_to_Provide__c = True);
insert subcase;
System.Debug('#Sub Case : '+subcase);
Action_Plan__c actionPlan = new Action_Plan__c(
Name = 'Test Action Plan',
Status__c = 'New',
Action_Plan_Executor_Role__c ='L1 Owner',
Sub_Case__c = subcase.Id,
Information_Only__c = false,
RecordTypeId = subCaseActionPlan,
Next_PAO__c = TestUser.Id,
Next_Action_Due_Date__c = System.Today()
);
insert actionPlan;
actionPlan.Status__c = 'Submitted';
update actionPlan;
/***calling starttest() to start test to avoid hitting SOQL Row limit ***/
Test.starttest();
Action_Plan__c actionPlanResp = new Action_Plan__c(
Name = 'Test Action Plan',
Status__c = 'New',
Action_Plan__c = actionPlan.Id,
RecordTypeId = subCaseActionPlanRes ,
Action_Plan_Executor_Role__c ='L1 Owner',
Sub_Case__c = subcase.Id
//Information_Only__c = false,
//Next_Action_Due_Date__c = null
);
insert actionPlanResp;
actionPlanResp.Status__c = 'Submitted';
update actionPlanResp;
try{
subcase.Status = 'Closed';
update subcase;
}catch(Exception e){
System.Debug('#Exception'+e);
System.assertEquals('FIELD_CUSTOM_VALIDATION_EXCEPTION', e.getDmlStatusCode(0));
}
ParentCase.Status = 'Fixed';
ParentCase.Reason = 'Void';
update ParentCase;
Test.stoptest();
/***calling stoptest() to avoid hitting SOQL Row limit ***/
}
}
}


This is caused by the trigger. Check the line number mentioned in the error in the trigger.

Thank you