### Question:
StepExternalConsumerRowListener extends RowAdapter { public StepExternalConsumerRowListener( IStepExternalResourceConsumer stepExternalResourceConsumer, StepInterface step ) { this.stepExternalResourceConsumer = stepExternalResourceConsumer; this.step = step; } StepExternalConsumerRowListener(
    IStepExternalResourceConsumer stepExternalResourceConsumer, StepInterface step ); @Override @SuppressWarnings( "unchecked" ) void rowReadEvent( RowMetaInterface rowMeta, Object[] row );  }### Answer:
@Test public void testStepExternalConsumerRowListener() throws Exception { BaseStep mockStep = mock( BaseStep.class, withSettings().extraInterfaces( StepInterface.class ) ); when( mockStep.getStepname() ).thenReturn( "my_step" ); StepMeta mockStepMeta = mock( StepMeta.class ); BaseStepMeta bsm = mock( BaseStepMeta.class, withSettings().extraInterfaces( StepMetaInterface.class ) ); StepMetaInterface stepMetaInterface = (StepMetaInterface) bsm; when( mockStep.getStepMeta() ).thenReturn( mockStepMeta ); when( mockStepMeta.getStepMetaInterface() ).thenReturn( stepMetaInterface ); Trans mockTrans = mock( Trans.class ); when( mockStep.getTrans() ).thenReturn( mockTrans ); LineageHolder holder = TransLineageHolderMap.getInstance().getLineageHolder( mockStep.getTrans() ); IExecutionProfile executionProfile = new ExecutionProfile(); holder.setExecutionProfile( executionProfile ); TransLineageHolderMap.getInstance().putLineageHolder( mockTrans, holder ); IStepExternalResourceConsumer consumer = mock( IStepExternalResourceConsumer.class ); RowMetaInterface rmi = mock( RowMetaInterface.class ); Object[] row1 = new String[] { "val1a", "val1b" }; Object[] row2 = new String[] { "val21a", "val2b" }; StepExternalConsumerRowListener listener = new StepExternalConsumerRowListener( consumer, mockStep ); IExternalResourceInfo resource1 = mock( IExternalResourceInfo.class ); IExternalResourceInfo resource2 = mock( IExternalResourceInfo.class ); IExternalResourceInfo resource3 = mock( IExternalResourceInfo.class ); when( consumer.getResourcesFromRow( mockStep, rmi, row1 ) ).thenReturn( Arrays.asList( new IExternalResourceInfo[] { resource1, resource2 } ) ); when( consumer.getResourcesFromRow( mockStep, rmi, row2 ) ).thenReturn( Arrays.asList( new IExternalResourceInfo[] { resource2, resource3 } ) ); listener.rowReadEvent( rmi, row1 ); Map resourceMap = TransLineageHolderMap.getInstance().getLineageHolder( mockTrans ).getExecutionProfile() .getExecutionData().getExternalResources(); Assert.assertNotNull( resourceMap ); Assert.assertEquals( 1, resourceMap.size() ); Assert.assertNotNull( resourceMap.get( "my_step" ) ); Assert.assertTrue( resourceMap.get( "my_step" ) instanceof List ); List resources = (List) resourceMap.get( "my_step" ); Assert.assertNotNull( resources ); Assert.assertEquals( 2, resources.size() ); Assert.assertTrue( resources.contains( resource1 ) ); Assert.assertTrue( resources.contains( resource2 ) ); listener.rowReadEvent( rmi, row2 ); resourceMap = TransLineageHolderMap.getInstance().getLineageHolder( mockTrans ).getExecutionProfile() .getExecutionData().getExternalResources(); Assert.assertNotNull( resourceMap ); Assert.assertEquals( 1, resourceMap.size() ); Assert.assertNotNull( resourceMap.get( "my_step" ) ); Assert.assertTrue( resourceMap.get( "my_step" ) instanceof List ); resources = (List) resourceMap.get( "my_step" ); Assert.assertNotNull( resources ); Assert.assertEquals( 3, resources.size() ); Assert.assertTrue( resources.contains( resource1 ) ); Assert.assertTrue( resources.contains( resource2 ) ); Assert.assertTrue( resources.contains( resource3 ) ); }