### Question:
MetaInject extends BaseStep implements StepInterface { public static void removeUnavailableStepsFromMapping( Map<TargetStepAttribute, SourceStepField> targetMap, Set<SourceStepField> unavailableSourceSteps, Set<TargetStepAttribute> unavailableTargetSteps ) { Iterator<Entry<TargetStepAttribute, SourceStepField>> targetMapIterator = targetMap.entrySet().iterator(); while ( targetMapIterator.hasNext() ) { Entry<TargetStepAttribute, SourceStepField> entry = targetMapIterator.next(); SourceStepField currentSourceStepField = entry.getValue(); TargetStepAttribute currentTargetStepAttribute = entry.getKey(); if ( unavailableSourceSteps.contains( currentSourceStepField ) || unavailableTargetSteps.contains( currentTargetStepAttribute ) ) { targetMapIterator.remove(); } } } MetaInject(
    StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta, Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); static void removeUnavailableStepsFromMapping( Map<TargetStepAttribute, SourceStepField> targetMap,
                                                        Set<SourceStepField> unavailableSourceSteps, Set<TargetStepAttribute> unavailableTargetSteps ); static Set<TargetStepAttribute> getUnavailableTargetSteps( Map<TargetStepAttribute, SourceStepField> targetMap,
                                                                    TransMeta injectedTransMeta ); static Set<TargetStepAttribute> getUnavailableTargetKeys( Map<TargetStepAttribute, SourceStepField> targetMap,
                                                                   TransMeta injectedTransMeta, Set<TargetStepAttribute> unavailableTargetSteps ); static Set<SourceStepField> getUnavailableSourceSteps( Map<TargetStepAttribute, SourceStepField> targetMap,
                                                                TransMeta sourceTransMeta, StepMeta stepMeta );  }### Answer:
@Test public void removeUnavailableStepsFromMapping_unavailable_source_step() { TargetStepAttribute unavailableTargetStep = new TargetStepAttribute( UNAVAILABLE_STEP, TEST_ATTR_VALUE, false ); SourceStepField unavailableSourceStep = new SourceStepField( UNAVAILABLE_STEP, TEST_FIELD ); Map<TargetStepAttribute, SourceStepField> targetMap = new HashMap<TargetStepAttribute, SourceStepField>(); targetMap.put( unavailableTargetStep, unavailableSourceStep ); Set<SourceStepField> unavailableSourceSteps = Collections.singleton( UNAVAILABLE_SOURCE_STEP ); MetaInject.removeUnavailableStepsFromMapping( targetMap, unavailableSourceSteps, Collections .<TargetStepAttribute>emptySet() ); assertTrue( targetMap.isEmpty() ); }
@Test public void removeUnavailableStepsFromMapping_unavailable_target_step() { TargetStepAttribute unavailableTargetStep = new TargetStepAttribute( UNAVAILABLE_STEP, TEST_ATTR_VALUE, false ); SourceStepField unavailableSourceStep = new SourceStepField( UNAVAILABLE_STEP, TEST_FIELD ); Map<TargetStepAttribute, SourceStepField> targetMap = new HashMap<TargetStepAttribute, SourceStepField>(); targetMap.put( unavailableTargetStep, unavailableSourceStep ); Set<TargetStepAttribute> unavailableTargetSteps = Collections.singleton( UNAVAILABLE_TARGET_STEP ); MetaInject.removeUnavailableStepsFromMapping( targetMap, Collections.<SourceStepField>emptySet(), unavailableTargetSteps ); assertTrue( targetMap.isEmpty() ); }
@Test public void removeUnavailableStepsFromMapping_unavailable_source_target_step() { TargetStepAttribute unavailableTargetStep = new TargetStepAttribute( UNAVAILABLE_STEP, TEST_ATTR_VALUE, false ); SourceStepField unavailableSourceStep = new SourceStepField( UNAVAILABLE_STEP, TEST_FIELD ); Map<TargetStepAttribute, SourceStepField> targetMap = new HashMap<TargetStepAttribute, SourceStepField>(); targetMap.put( unavailableTargetStep, unavailableSourceStep ); Set<TargetStepAttribute> unavailableTargetSteps = Collections.singleton( UNAVAILABLE_TARGET_STEP ); Set<SourceStepField> unavailableSourceSteps = Collections.singleton( UNAVAILABLE_SOURCE_STEP ); MetaInject.removeUnavailableStepsFromMapping( targetMap, unavailableSourceSteps, unavailableTargetSteps ); assertTrue( targetMap.isEmpty() ); }