Search in sources :

Example 1 with StepExternalResourceConsumerProvider

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);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) IStepExternalResourceConsumer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumer) StepInterface(org.pentaho.di.trans.step.StepInterface) StepExternalResourceConsumerProvider(org.pentaho.metaverse.analyzer.kettle.step.StepExternalResourceConsumerProvider) StepMetaDataCombi(org.pentaho.di.trans.step.StepMetaDataCombi) Trans(org.pentaho.di.trans.Trans) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with StepExternalResourceConsumerProvider

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();
}
Also used : StepExternalResourceConsumerProvider(org.pentaho.metaverse.analyzer.kettle.step.StepExternalResourceConsumerProvider) IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) ArrayList(java.util.ArrayList) Collection(java.util.Collection) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) IStepExternalResourceConsumer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumer) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

HashSet (java.util.HashSet)2 Test (org.junit.Test)2 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)2 StepExternalResourceConsumerProvider (org.pentaho.metaverse.analyzer.kettle.step.StepExternalResourceConsumerProvider)2 IStepExternalResourceConsumer (org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumer)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Set (java.util.Set)1 Trans (org.pentaho.di.trans.Trans)1 StepInterface (org.pentaho.di.trans.step.StepInterface)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 StepMetaDataCombi (org.pentaho.di.trans.step.StepMetaDataCombi)1 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)1 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)1