Github user patricker commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/3107#discussion_r234310982
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteSQLRecord.java
 ---
    @@ -350,6 +357,37 @@ public void invokeOnTriggerRecords(final Integer 
queryTimeout, final String quer
             assertEquals(durationTime, fetchTime + executionTime);
         }
     
    +    @SuppressWarnings("unchecked")
    +    @Test
    +    public void testWithSqlExceptionErrorProcessingResultSet() throws 
Exception {
    +        DBCPService dbcp = mock(DBCPService.class);
    +        Connection conn = mock(Connection.class);
    +        when(dbcp.getConnection(any(Map.class))).thenReturn(conn);
    +        when(dbcp.getIdentifier()).thenReturn("mockdbcp");
    +        PreparedStatement statement = mock(PreparedStatement.class);
    +        when(conn.prepareStatement(anyString())).thenReturn(statement);
    +        when(statement.execute()).thenReturn(true);
    +        ResultSet rs = mock(ResultSet.class);
    +        when(statement.getResultSet()).thenReturn(rs);
    +        // Throw an exception the first time you access the ResultSet, 
this is after the flow file to hold the results has been created.
    +        when(rs.getMetaData()).thenThrow(new SQLException("test execute 
statement failed"));
    +
    --- End diff --
    
    I ran the tests, but this one failed because the required `RecordWriter` is 
missing. I think you need:
    
    ```
    MockRecordWriter recordWriter = new MockRecordWriter(null, true, -1);
            runner.addControllerService("writer", recordWriter);
            runner.setProperty(ExecuteSQLRecord.RECORD_WRITER_FACTORY, 
"writer");
            runner.enableControllerService(recordWriter);
    ```
    Here is the error text:
    
    > java.lang.AssertionError: Processor has 1 validation failures:
    > 'Record Writer' is invalid because Record Writer is required


---

Reply via email to