clolov commented on code in PR #13240:
URL: https://github.com/apache/kafka/pull/13240#discussion_r1197974839


##########
core/src/test/scala/unit/kafka/server/OffsetCommitRequestTest.scala:
##########
@@ -0,0 +1,147 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package unit.kafka.server
+
+import kafka.server.KafkaApisTest.{NameAndId, newOffsetCommitRequestData, 
newOffsetCommitResponseData}
+import kafka.server.{BaseRequestTest, KafkaConfig}
+import org.apache.kafka.clients.consumer.{ConsumerConfig, KafkaConsumer, 
OffsetAndMetadata}
+import org.apache.kafka.common.protocol.{ApiKeys, Errors}
+import 
org.apache.kafka.common.requests.OffsetCommitRequestTest.assertResponseEquals
+import org.apache.kafka.common.{TopicPartition, Uuid}
+import org.apache.kafka.common.requests.{OffsetCommitRequest, 
OffsetCommitResponse}
+import org.apache.kafka.common.utils.Utils
+import org.junit.jupiter.api.{AfterEach, BeforeEach, Test, TestInfo}
+
+import java.util.Optional.empty
+import java.util.Properties
+import scala.collection.{Map, Seq}
+import scala.collection.immutable.ListMap
+import scala.jdk.CollectionConverters.{ListHasAsScala, MapHasAsJava, 
SeqHasAsJava}
+
+class OffsetCommitRequestTest extends BaseRequestTest {
+  override def brokerCount: Int = 1
+
+  val brokerId: Integer = 0
+  val offset = 15L
+  val groupId = "groupId"
+
+  var consumer: KafkaConsumer[_, _] = _
+
+  override def brokerPropertyOverrides(properties: Properties): Unit = {
+    properties.put(KafkaConfig.BrokerIdProp, brokerId.toString)
+    properties.put(KafkaConfig.OffsetsTopicPartitionsProp, "1")
+    properties.put(KafkaConfig.OffsetsTopicReplicationFactorProp, "1")
+  }
+
+  @BeforeEach
+  override def setUp(testInfo: TestInfo): Unit = {
+    super.setUp(testInfo)
+    consumerConfig.setProperty(ConsumerConfig.GROUP_ID_CONFIG, groupId)
+    consumer = createConsumer()
+  }
+
+  @AfterEach
+  override def tearDown(): Unit = {
+    if (consumer != null)
+      Utils.closeQuietly(consumer, "KafkaConsumer")
+    super.tearDown()
+  }
+
+  def createTopics(topicNames: String*): Seq[NameAndId] = {
+    topicNames.map(topic => {
+      createTopic(topic)
+      val topicId: Uuid = getTopicIds().get(topic) match {
+        case Some(x) => x
+        case _ => throw new AssertionError("Topic ID not found for " + topic)
+      }
+      NameAndId(topic, topicId)
+    })
+  }
+
+
+  @Test
+  def testTopicIdsArePopulatedInOffsetCommitResponses(): Unit = {
+    val topics = createTopics("topic1", "topic2", "topic3")
+    consumer.subscribe(topics.map(_.name).asJava)
+
+    sendOffsetCommitRequest(
+      topics.map((_, ListMap(0 -> offset))),
+      topics.map((_, Map(0 -> Errors.NONE))),
+      ApiKeys.OFFSET_COMMIT.allVersions().asScala

Review Comment:
   To be honest I would prefer if we leave it like this. If we parameterise it, 
this means we have to change `sendOffsetCommitRequest`. If we change 
`sendOffsetCommitRequest` then we need to come up with a different source for 
`testOffsetCommitWithUnknownTopicId`. Alternatively I can parameterise this 
test, but I would end up wrapping a single version in a Seq. Is the reason you 
want it parameterised here so that it breaks it down when running the tests in 
IntelliJ?



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