dajac commented on code in PR #14402: URL: https://github.com/apache/kafka/pull/14402#discussion_r1331094691
########## core/src/test/scala/unit/kafka/server/AddPartitionsToTxnManagerTest.scala: ########## @@ -68,87 +71,143 @@ class AddPartitionsToTxnManagerTest { private val versionMismatchResponse = clientResponse(null, mismatchException = new UnsupportedVersionException("")) private val disconnectedResponse = clientResponse(null, disconnected = true) + private val config = KafkaConfig.fromProps(TestUtils.createBrokerConfig(1, "localhost:2181")) + @BeforeEach def setup(): Unit = { addPartitionsToTxnManager = new AddPartitionsToTxnManager( - KafkaConfig.fromProps(TestUtils.createBrokerConfig(1, "localhost:2181")), + config, networkClient, - time) + metadataCache, + partitionFor, + time + ) } @AfterEach def teardown(): Unit = { addPartitionsToTxnManager.shutdown() } - def setErrors(errors: mutable.Map[TopicPartition, Errors])(callbackErrors: Map[TopicPartition, Errors]): Unit = { - callbackErrors.foreach { - case (tp, error) => errors.put(tp, error) - } + private def setErrors(errors: mutable.Map[TopicPartition, Errors])(callbackErrors: Map[TopicPartition, Errors]): Unit = { + callbackErrors.forKeyValue(errors.put) } @Test def testAddTxnData(): Unit = { + when(partitionFor.apply(transactionalId1)).thenReturn(0) Review Comment: I haven't found a good way to refactor this... The trick is that the mocks are always a bit different. I am open to ideas on this one. -- 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