### Question:
SalesforceInputDialog extends SalesforceStepDialog { void addFields( String prefix, Set<String> fieldNames, XmlObject field ) { if ( isNullIdField( field ) ) { return; } String fieldname = prefix + field.getName().getLocalPart(); if ( field instanceof SObject ) { SObject sobject = (SObject) field; for ( XmlObject element : SalesforceConnection.getChildren( sobject ) ) { addFields( fieldname + ".", fieldNames, element ); } } else { addField( fieldname, fieldNames, (String) field.getValue() ); } } SalesforceInputDialog( Shell parent, Object in, TransMeta transMeta, String sname ); @Override String open(); void getData( SalesforceInputMeta in ); void setPosition();  }### Answer:
@Test public void testAddFieldsFromSOQLQuery() throws Exception { final Set<String> fields = new LinkedHashSet<>(); XmlObject testObject = createObject( "Field1", VALUE, ObjectType.XMLOBJECT ); dialog.addFields( "", fields, testObject ); dialog.addFields( "", fields, testObject ); assertArrayEquals( "No duplicates", new String[]{"Field1"}, fields.toArray() ); testObject = createObject( "Field2", VALUE, ObjectType.XMLOBJECT ); dialog.addFields( "", fields, testObject ); assertArrayEquals( "Two fields", new String[]{"Field1", "Field2"}, fields.toArray() ); }
@Test public void testAddFields_nullIdNotAdded() throws Exception { final Set<String> fields = new LinkedHashSet<>(); XmlObject testObject = createObject( "Id", null, ObjectType.XMLOBJECT ); dialog.addFields( "", fields, testObject ); assertArrayEquals( "Null Id field not added", new String[]{}, fields.toArray() ); }
@Test public void testAddFields_IdAdded() throws Exception { final Set<String> fields = new LinkedHashSet<>(); XmlObject testObject = createObject( "Id", VALUE, ObjectType.XMLOBJECT ); dialog.addFields( "", fields, testObject ); assertArrayEquals( "Id field added", new String[]{"Id"}, fields.toArray() ); }