use of org.pentaho.di.trans.step.BaseStepMeta 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();
}
use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.
the class ConnectionExternalResourceStepAnalyzerTest method setUp.
@Before
public void setUp() throws Exception {
analyzer = spy(new ConnectionExternalResourceStepAnalyzer<BaseStepMeta>() {
@Override
protected IMetaverseNode createTableNode(IExternalResourceInfo resource) throws MetaverseAnalyzerException {
return tableNode;
}
@Override
public String getResourceInputNodeType() {
return "INPUT_TYPE";
}
@Override
public String getResourceOutputNodeType() {
return "OUTPUT_TYPE";
}
@Override
public boolean isOutput() {
return false;
}
@Override
public boolean isInput() {
return true;
}
@Override
protected Set<StepField> getUsedFields(BaseStepMeta meta) {
Set<StepField> stepFields = new HashSet<>();
stepFields.add(new StepField("prevStep", "filename"));
return stepFields;
}
@Override
public Set<Class<? extends BaseStepMeta>> getSupportedSteps() {
return null;
}
});
when(analyzer.getMetaverseBuilder()).thenReturn(builder);
analyzer.descriptor = descriptor;
when(descriptor.getContext()).thenReturn(context);
analyzer.parentTransMeta = parentTransMeta;
analyzer.parentStepMeta = parentStepMeta;
analyzer.setMetaverseObjectFactory(new MetaverseObjectFactory());
}
use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testGetInputFieldsWithException.
@Test
public void testGetInputFieldsWithException() {
analyzer = new StepAnalyzer() {
@Override
public void validateState(IComponentDescriptor descriptor, BaseStepMeta object) throws MetaverseAnalyzerException {
throw new MetaverseAnalyzerException("expected exception");
}
@Override
public Set<Class<? extends BaseStepMeta>> getSupportedSteps() {
return null;
}
@Override
protected Set getUsedFields(BaseStepMeta meta) {
// TODO Auto-generated method stub
return null;
}
@Override
protected void customAnalyze(BaseStepMeta meta, IMetaverseNode rootNode) throws MetaverseAnalyzerException {
// TODO Auto-generated method stub
}
};
assertNull(analyzer.getInputFields(null));
}
use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method setUp.
@Before
public void setUp() throws Exception {
StepAnalyzer stepAnalyzer = new StepAnalyzer() {
@Override
protected Set<StepField> getUsedFields(BaseStepMeta meta) {
return null;
}
@Override
protected void customAnalyze(BaseStepMeta meta, IMetaverseNode rootNode) throws MetaverseAnalyzerException {
}
@Override
public Set<Class<? extends BaseStepMeta>> getSupportedSteps() {
return null;
}
};
analyzer = spy(stepAnalyzer);
analyzer.rootNode = rootNode;
analyzer.baseStepMeta = baseStepMeta;
analyzer.descriptor = descriptor;
analyzer.parentTransMeta = parentTransMeta;
analyzer.parentStepMeta = parentStepMeta;
usedFields = new HashSet<>();
inputs = new StepNodes();
inputs.addNode("prevStep", "name", fieldNode);
inputs.addNode("prevStep", "address", fieldNode);
inputs.addNode("prevStep", "email", fieldNode);
inputs.addNode("prevStep", "birthday", fieldNode);
inputs.addNode("prevStep2", "employeeNumber", fieldNode);
inputs.addNode("prevStep2", "occupation", fieldNode);
outputs = new StepNodes();
outputs.addNode("nextStep", "full name", fieldNode);
outputs.addNode("nextStep", "address", fieldNode);
outputs.addNode("nextStep", "email", fieldNode);
outputs.addNode("nextStep", "date of birth", fieldNode);
outputs.addNode("nextStep", "ID", fieldNode);
outputs.addNode("nextStep", "occupation", fieldNode);
doReturn(builder).when(analyzer).getMetaverseBuilder();
MetaverseObjectFactory factory = new MetaverseObjectFactory();
doReturn(factory).when(analyzer).getMetaverseObjectFactory();
when(descriptor.getContext()).thenReturn(context);
when(parentStepMeta.getName()).thenReturn("STEP NAME");
}
use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.
the class AnalyzerInfoService method getSupportedSteps.
/**
* Gets a list of all implementations of {@link BaseStepMeta} with a custom {@link IStepAnalyzer}
* that produces lineage. Any step not found in this list will fall back to using
* {@link org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer}.
*
* <p><b>Example Request:</b><br />
* GET pentaho-di/osgi/cxf/lineage/info/steps
* </p>
*
* @return List of {@link AnalyzerInfo}
*
* <p><b>Example Response:</b></p>
* <pre function="syntax.js">
* [ { meta: "CalculatorMeta" }, { meta: "CsvInputMeta" }, { meta: "ExcelInputMeta" } ]
* </pre>
*/
@GET
@Path("/steps")
@Produces({ MediaType.APPLICATION_JSON })
@StatusCodes({ @ResponseCode(code = OK, condition = "Successfully listed the supported steps"), @ResponseCode(code = SERVER_ERROR, condition = "Server Error.") })
public Response getSupportedSteps() {
List<AnalyzerInfo> analyzers = new ArrayList<>();
for (IStepAnalyzer analyzer : getStepAnalyzerProvider().getAnalyzers()) {
Set<Class<? extends BaseStepMeta>> supportedSteps = analyzer.getSupportedSteps();
for (Class<? extends BaseStepMeta> supportedStep : supportedSteps) {
AnalyzerInfo info = new AnalyzerInfo(supportedStep.getSimpleName());
analyzers.add(info);
}
}
Collections.sort(analyzers, new AnalyzerInfoComparator());
return Response.ok(analyzers).build();
}
Aggregations