Skip to content

Commit

Permalink
additional test for polymorphic relationships
Browse files Browse the repository at this point in the history
Test that a CSV file can contain records that map a relationship field to different parent types if the relationship is a polymorphic relationship.
  • Loading branch information
ashitsalesforce committed Feb 6, 2024
1 parent 5ff1cb3 commit 939c5bf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.salesforce.dataloader.action.progress.ILoaderProgress;
import com.salesforce.dataloader.config.Config;
import com.salesforce.dataloader.controller.Controller;
import com.salesforce.dataloader.dyna.RelationshipField;
import com.salesforce.dataloader.exception.DataAccessObjectException;
import com.salesforce.dataloader.exception.ProcessInitializationException;
import com.salesforce.dataloader.exception.UnsupportedOperationException;
Expand Down Expand Up @@ -116,14 +115,18 @@ public void testPolymorphicRelationshipInAttachment() throws ProcessInitializati
AccountGenerator acctGen = new AccountGenerator();
SObject[] parentAccts = new SObject[1];
parentAccts[0] = acctGen.getObject(0, false);

// value of Oracle_id__c = 1-000000
SaveResult[] results = getBinding().create(parentAccts);
parentAccts[0].addField("id", results[0]);


ContactGenerator contactGen = new ContactGenerator();
SObject[] parentContacts = new SObject[1];
parentContacts[0] = contactGen.getObject(0, false);
// value of Oracle_id__c = 1-000000
results = getBinding().create(parentContacts);
parentContacts[0].addField("id", results[0]);

configMap.put(Config.ENTITY, "Attachment");
RelationshipField parentRel = new RelationshipField("Account", "Parent");
parentRel.setParentFieldName(DEFAULT_ACCOUNT_EXT_ID_FIELD);
runProcess(configMap, 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ public SObject getObject(int i, boolean negativeTest) {
contact.setField("Title", titleValue);
contact.setField("Phone", "415-555-" + seqStr);
contact.setField(DEFAULT_CONTACT_EXT_ID_FIELD, (double) i);
contact.setField("Email", "contact"+i+"@testcustomer.com");
return contact;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Name,Body,Parent:Account-Oracle_Id__c
TestAttachment_01.txt,"target/test-classes/testfiles/data/attachment.txt","1-000000"
Name,Body,Parent:Account-Oracle_Id__c,Parent:Contact-Email
accountAttachment.txt,"target/test-classes/testfiles/data/attachment.txt","1-000000",""
contactAttachment.txt,"target/test-classes/testfiles/data/attachment.txt","","[email protected]"
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# salesforceFieldName=csvFieldName
Name=Name
Body=Body
Parent\:Account-Oracle_Id__c=Parent\:Account-Oracle_Id__c
Parent\:Account-Oracle_Id__c=Parent\:Account-Oracle_Id__c
Parent\:Contact-Email=Parent\:Contact-Email

0 comments on commit 939c5bf

Please sign in to comment.