### Question:
AbstractStepMetaJsonSerializer extends GenericStepOrJobEntryJsonSerializer<T> { protected void writeExternalResources( T meta, JsonGenerator json, SerializerProvider serializerProvider ) throws IOException, JsonGenerationException { Set<Class<?>> metaClassSet = new HashSet<Class<?>>( 1 ); metaClassSet.add( meta.getClass() ); IStepExternalResourceConsumerProvider stepExternalResourceConsumerProvider = getStepExternalResourceConsumerProvider(); List<IStepExternalResourceConsumer> resourceConsumers = null; if ( stepExternalResourceConsumerProvider != null ) { resourceConsumers = stepExternalResourceConsumerProvider.getExternalResourceConsumers( metaClassSet ); } json.writeArrayFieldStart( JSON_PROPERTY_EXTERNAL_RESOURCES ); if ( resourceConsumers != null ) { for ( IStepExternalResourceConsumer resourceConsumer : resourceConsumers ) { Collection<IExternalResourceInfo> infos = resourceConsumer.getResourcesFromMeta( meta ); for ( IExternalResourceInfo info : infos ) { json.writeObject( info ); } } } json.writeEndArray(); } protected  AbstractStepMetaJsonSerializer( Class<T> aClass ); protected  AbstractStepMetaJsonSerializer( Class<T> aClass, LineageRepository repo ); IStepAnalyzerProvider getStepAnalyzerProvider(); void setStepAnalyzerProvider( IStepAnalyzerProvider stepAnalyzerProvider ); static final String JSON_PROPERTY_TRANSFORMS; static final String JSON_PROPERTY_INPUT_FIELDS; static final String JSON_PROPERTY_OUTPUT_FIELDS; static final String JSON_PROPERTY_MAPPINGS; }### Answer:
@Test public void testWriteExternalResources() throws Exception { StepExternalResourceConsumerProvider mockConsumerMap = mock( StepExternalResourceConsumerProvider.class ); List<IStepExternalResourceConsumer> consumers = new ArrayList<IStepExternalResourceConsumer>(); Set<IExternalResourceInfo> externalResources = new HashSet<IExternalResourceInfo>(); IExternalResourceInfo info = mock( IExternalResourceInfo.class ); externalResources.add( info ); IStepExternalResourceConsumer consumer = mock( IStepExternalResourceConsumer.class ); when( consumer.getResourcesFromMeta( anyObject() ) ).thenReturn( externalResources ); consumers.add( consumer ); Class<? extends BaseStepMeta> stepMetaClass = BaseStepMeta.class; when( mockConsumerMap.getExternalResourceConsumers( any( Collection.class ) ) ).thenReturn( consumers ); serializer.setStepExternalResourceConsumerProvider( mockConsumerMap ); serializer.writeExternalResources( spyMeta, json, provider ); verify( mockConsumerMap ).getExternalResourceConsumers( any( Collection.class ) ); verify( json ).writeArrayFieldStart( AbstractStepMetaJsonSerializer.JSON_PROPERTY_EXTERNAL_RESOURCES ); verify( consumer ).getResourcesFromMeta( anyObject() ); verify( json, times( externalResources.size() ) ).writeObject( any( IExternalResourceInfo.class ) ); verify( json ).writeEndArray(); }