use of org.pentaho.metaverse.api.MetaverseObjectFactory in project pentaho-kettle by pentaho.
the class JsonInputAnalyzerTest method setUp.
@Before
public void setUp() throws Exception {
mockFactory = new MetaverseObjectFactory();
when(mockBuilder.getMetaverseObjectFactory()).thenReturn(mockFactory);
when(mockNamespace.getParentNamespace()).thenReturn(mockNamespace);
analyzer = new JsonInputAnalyzer() {
@Override
public Set<String> getInputStepNames(final JsonInputMeta meta, final String fieldName) {
Set<String> inputFieldStepNames = new HashSet<>();
inputFieldStepNames.add("previousStep");
return inputFieldStepNames;
}
};
analyzer.setMetaverseBuilder(mockBuilder);
when(mockJsonInput.getStepMetaInterface()).thenReturn(meta);
when(mockJsonInput.getStepMeta()).thenReturn(mockStepMeta);
when(mockStepMeta.getStepMetaInterface()).thenReturn(meta);
}
use of org.pentaho.metaverse.api.MetaverseObjectFactory in project pentaho-metaverse by pentaho.
the class BaseKettleMetaverseComponentTest method testCreateNodeFromDescriptor.
@Test
public void testCreateNodeFromDescriptor() throws Exception {
String namespaceId = "{namespace: 'my namespace', name: 'my name', type: 'my type'}";
ILogicalIdGenerator idGenerator = DictionaryConst.LOGICAL_ID_GENERATOR_DEFAULT;
IComponentDescriptor descriptor = mock(IComponentDescriptor.class);
INamespace ns = mock(INamespace.class);
when(descriptor.getParentNamespace()).thenReturn(mock(INamespace.class));
when(descriptor.getNamespace()).thenReturn(ns);
when(ns.getNamespaceId()).thenReturn(namespaceId);
component.metaverseObjectFactory = spy(new MetaverseObjectFactory());
IMetaverseNode node = component.createNodeFromDescriptor(descriptor, idGenerator);
assertNotNull(node);
assertTrue(node.getLogicalId().contains(namespaceId));
}
use of org.pentaho.metaverse.api.MetaverseObjectFactory 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.metaverse.api.MetaverseObjectFactory 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.metaverse.api.MetaverseObjectFactory in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testGetStepFieldOriginDescriptor.
@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"));
}
Aggregations