### Question:
StepAnalyzer extends BaseKettleMetaverseComponent implements
  IClonableStepAnalyzer<T>, IFieldLineageMetadataProvider<T> { protected IComponentDescriptor getStepFieldOriginDescriptor( IComponentDescriptor descriptor, String fieldName ) throws MetaverseAnalyzerException { if ( descriptor == null || stepFields == null ) { return null; } ValueMetaInterface vmi = stepFields.searchValueMeta( fieldName ); String origin = ( vmi == null ) ? fieldName : vmi.getOrigin(); if ( origin == null && !ArrayUtils.isEmpty( prevStepNames ) ) { throw new MetaverseAnalyzerException( Messages.getString( "ERROR.NoOriginForField", fieldName ) ); } IMetaverseNode tmpOriginNode = metaverseObjectFactory.createNodeObject( UUID.randomUUID().toString(), origin, DictionaryConst.NODE_TYPE_TRANS_STEP ); tmpOriginNode.setProperty( DictionaryConst.PROPERTY_NAMESPACE, rootNode .getProperty( DictionaryConst.PROPERTY_NAMESPACE ) ); INamespace stepFieldNamespace = new Namespace( tmpOriginNode.getLogicalId() ); MetaverseComponentDescriptor d = new MetaverseComponentDescriptor( fieldName, DictionaryConst.NODE_TYPE_TRANS_FIELD, tmpOriginNode, descriptor .getContext() ); return d; }  @Override IMetaverseNode analyze( IComponentDescriptor descriptor, T meta ); @Override void postAnalyze( T meta ); Set<String> getInputStepNames( final T meta, final String fieldName ); String getStepName(); StepNodes getInputs(); StepNodes getOutputs(); void setDescriptor( IComponentDescriptor descriptor ); IComponentDescriptor getDescriptor(); Set<StepField> createStepFields( String fieldName, StepNodes stepNodes ); void validateState( IComponentDescriptor descriptor, T object ); IConnectionAnalyzer getConnectionAnalyzer(); void setConnectionAnalyzer( IConnectionAnalyzer connectionAnalyzer ); Map<String, RowMetaInterface> getInputFields( final TransMeta parentTransMeta,
                                                       final StepMeta parentStepMeta ); @Override Map<String, RowMetaInterface> getInputFields( T meta ); @Override RowMetaInterface getOutputFields( T meta ); @Override Set<IFieldMapping> getFieldMappings( T meta ); @Override Set<ComponentDerivationRecord> getChangeRecords( T meta ); void loadInputAndOutputStreamFields( T meta ); @Override final IClonableStepAnalyzer cloneAnalyzer(); IMetaverseNode getNode( final String name, final String type, final INamespace namespace,
                                 final String nodeKey, final Map<String, IMetaverseNode> nodeMap ); @Override void setDocumentAnalyzer( final IClonableDocumentAnalyzer documentAnalyzer ); @Override IClonableDocumentAnalyzer getDocumentAnalyzer(); @Override void setDocumentDescriptor( final IComponentDescriptor documentDescriptor ); @Override IComponentDescriptor getDocumentDescriptor(); @Override void setDocumentPath( final String documentPath ); static final String NONE; }### Answer:
@Test public void testGetStepFieldOriginDescriptorNullDescriptor() throws Exception { assertNull( analyzer.getStepFieldOriginDescriptor( null, "Name" ) ); }
@Test public void testGetStepFieldOriginDescriptor() throws Exception { when( mockStepFields.getFieldNames() ).thenReturn( new String[]{ "field1", "field2" } ); analyzer.stepFields = mockStepFields; IMetaverseNode rootNode = mock( IMetaverseNode.class ); when( rootNode.getProperty( DictionaryConst.PROPERTY_NAMESPACE ) ).thenReturn( "{}" ); analyzer.rootNode = rootNode; analyzer.setMetaverseObjectFactory( new MetaverseObjectFactory() ); assertNotNull( analyzer.getStepFieldOriginDescriptor( mockDescriptor, "field1" ) ); }