### Question:
SelectValuesStepAnalyzer extends StepAnalyzer<SelectValuesMeta> { @Override protected Set<StepField> getUsedFields( SelectValuesMeta meta ) { Set<StepField> usedFields = new HashSet<>(); String[] fieldNames = meta.getSelectName(); for ( String fieldName : fieldNames ) { usedFields.addAll( createStepFields( fieldName, getInputs() ) ); } SelectMetadataChange[] selectMetadataChanges = meta.getMeta(); for ( SelectMetadataChange selectMetadataChange : selectMetadataChanges ) { usedFields.addAll( createStepFields( selectMetadataChange.getName(), getInputs() ) ); } return usedFields; }  @Override Set<ComponentDerivationRecord> getChangeRecords( SelectValuesMeta selectValuesMeta ); @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps();  }### Answer:
@Test public void testGetUsedFields_selectOnly() throws Exception { String[] selectedNames = new String[] { "FIRST", "LAST", "age" }; when( selectValuesMeta.getSelectName() ).thenReturn( selectedNames ); when( selectValuesMeta.getMeta() ).thenReturn( new SelectMetadataChange[0] ); Set<StepField> usedFields = analyzer.getUsedFields( selectValuesMeta ); assertNotNull( usedFields ); assertEquals( selectedNames.length, usedFields.size() ); }
@Test public void testGetUsedFields_metaOnly() throws Exception { String[] selectedNames = new String[0]; SelectMetadataChange[] changes = new SelectMetadataChange[] { testChange1, testChange2 }; when( selectValuesMeta.getSelectName() ).thenReturn( selectedNames ); when( selectValuesMeta.getMeta() ).thenReturn( changes ); Set<StepField> usedFields = analyzer.getUsedFields( selectValuesMeta ); assertNotNull( usedFields ); assertEquals( changes.length, usedFields.size() ); }
@Test public void testGetUsedFields_selectAndMetaOverlap() throws Exception { String[] selectedNames = new String[] { "first", "AGE" }; SelectMetadataChange[] changes = new SelectMetadataChange[] { testChange1, testChange2 }; when( selectValuesMeta.getSelectName() ).thenReturn( selectedNames ); when( selectValuesMeta.getMeta() ).thenReturn( changes ); Set<StepField> usedFields = analyzer.getUsedFields( selectValuesMeta ); assertNotNull( usedFields ); assertEquals( 3, usedFields.size() ); }