anatasiavela commented on a change in pull request #9526:
URL: https://github.com/apache/kafka/pull/9526#discussion_r514872477



##########
File path: core/src/test/scala/unit/kafka/network/RequestConvertToJsonTest.scala
##########
@@ -0,0 +1,188 @@
+/**
+ * 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 kafka.network
+
+import java.util.HashMap
+
+import org.apache.kafka.common.TopicPartition
+import org.apache.kafka.common.message._
+import org.junit.Test
+import org.apache.kafka.common.protocol.ApiKeys
+import org.apache.kafka.common.record.MemoryRecords
+import org.apache.kafka.common.requests._
+
+import scala.collection.mutable.ArrayBuffer
+
+class RequestConvertToJsonTest {
+
+  def createRequestsFromApiKey(apiKey: ApiKeys, version: Short): 
AbstractRequest = apiKey match {
+    case ApiKeys.PRODUCE => ProduceRequest.Builder.forCurrentMagic(0.toShort, 
10000, new HashMap[TopicPartition, MemoryRecords]()).build()
+    case ApiKeys.FETCH => new FetchRequest(new FetchRequestData(), version)
+    case ApiKeys.LIST_OFFSETS => new ListOffsetRequest(new 
ListOffsetRequestData().toStruct(version), version)
+    case ApiKeys.METADATA => new MetadataRequest(new MetadataRequestData(), 
version)
+    case ApiKeys.OFFSET_COMMIT => new OffsetCommitRequest(new 
OffsetCommitRequestData(), version)
+    case ApiKeys.OFFSET_FETCH => new OffsetFetchRequest(new 
OffsetFetchRequestData().toStruct(version), version)
+    case ApiKeys.FIND_COORDINATOR => new FindCoordinatorRequest(new 
FindCoordinatorRequestData().toStruct(version), version)
+    case ApiKeys.JOIN_GROUP => new JoinGroupRequest(new 
JoinGroupRequestData(), version)
+    case ApiKeys.HEARTBEAT => new HeartbeatRequest(new 
HeartbeatRequestData().toStruct(version), version)
+    case ApiKeys.LEAVE_GROUP => new LeaveGroupRequest(new 
LeaveGroupRequestData().toStruct(version), version)

Review comment:
       Actually, I found a workaround for this mapping and removed it all 
together, so there'd be one less apikey mapping to maintain.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to