use of org.pentaho.metaverse.analyzer.kettle.step.StepExternalResourceConsumerProvider in project pentaho-metaverse by pentaho.
the class StepExternalResourceConsumerListenerTest method testCallStepExtensionPoint.
@Test
public void testCallStepExtensionPoint() throws Exception {
StepExternalResourceConsumerListener stepExtensionPoint = new StepExternalResourceConsumerListener();
stepExtensionPoint.setStepExternalResourceConsumerProvider(MetaverseTestUtils.getStepExternalResourceConsumerProvider());
StepMetaDataCombi stepCombi = mock(StepMetaDataCombi.class);
BaseStepMeta bsm = mock(BaseStepMeta.class, withSettings().extraInterfaces(StepMetaInterface.class));
stepCombi.meta = (StepMetaInterface) bsm;
stepCombi.step = mock(StepInterface.class);
stepCombi.stepMeta = mock(StepMeta.class);
stepExtensionPoint.callExtensionPoint(null, stepCombi);
Map<Class<? extends BaseStepMeta>, Set<IStepExternalResourceConsumer>> stepConsumerMap = new StepExternalResourceConsumerProvider().getStepConsumerMap();
Set<IStepExternalResourceConsumer> consumers = new HashSet<IStepExternalResourceConsumer>();
stepConsumerMap.put(bsm.getClass(), consumers);
stepExtensionPoint.callExtensionPoint(null, stepCombi);
IStepExternalResourceConsumer consumer = mock(IStepExternalResourceConsumer.class);
when(consumer.getResourcesFromMeta(Mockito.any())).thenReturn(Collections.emptyList());
consumers.add(consumer);
Trans mockTrans = mock(Trans.class);
when(stepCombi.step.getTrans()).thenReturn(mockTrans);
stepExtensionPoint.callExtensionPoint(null, stepCombi);
when(consumer.isDataDriven(Mockito.any())).thenReturn(Boolean.TRUE);
stepExtensionPoint.callExtensionPoint(null, stepCombi);
}
use of org.pentaho.metaverse.analyzer.kettle.step.StepExternalResourceConsumerProvider in project pentaho-metaverse by pentaho.
the class AbstractStepMetaJsonSerializerTest method testWriteExternalResources.
@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();
}
Aggregations