[SalesForce] FIELD_INTEGRITY_EXCEPTION Error in Test class

am getting Field integrity exception error on test class – test class not passing,below is my test class code

@isTest(seeAllData=false)
private class ToInsertClaimsFromImportClaimTest{
Public static List<Patent__c> AssetList;
public static List<ClaimImport__c> claimIList;
public static List<Claim_v1__c> claimList;

static void init(){
AssetList = new List<Patent__c>();
claimIList= new List<ClaimImport__c>();
claimList= new List<Claim_v1__c>();
AssetList.add(new Patent__c(
    Title_of_Invention__c= 'test'
));
insert AssetList;
Claim_v1__c clm = new Claim_v1__c(Name='Claim Test',Asset__c=AssetList[0].id); 
System.assertEquals(clm.Name,'Claim Test');
}


static testMethod void testWithExistingContact() {
init();
Test.startTest();
claimIList.add(new ClaimImport__c(
    Asset__C = AssetList[0].id,Claims__c='[!1!] Test1 [!2!] Test2 Claim 1 [!3!] Test3 Claim 1 [!4!] Test4 Claim 2 [!5!] Test5 [!6!] Test6 Claim 5 [!7!] Test7 Claim 3'
));
insert claimIList;
Test.stopTest();
}}

This is error message am getting:

Error Message: System.DmlException: Insert failed. First exception on
row 0; first error: FIELD_INTEGRITY_EXCEPTION, Asset: id value of
incorrect type: a2z36000000z7YJAAY: [SymphonyIAM__Asset__c]

Stack
Trace Class.SymphonyIAM.ToInsertClaimsFromImportClaimTest.testWithExistingContact:
line 26, column 1

Best Answer

As per the error message, You are not populating correct value for Asset lookup field.

At Line number 23, make sure that you are populating Asset lookup field on ClaimImport__c record with correct Asset Id.

Related Topic