use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class TableInputStepAnalyzerTest method testGetConnectionNode.
@Test
public void testGetConnectionNode() throws Exception {
DatabaseConnectionAnalyzer dbAnalyzer = mock(DatabaseConnectionAnalyzer.class);
when(meta.getDatabaseMeta()).thenReturn(dbMeta);
when(dbAnalyzer.analyze(descriptor, dbMeta)).thenReturn(connectionNode);
doReturn(dbAnalyzer).when(analyzer).getConnectionAnalyzer();
IMetaverseNode node = analyzer.getConnectionNode();
verify(analyzer).getConnectionAnalyzer();
verify(dbAnalyzer).analyze(descriptor, dbMeta);
assertEquals(node, connectionNode);
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class TableOutputStepAnalyzerTest method testCreateTableNode_nullTable.
@Test
public void testCreateTableNode_nullTable() throws Exception {
IConnectionAnalyzer connectionAnalyzer = mock(IConnectionAnalyzer.class);
doReturn(connectionAnalyzer).when(analyzer).getConnectionAnalyzer();
IMetaverseNode connNode = mock(IMetaverseNode.class);
when(connectionAnalyzer.analyze(any(IComponentDescriptor.class), anyObject())).thenReturn(connNode);
BaseDatabaseResourceInfo resourceInfo = mock(BaseDatabaseResourceInfo.class);
Map<Object, Object> attributes = new HashMap<>();
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);
assertNull(resourceNode.getProperty(DictionaryConst.PROPERTY_TABLE));
assertNull(resourceNode.getProperty(DictionaryConst.PROPERTY_SCHEMA));
assertEquals("CONNECTION_ID", resourceNode.getProperty(DictionaryConst.PROPERTY_NAMESPACE));
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class TableOutputStepAnalyzerTest method testCreateTableNode.
@Test
public void testCreateTableNode() throws Exception {
IConnectionAnalyzer connectionAnalyzer = mock(IConnectionAnalyzer.class);
doReturn(connectionAnalyzer).when(analyzer).getConnectionAnalyzer();
IMetaverseNode connNode = mock(IMetaverseNode.class);
when(connectionAnalyzer.analyze(any(IComponentDescriptor.class), anyObject())).thenReturn(connNode);
BaseDatabaseResourceInfo resourceInfo = mock(BaseDatabaseResourceInfo.class);
Map<Object, Object> attributes = new HashMap<>();
attributes.put(DictionaryConst.PROPERTY_TABLE, "tableName");
attributes.put(DictionaryConst.PROPERTY_SCHEMA, "schemaName");
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("tableName", resourceNode.getProperty(DictionaryConst.PROPERTY_TABLE));
assertEquals("tableName", resourceNode.getName());
assertEquals("schemaName", resourceNode.getProperty(DictionaryConst.PROPERTY_SCHEMA));
assertEquals("CONNECTION_ID", resourceNode.getProperty(DictionaryConst.PROPERTY_NAMESPACE));
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class TableOutputStepAnalyzerTest method testCreateTableNode_nullSchema.
@Test
public void testCreateTableNode_nullSchema() throws Exception {
IConnectionAnalyzer connectionAnalyzer = mock(IConnectionAnalyzer.class);
doReturn(connectionAnalyzer).when(analyzer).getConnectionAnalyzer();
IMetaverseNode connNode = mock(IMetaverseNode.class);
when(connectionAnalyzer.analyze(any(IComponentDescriptor.class), anyObject())).thenReturn(connNode);
BaseDatabaseResourceInfo resourceInfo = mock(BaseDatabaseResourceInfo.class);
Map<Object, Object> attributes = new HashMap<>();
attributes.put(DictionaryConst.PROPERTY_TABLE, "tableName");
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("tableName", resourceNode.getProperty(DictionaryConst.PROPERTY_TABLE));
assertEquals("tableName", resourceNode.getName());
assertNull(resourceNode.getProperty(DictionaryConst.PROPERTY_SCHEMA));
assertEquals("CONNECTION_ID", resourceNode.getProperty(DictionaryConst.PROPERTY_NAMESPACE));
}
use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.
the class TextFileOutputStepAnalyzerTest method testCreateResourceNode.
@Test
public void testCreateResourceNode() throws Exception {
IExternalResourceInfo res = mock(IExternalResourceInfo.class);
when(res.getName()).thenReturn("file:///Users/home/tmp/xyz.ktr");
IMetaverseNode resourceNode = analyzer.createResourceNode(res);
assertNotNull(resourceNode);
assertEquals(DictionaryConst.NODE_TYPE_FILE, resourceNode.getType());
}
Aggregations