### Question:
DeFiAdminBrokerProcessor implements NettyRequestProcessor { @Override public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { switch (request.getCode()) { case RequestCode.UPDATE_AND_CREATE_TOPIC: return this.updateAndCreateTopic(ctx, request); case RequestCode.GET_BROKER_RUNTIME_INFO: return this.getBrokerRuntimeInfo(ctx, request); case DeFiBusRequestCode.GET_CONSUME_STATS_V2: return this.getConsumeStatsV2(ctx, request); default: break; } return null; } DeFiAdminBrokerProcessor(final DeFiBrokerController deFiBrokerController); @Override RemotingCommand processRequest(ChannelHandlerContext ctx,
        RemotingCommand request); @Override boolean rejectRequest();  }### Answer:
@Test public void testProcessRequestUpdateAndCreateTopic() throws RemotingCommandException { RemotingCommand request = createCommand(RequestCode.UPDATE_AND_CREATE_TOPIC); final RemotingCommand[] response = new RemotingCommand[1]; doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { response[0] = (RemotingCommand) invocation.getArguments()[0]; return null; } }).when(handlerContext).writeAndFlush(any(Object.class)); RemotingCommand responseToReturn = deFiAdminBrokerProcessor.processRequest(handlerContext, request); if (responseToReturn != null) { Assert.assertNull(response[0]); response[0] = responseToReturn; } Assert.assertEquals(response[0].getCode(), ResponseCode.SUCCESS); Assert.assertEquals(response[0].getOpaque(), request.getOpaque()); }
@Test public void testProcessRequestUpdateAndCreateTopic_fail() throws RemotingCommandException { RemotingCommand request = createCommand(RequestCode.UPDATE_AND_CREATE_TOPIC); RemotingCommand response = deFiAdminBrokerProcessor.processRequest(handlerContext, request); }
@Test public void testProcessRequest_GET_CONSUME_STATS_V2() throws RemotingCommandException { RemotingCommand request = createCommand(DeFiBusRequestCode.GET_CONSUME_STATS_V2); deFiBrokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(topic, 1, 6, 0); RemotingCommand response = deFiAdminBrokerProcessor.processRequest(handlerContext, request); assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS); DeFiBusConsumeStats consumerStats = RemotingSerializable.decode(response.getBody(), DeFiBusConsumeStats.class); assertThat(consumerStats).isNotNull(); }