Jave-Chen commented on issue #1909: add ScriptRunnerTest.java unit test URL: https://github.com/apache/incubator-dolphinscheduler/pull/1909#issuecomment-583736846 ``` try { Connection conn = Mockito.mock(Connection.class); Mockito.when(conn.getAutoCommit()).thenReturn(true); PreparedStatement st = Mockito.mock(PreparedStatement.class); Mockito.when(conn.createStatement()).thenReturn(st); ResultSet rs = Mockito.mock(ResultSet.class); Mockito.when(st.getResultSet()).thenReturn(rs); ResultSetMetaData md = Mockito.mock(ResultSetMetaData.class); Mockito.when(rs.getMetaData()).thenReturn(md); Mockito.when(md.getColumnCount()).thenReturn(1); Mockito.when(rs.next()).thenReturn(true, false); ScriptRunner s = new ScriptRunner(conn, true, true); s.runScript(new StringReader("select 1;"), "test_db"); Mockito.verify(md).getColumnLabel(0); } catch(Exception e) { Assert.assertNotNull(e); } ``` how about encapsulate as a method ?
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
