mattyb149 commented on a change in pull request #5024:
URL: https://github.com/apache/nifi/pull/5024#discussion_r623136402
##########
File path:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/groovy/org/apache/nifi/processors/standard/TestPutDatabaseRecord.groovy
##########
@@ -301,6 +301,73 @@ class TestPutDatabaseRecord {
conn.close()
}
+ @Test
+ void testInsertNonRequiredColumns() throws InitializationException,
ProcessException, SQLException, IOException {
+ recreateTable(createPersons)
+ final MockRecordParser parser = new MockRecordParser()
+ runner.addControllerService("parser", parser)
+ runner.enableControllerService(parser)
+
+ parser.addSchemaField("id", RecordFieldType.INT)
+ parser.addSchemaField("name", RecordFieldType.STRING)
+ parser.addSchemaField("dt", RecordFieldType.DATE)
+
+ LocalDate testDate1 = LocalDate.of(2021, 1, 26)
+ Date nifiDate1 = new
Date(testDate1.atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli()) // in
UTC
+ Date jdbcDate1 = Date.valueOf(testDate1) // in local TZ
+ LocalDate testDate2 = LocalDate.of(2021, 7, 26)
+ Date nifiDate2 = new
Date(testDate2.atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli()) // in
URC
+ Date jdbcDate2 = Date.valueOf(testDate2) // in local TZ
+
+ parser.addRecord(1, 'rec1', nifiDate1)
+ parser.addRecord(2, 'rec2', nifiDate2)
+ parser.addRecord(3, 'rec3', null)
+ parser.addRecord(4, 'rec4', null)
+ parser.addRecord(5, null, null)
+
+ runner.setProperty(PutDatabaseRecord.RECORD_READER_FACTORY, 'parser')
+ runner.setProperty(PutDatabaseRecord.STATEMENT_TYPE,
PutDatabaseRecord.INSERT_TYPE)
+ runner.setProperty(PutDatabaseRecord.TABLE_NAME, 'PERSONS')
+
+ runner.enqueue(new byte[0])
+ runner.run()
+
+ runner.assertTransferCount(PutDatabaseRecord.REL_SUCCESS, 1)
+ final Connection conn = dbcp.getConnection()
+ final Statement stmt = conn.createStatement()
Review comment:
Groovy doesn't have a try-with-resources per se, I'm going to move this
test to a Java class and add the try-with-resources there
--
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]