hgeraldino commented on code in PR #13191: URL: https://github.com/apache/kafka/pull/13191#discussion_r1112459731
########## connect/runtime/src/test/java/org/apache/kafka/connect/runtime/AbstractWorkerSourceTaskTest.java: ########## @@ -235,115 +236,100 @@ public void testMetricsGroup() { public void testSendRecordsConvertsData() { createWorkerTask(); - List<SourceRecord> records = new ArrayList<>(); // Can just use the same record for key and value - records.add(new SourceRecord(PARTITION, OFFSET, "topic", null, KEY_SCHEMA, KEY, RECORD_SCHEMA, RECORD)); - - Capture<ProducerRecord<byte[], byte[]>> sent = expectSendRecordAnyTimes(); + List<SourceRecord> records = Collections.singletonList( + new SourceRecord(PARTITION, OFFSET, "topic", null, KEY_SCHEMA, KEY, RECORD_SCHEMA, RECORD) + ); + expectSendRecord(emptyHeaders()); expectTopicCreation(TOPIC); - PowerMock.replayAll(); - workerTask.toSend = records; workerTask.sendRecords(); + + ArgumentCaptor<ProducerRecord<byte[], byte[]>> sent = verifySendRecord(); + assertEquals(SERIALIZED_KEY, sent.getValue().key()); assertEquals(SERIALIZED_RECORD, sent.getValue().value()); - PowerMock.verifyAll(); + verifyTaskGetTopic(); } @Test public void testSendRecordsPropagatesTimestamp() { final Long timestamp = System.currentTimeMillis(); - createWorkerTask(); - List<SourceRecord> records = Collections.singletonList( - new SourceRecord(PARTITION, OFFSET, "topic", null, KEY_SCHEMA, KEY, RECORD_SCHEMA, RECORD, timestamp) - ); - - Capture<ProducerRecord<byte[], byte[]>> sent = expectSendRecordAnyTimes(); - + expectSendRecord(emptyHeaders()); expectTopicCreation(TOPIC); - PowerMock.replayAll(); - - workerTask.toSend = records; + workerTask.toSend = Collections.singletonList( + new SourceRecord(PARTITION, OFFSET, "topic", null, KEY_SCHEMA, KEY, RECORD_SCHEMA, RECORD, timestamp) + ); workerTask.sendRecords(); + + ArgumentCaptor<ProducerRecord<byte[], byte[]>> sent = verifySendRecord(); assertEquals(timestamp, sent.getValue().timestamp()); - PowerMock.verifyAll(); + verifyTaskGetTopic(); } @Test public void testSendRecordsCorruptTimestamp() { final Long timestamp = -3L; createWorkerTask(); - List<SourceRecord> records = Collections.singletonList( + expectSendRecord(emptyHeaders()); + expectTopicCreation(TOPIC); Review Comment: Good catch. Removed -- 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. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org