Search in sources :

Example 6 with BaseDatabaseResourceInfo

use of org.pentaho.metaverse.api.model.BaseDatabaseResourceInfo 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));
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) BaseDatabaseResourceInfo(org.pentaho.metaverse.api.model.BaseDatabaseResourceInfo) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) HashMap(java.util.HashMap) Matchers.anyObject(org.mockito.Matchers.anyObject) IConnectionAnalyzer(org.pentaho.metaverse.api.IConnectionAnalyzer) Test(org.junit.Test)

Aggregations

IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)6 BaseDatabaseResourceInfo (org.pentaho.metaverse.api.model.BaseDatabaseResourceInfo)6 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 Matchers.anyObject (org.mockito.Matchers.anyObject)3 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)3 IConnectionAnalyzer (org.pentaho.metaverse.api.IConnectionAnalyzer)3 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)2