### Question:
ExcelInputStepAnalyzer extends ExternalResourceStepAnalyzer<ExcelInputMeta> { @Override protected Set<StepField> getUsedFields( ExcelInputMeta meta ) { Set<StepField> usedFields = new HashSet<>(); if ( meta.isAcceptingFilenames() && StringUtils.isNotEmpty( meta.getAcceptingStepName() ) ) { StepField stepField = new StepField( meta.getAcceptingStepName(), meta.getAcceptingField() ); usedFields.add( stepField ); } return usedFields; }  @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); @Override IClonableStepAnalyzer newInstance();  }### Answer:
@Test public void testGetUsedFields_fileNameFromField() throws Exception { when( meta.isAcceptingFilenames() ).thenReturn( true ); when( meta.getAcceptingField() ).thenReturn( "filename" ); when( meta.getAcceptingStepName() ).thenReturn( "previousStep" ); Set<StepField> usedFields = analyzer.getUsedFields( meta ); assertNotNull( usedFields ); assertEquals( 1, usedFields.size() ); StepField used = usedFields.iterator().next(); assertEquals( "previousStep", used.getStepName() ); assertEquals( "filename", used.getFieldName() ); }
@Test public void testGetUsedFields_isNotAcceptingFilenames() throws Exception { when( meta.isAcceptingFilenames() ).thenReturn( false ); when( meta.getAcceptingField() ).thenReturn( "filename" ); when( meta.getAcceptingStepName() ).thenReturn( "previousStep" ); Set<StepField> usedFields = analyzer.getUsedFields( meta ); assertNotNull( usedFields ); assertEquals( 0, usedFields.size() ); }
@Test public void testGetUsedFields_isAcceptingFilenamesButNoStepName() throws Exception { when( meta.isAcceptingFilenames() ).thenReturn( true ); when( meta.getAcceptingField() ).thenReturn( "filename" ); when( meta.getAcceptingStepName() ).thenReturn( null ); Set<StepField> usedFields = analyzer.getUsedFields( meta ); assertNotNull( usedFields ); assertEquals( 0, usedFields.size() ); }