### Question:
FieldSplitter extends BaseTransform<FieldSplitterMeta, FieldSplitterData> implements ITransform<FieldSplitterMeta, FieldSplitterData> { @Override public synchronized boolean processRow() throws HopException { Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } Object[] outputRowData = splitField( r ); putRow( data.outputMeta, outputRowData ); if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "FieldSplitter.Log.LineNumber" ) + getLinesRead() ); } } return true; } FieldSplitter( TransformMeta transformMeta, FieldSplitterMeta meta, FieldSplitterData data, int copyNr, PipelineMeta pipelineMeta,
                        Pipeline pipeline ); @Override synchronized boolean processRow();  }### Answer:
@Test public void testSplitFields() throws HopException { FieldSplitter transform = new FieldSplitter( transformMockHelper.transformMeta, mockProcessRowMeta(), transformMockHelper.iTransformData, 0, transformMockHelper.pipelineMeta, transformMockHelper.pipeline ); transform.init(); transform.setInputRowMeta( getInputRowMeta() ); transform.addRowSetToInputRowSets( mockInputRowSet() ); transform.addRowSetToOutputRowSets( new QueueRowSet() ); boolean hasMoreRows; do { hasMoreRows = transform.processRow(); } while ( hasMoreRows ); IRowSet outputRowSet = transform.getOutputRowSets().get( 0 ); Object[] actualRow = outputRowSet.getRow(); Object[] expectedRow = new Object[] { "before", null, "b=b", "after" }; assertEquals( "Output row is of an unexpected length", expectedRow.length, outputRowSet.getRowMeta().size() ); for ( int i = 0; i < expectedRow.length; i++ ) { assertEquals( "Unexpected output value at index " + i, expectedRow[ i ], actualRow[ i ] ); } }
@Test public void testSplitFieldsDup() throws Exception { FieldSplitterMeta meta = new FieldSplitterMeta(); meta.allocate( 2 ); meta.setDelimiter( " " ); meta.setEnclosure( "" ); meta.setSplitField( "split" ); meta.setFieldName( new String[] { "key", "val" } ); meta.setFieldType( new int[] { IValueMeta.TYPE_STRING, IValueMeta.TYPE_STRING } ); FieldSplitter transform = new FieldSplitter( transformMockHelper.transformMeta, meta, transformMockHelper.iTransformData, 0, transformMockHelper.pipelineMeta, transformMockHelper.pipeline ); transform.init(); IRowMeta rowMeta = new RowMeta(); rowMeta.addValueMeta( new ValueMetaString( "key" ) ); rowMeta.addValueMeta( new ValueMetaString( "val" ) ); rowMeta.addValueMeta( new ValueMetaString( "split" ) ); transform.setInputRowMeta( rowMeta ); transform.addRowSetToInputRowSets( transformMockHelper.getMockInputRowSet( new Object[] { "key", "string", "part1 part2" } ) ); transform.addRowSetToOutputRowSets( new SingleRowRowSet() ); assertTrue( transform.processRow() ); IRowSet rs = transform.getOutputRowSets().get( 0 ); Object[] row = rs.getRow(); IRowMeta rm = rs.getRowMeta(); assertArrayEquals( new Object[] { "key", "string", "part1", "part2" }, Arrays.copyOf( row, 4 ) ); assertArrayEquals( new Object[] { "key", "val", "key_1", "val_1" }, rm.getFieldNames() ); }