@Test public void testSetBaseStepMeta() throws Exception { analyzer.setBaseStepMeta(meta); DatabaseConnectionAnalyzer dbAnalyzer = mock(DatabaseConnectionAnalyzer.class); doReturn(dbAnalyzer).when(analyzer).getConnectionAnalyzer(); analyzer.getConnectionNode(); verify(meta, times(1)).getDatabaseMeta(); }
@Before public void setUp() throws Exception { analyzer = spy(new TableInputStepAnalyzer()); when(mockNamespace.getParentNamespace()).thenReturn(mockNamespace); descriptor = new MetaverseComponentDescriptor( "test", DictionaryConst.NODE_TYPE_TRANS_STEP, mockNamespace); analyzer.setDescriptor(descriptor); analyzer.setBaseStepMeta(meta); IMetaverseObjectFactory factory = MetaverseTestUtils.getMetaverseObjectFactory(); when(builder.getMetaverseObjectFactory()).thenReturn(factory); analyzer.setMetaverseBuilder(builder); }
@Test public void testGetSupportedSteps() throws Exception { Set<Class<? extends BaseStepMeta>> types = analyzer.getSupportedSteps(); assertNotNull(types); assertEquals(types.size(), 1); assertTrue(types.contains(TableInputMeta.class)); }
@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); }
@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)); }
@Test public void testGetUsedFields() throws Exception { assertNull(analyzer.getUsedFields(meta)); }
@Test public void testIsInput() throws Exception { assertTrue(analyzer.isInput()); }
@Test public void testIsOutput() throws Exception { assertFalse(analyzer.isOutput()); }
@Test public void testGetResourceOutputNodeType() throws Exception { assertNull(analyzer.getResourceOutputNodeType()); }
@Test public void testGetResourceInputNodeType() throws Exception { assertEquals(DictionaryConst.NODE_TYPE_DATA_COLUMN, analyzer.getResourceInputNodeType()); }