showuon commented on a change in pull request #10794: URL: https://github.com/apache/kafka/pull/10794#discussion_r667293072
########## File path: core/src/test/scala/unit/kafka/network/RequestChannelTest.scala ########## @@ -179,6 +184,108 @@ class RequestChannelTest { assertTrue(isValidJson(RequestConvertToJson.request(alterConfigs.loggableRequest).toString)) } + @Test + def testEnvelopeBuildResponseSendShouldReturnNoErrorIfInnerResponseHasNoError(): Unit = { + val channelRequest = buildRequestWithEnvelope() + + val mockSend: ByteBufferSend = Mockito.mock(classOf[ByteBufferSend]) + val envelopResponseArgumentCaptor = ArgumentCaptor.forClass(classOf[EnvelopeResponse]) + + Mockito.doReturn(mockSend).when(channelRequest.envelope.get.context).buildResponseSend(envelopResponseArgumentCaptor.capture()) + + // create an inner response without error + val ResponseWithoutError = RequestTestUtils.metadataUpdateWith(2, Collections.singletonMap("a", 2)) + + // build an envelope response + channelRequest.buildResponseSend(ResponseWithoutError) + + // expect the envelopeResponse result without error + val capturedValue: EnvelopeResponse = envelopResponseArgumentCaptor.getValue + assertTrue(capturedValue.error().equals(Errors.NONE)) + } + + @Test + def testEnvelopeBuildResponseSendShouldReturnNotControllerErrorIfInnerResponseHasOne(): Unit = { Review comment: Good suggestion! Added `testEnvelopeBuildResponseSendShouldReturnNoErrorIfInnerResponseHasNoNotControllerError` -- 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