Search in sources :

Example 1 with IConnectionAnalyzer

use of org.pentaho.metaverse.api.IConnectionAnalyzer in project pentaho-metaverse by pentaho.

the class MongoDbInputStepAnalyzerTest 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);
    MongoDbResourceInfo resourceInfo = mock(MongoDbResourceInfo.class);
    when(resourceInfo.getCollection()).thenReturn("myCollection");
    IMetaverseNode connectionNode = mock(IMetaverseNode.class);
    doReturn(connectionNode).when(analyzer).getConnectionNode();
    when(connectionNode.getLogicalId()).thenReturn("CONNECTION_ID");
    IMetaverseNode resourceNode = analyzer.createTableNode(resourceInfo);
    assertEquals("myCollection", resourceNode.getProperty(MongoDbInputStepAnalyzer.COLLECTION));
    assertEquals("myCollection", resourceNode.getName());
    assertEquals("CONNECTION_ID", resourceNode.getProperty(DictionaryConst.PROPERTY_NAMESPACE));
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IConnectionAnalyzer(org.pentaho.metaverse.api.IConnectionAnalyzer) MongoDbResourceInfo(org.pentaho.metaverse.impl.model.MongoDbResourceInfo) Test(org.junit.Test)

Example 2 with IConnectionAnalyzer

use of org.pentaho.metaverse.api.IConnectionAnalyzer 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));
}
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)

Example 3 with IConnectionAnalyzer

use of org.pentaho.metaverse.api.IConnectionAnalyzer 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));
}
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)

Example 4 with IConnectionAnalyzer

use of org.pentaho.metaverse.api.IConnectionAnalyzer 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)

Example 5 with IConnectionAnalyzer

use of org.pentaho.metaverse.api.IConnectionAnalyzer in project pentaho-metaverse by pentaho.

the class ConnectionExternalResourceStepAnalyzerTest method testCustomAnalyze_nullERC.

@Test
public void testCustomAnalyze_nullERC() throws Exception {
    // fake the super.analyze call
    IMetaverseNode connectionNode = mock(IMetaverseNode.class);
    IConnectionAnalyzer connectionAnalyzer = mock(IConnectionAnalyzer.class);
    doReturn(connectionAnalyzer).when(analyzer).getConnectionAnalyzer();
    when(connectionAnalyzer.analyze(descriptor, meta)).thenReturn(connectionNode);
    analyzer.setExternalResourceConsumer(null);
    analyzer.customAnalyze(meta, node);
    verify(builder, never()).addNode(resourceNode);
    verify(builder, never()).addLink(node, DictionaryConst.LINK_READBY, resourceNode);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IConnectionAnalyzer(org.pentaho.metaverse.api.IConnectionAnalyzer) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 IConnectionAnalyzer (org.pentaho.metaverse.api.IConnectionAnalyzer)6 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)5 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)4 HashMap (java.util.HashMap)3 Matchers.anyObject (org.mockito.Matchers.anyObject)3 BaseDatabaseResourceInfo (org.pentaho.metaverse.api.model.BaseDatabaseResourceInfo)3 MongoDbResourceInfo (org.pentaho.metaverse.impl.model.MongoDbResourceInfo)1