satishd commented on code in PR #13043:
URL: https://github.com/apache/kafka/pull/13043#discussion_r1063978512


##########
core/src/test/scala/unit/kafka/log/ProducerStateManagerTest.scala:
##########
@@ -255,15 +259,28 @@ class ProducerStateManagerTest {
     appendData(30L, 31L, secondAppend)
 
     assertEquals(2, secondAppend.startedTransactions.size)
-    assertEquals(TxnMetadata(producerId, new LogOffsetMetadata(24L)), 
secondAppend.startedTransactions.head)
-    assertEquals(TxnMetadata(producerId, new LogOffsetMetadata(30L)), 
secondAppend.startedTransactions.last)
+    assertTxnMetadataEquals(new TxnMetadata(producerId, new 
LogOffsetMetadata(24L)), secondAppend.startedTransactions.asScala.head)
+    assertTxnMetadataEquals(new TxnMetadata(producerId, new 
LogOffsetMetadata(30L)), secondAppend.startedTransactions.asScala.last)
     stateManager.update(secondAppend)
     stateManager.completeTxn(firstCompletedTxn.get)
     stateManager.completeTxn(secondCompletedTxn.get)
     stateManager.onHighWatermarkUpdated(32L)
     assertEquals(Some(new LogOffsetMetadata(30L)), 
stateManager.firstUnstableOffset)
   }
 
+  def assertTxnMetadataEquals(expected: java.util.List[TxnMetadata], actual: 
java.util.List[TxnMetadata]): Unit = {
+    val expectedIter = expected.iterator()
+    val actualIter = actual.iterator()
+    while(expectedIter.hasNext && actualIter.hasNext) {
+      assertTxnMetadataEquals(expectedIter.next(), actualIter.next())
+    }
+  }
+
+  def assertTxnMetadataEquals(expected: TxnMetadata, actual:TxnMetadata) : 
Unit = {
+    assertEquals(expected.producerId, actual.producerId)
+    assertEquals(expected.firstOffset, actual.firstOffset)

Review Comment:
   I see that `lastOffset` is empty for all the cases. I was not sure whether 
that is the intended check. Added this check with the updated PR. 



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

Reply via email to