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

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() {
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;

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

2 Answers 2


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.


Given that AssetList holds a list of Patent__c objects:

Public static List<Patent__c> AssetList;

it is pretty unlikely that the following statement and similar statements are correct because lookup field names by default match the type name of the object they reference which in this case is Asset__c:

Claim_v1__c clm = new Claim_v1__c(Name='Claim Test',Asset__c=AssetList[0].id);

and the detail of the error message confirms that.

You need to review the data model and figure out how to connect the correct types of objects up in the test.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .