use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class MongoDbInputStepAnalyzerTest method testCreateOutputFieldNode_noFields.
@Test
public void testCreateOutputFieldNode_noFields() throws Exception {
ValueMetaInterface vmi = new ValueMeta("field1");
IAnalysisContext context = mock(IAnalysisContext.class);
when(meta.getMongoFields()).thenReturn(null);
doReturn("thisStepName").when(analyzer).getStepName();
when(node.getLogicalId()).thenReturn("logical id");
IMetaverseNode node = analyzer.createOutputFieldNode(context, vmi, ExternalResourceStepAnalyzer.RESOURCE, DictionaryConst.NODE_TYPE_TRANS_FIELD);
assertEquals("field1", node.getName());
assertNull(node.getProperty(MongoDbInputStepAnalyzer.JSON_PATH));
assertNull(node.getProperty(MongoDbInputStepAnalyzer.MINMAX_RANGE));
assertNull(node.getProperty(MongoDbInputStepAnalyzer.OCCUR_RATIO));
assertNull(node.getProperty(MongoDbInputStepAnalyzer.INDEXED_VALS));
assertNull(node.getProperty(MongoDbInputStepAnalyzer.DISPARATE_TYPES));
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class MongoDbInputStepAnalyzerTest method testCustomAnalyze.
@Test
public void testCustomAnalyze() throws Exception {
when(meta.getJsonQuery()).thenReturn("{test:test}");
when(meta.getCollection()).thenReturn("myCollection");
when(meta.getQueryIsPipeline()).thenReturn(true);
IMetaverseNode node = new MetaverseTransientNode("new node");
analyzer.customAnalyze(meta, node);
assertNotNull(node);
assertEquals("{test:test}", node.getProperty(DictionaryConst.PROPERTY_QUERY));
assertEquals("myCollection", node.getProperty(MongoDbInputStepAnalyzer.COLLECTION));
assertTrue((Boolean) node.getProperty(MongoDbInputStepAnalyzer.AGG_PIPELINE));
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class RestClientStepAnalyzerTest method testCreateResourceNode.
@Test
public void testCreateResourceNode() throws Exception {
IExternalResourceInfo res = mock(IExternalResourceInfo.class);
when(res.getName()).thenReturn("http://my.rest.url");
IMetaverseNode resourceNode = analyzer.createResourceNode(res);
assertNotNull(resourceNode);
assertEquals(DictionaryConst.NODE_TYPE_WEBSERVICE, resourceNode.getType());
assertEquals("http://my.rest.url", resourceNode.getName());
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class StringsReplaceStepAnalyzerTest method setUp.
@Before
public void setUp() throws Exception {
when(stringsReplaceMeta.getFieldInStream()).thenReturn(new String[] { "firstName", "middleName", "lastName" });
when(stringsReplaceMeta.getFieldOutStream()).thenReturn(new String[] { "", "MN", "lastName" });
when(stringsReplaceMeta.getFieldReplaceByString()).thenReturn(new String[] { "Tom", "Dick", "Harry" });
when(stringsReplaceMeta.getReplaceString()).thenReturn(new String[] { "Bill", "Steve", "Jeff" });
analyzer = spy(new StringsReplaceStepAnalyzer());
stepFields = new HashSet<>();
stepFields.add(new StepField("prev", "firstName"));
stepFields.add(new StepField("prev", "middleName"));
stepFields.add(new StepField("prev", "lastName"));
StepNodes stepNodes = mock(StepNodes.class);
when(stepNodes.findNodes(anyString())).thenAnswer(new Answer<List<IMetaverseNode>>() {
@Override
public List<IMetaverseNode> answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
List<IMetaverseNode> foundNodes = new ArrayList<>();
String fieldName = (String) args[0];
if (fieldName.equals("firstName") || fieldName.equals("middleName") || fieldName.equals("lastName")) {
foundNodes.add(mock(IMetaverseNode.class));
}
return foundNodes;
}
});
when(analyzer.getInputs()).thenReturn(stepNodes);
doReturn(stepFields).when(analyzer).createStepFields(anyString(), any(StepNodes.class));
// Call customAnalyze() for coverage, it does nothing
analyzer.customAnalyze(stringsReplaceMeta, mock(IMetaverseNode.class));
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class TableInputStepAnalyzerTest method testCreateTableNode.
@Test
public void testCreateTableNode() throws Exception {
BaseDatabaseResourceInfo resourceInfo = mock(BaseDatabaseResourceInfo.class);
Map<Object, Object> attributes = new HashMap<>();
attributes.put(DictionaryConst.PROPERTY_QUERY, "select * from mytable");
when(resourceInfo.getAttributes()).thenReturn(attributes);
IMetaverseNode connectionNode = mock(IMetaverseNode.class);
doReturn(connectionNode).when(analyzer).getConnectionNode();
when(connectionNode.getLogicalId()).thenReturn("CONNECTION_ID");
IMetaverseNode resourceNode = analyzer.createTableNode(resourceInfo);
assertEquals("select * from mytable", resourceNode.getProperty(DictionaryConst.PROPERTY_QUERY));
assertEquals("SQL", resourceNode.getName());
assertEquals("CONNECTION_ID", resourceNode.getProperty(DictionaryConst.PROPERTY_NAMESPACE));
}
Aggregations