markap14 commented on a change in pull request #3439: NIFI-6218 Support setting 
transactional.id in PublishKafka/PublishKaf…
URL: https://github.com/apache/nifi/pull/3439#discussion_r277296231
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-0-11-processors/src/test/java/org/apache/nifi/processors/kafka/pubsub/TestPublisherPool.java
 ##########
 @@ -65,5 +70,40 @@ public void testPoisonedLeaseNotReturnedToPool() {
         lease.close();
         assertEquals(0, pool.available());
     }
+    @Test
+    public void testUseTransactionWithUUID() {
+        final Map<String, Object> kafkaProperties = new HashMap<>();
+        kafkaProperties.put("bootstrap.servers", "localhost:1111");
+        kafkaProperties.put("key.serializer", 
ByteArraySerializer.class.getName());
+        kafkaProperties.put("value.serializer", 
ByteArraySerializer.class.getName());
 
+        final PublisherPool pool = new PublisherPool(kafkaProperties, 
Mockito.mock(ComponentLog.class), 1024 * 1024, 1000L, true, null, null, 
StandardCharsets.UTF_8);
+        PublisherLease publisherLease = pool.obtainPublisher();
+
+        Producer producer = (Producer) 
Whitebox.getInternalState(publisherLease, "producer");
+        TransactionManager transactionManager = (TransactionManager) 
Whitebox.getInternalState(producer, "transactionManager");
+        String transactionalId = (String) 
Whitebox.getInternalState(transactionManager, "transactionalId");
+        try {
+            UUID uuid = UUID.fromString(transactionalId);
 
 Review comment:
   As there's no real magic to a UUID here, just important that a value be set, 
would recommend we just assert that the value is non-null, instead of asserting 
that it is a valid UUID.

----------------------------------------------------------------
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

Reply via email to