### Question:
SalesforceUpsert extends SalesforceStep { void setFieldInSObject( SObject sobjPass, XmlObject element ) { Iterator<XmlObject> children = element.getChildren(); String name = element.getName().getLocalPart(); if ( !children.hasNext() ) { sobjPass.setSObjectField( name, element.getValue() ); } else { SObject child = new SObject(); child.setName( new QName( name ) ); while ( children.hasNext() ) { setFieldInSObject( child, children.next() ); } sobjPass.setSObjectField( name, child ); } } SalesforceUpsert( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr,
    TransMeta transMeta, Trans trans ); @Override boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi );  }### Answer:
@Test public void testSetFieldInSObjectForeignKey() throws Exception { SalesforceUpsert salesforceUpsert = new SalesforceUpsert( smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans ); SObject sobjPass = new SObject(); XmlObject parentObject = new XmlObject(); String parentParam = "parentParam"; String parentValue = "parentValue"; parentObject.setName( new QName( parentParam ) ); parentObject.setValue( parentValue ); String child = "child"; String childParam = "childParam"; String childValue = "childValue"; XmlObject childObject = new XmlObject(); childObject.setName( new QName( child ) ); childObject.setField( childParam, childValue ); salesforceUpsert.setFieldInSObject( sobjPass, parentObject ); salesforceUpsert.setFieldInSObject( sobjPass, childObject ); Assert.assertEquals( parentValue, sobjPass.getField( parentParam ) ); Assert.assertEquals( childValue, ( (SObject) sobjPass.getField( child ) ).getField( childParam ) ); }