test_class.declarator: engine
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private DatabaseProtocolFrontendEngine engine;
test_class.type: DatabaseProtocolFrontendEngine
test_class.var_name: engine
test_class.declarator: codecEngine
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private DatabasePacketCodecEngine codecEngine;
test_class.type: DatabasePacketCodecEngine
test_class.var_name: codecEngine
test_class.declarator: payload
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private PacketPayload payload;
test_class.type: PacketPayload
test_class.var_name: payload
test_class.declarator: backendConnection
test_class.modifier: @Mock(answer = Answers.RETURNS_DEEP_STUBS)
      private
test_class.original_string: @Mock(answer = Answers.RETURNS_DEEP_STUBS)
      private BackendConnection backendConnection;
test_class.type: BackendConnection
test_class.var_name: backendConnection
test_class.declarator: handlerContext
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ChannelHandlerContext handlerContext;
test_class.type: ChannelHandlerContext
test_class.var_name: handlerContext
test_class.declarator: connectionStatus
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ConnectionStatus connectionStatus;
test_class.type: ConnectionStatus
test_class.var_name: connectionStatus
test_class.declarator: executeEngine
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private CommandExecuteEngine executeEngine;
test_class.type: CommandExecuteEngine
test_class.var_name: executeEngine
test_class.declarator: message
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ByteBuf message;
test_class.type: ByteBuf
test_class.var_name: message
test_class.declarator: commandPacketType
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private CommandPacketType commandPacketType;
test_class.type: CommandPacketType
test_class.var_name: commandPacketType
test_class.declarator: commandPacket
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private CommandPacket commandPacket;
test_class.type: CommandPacket
test_class.var_name: commandPacket
test_class.declarator: queryCommandExecutor
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private QueryCommandExecutor queryCommandExecutor;
test_class.type: QueryCommandExecutor
test_class.var_name: queryCommandExecutor
test_class.declarator: commandExecutor
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private CommandExecutor commandExecutor;
test_class.type: CommandExecutor
test_class.var_name: commandExecutor
test_class.declarator: databasePacket
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private DatabasePacket databasePacket;
test_class.type: DatabasePacket
test_class.var_name: databasePacket
test_class.declarator: frontendContext
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private FrontendContext frontendContext;
test_class.type: FrontendContext
test_class.var_name: frontendContext
test_class.file: shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTaskTest.java
test_class.identifier: CommandExecutorTaskTest
test_case.body: @Test
      public void assertRunByCommandExecutor() throws SQLException {
          when(frontendContext.isFlushForPerCommandPacket()).thenReturn(true);
          when(engine.getFrontendContext()).thenReturn(frontendContext);
          when(backendConnection.getConnectionSize()).thenReturn(1);
          when(commandExecutor.execute()).thenReturn(Collections.singletonList(databasePacket));
          when(executeEngine.getCommandPacket(eq(payload), eq(commandPacketType), eq(backendConnection))).thenReturn(commandPacket);
          when(executeEngine.getCommandExecutor(eq(commandPacketType), eq(commandPacket), eq(backendConnection))).thenReturn(commandExecutor);
          when(executeEngine.getCommandPacketType(eq(payload))).thenReturn(commandPacketType);
          when(engine.getCommandExecuteEngine()).thenReturn(executeEngine);
          when(backendConnection.getConnectionStatus()).thenReturn(connectionStatus);
          when(codecEngine.createPacketPayload(eq(message))).thenReturn(payload);
          when(engine.getCodecEngine()).thenReturn(codecEngine);
          when(backendConnection.closeResultSets()).thenReturn(Collections.emptyList());
          when(backendConnection.closeStatements()).thenReturn(Collections.emptyList());
          when(backendConnection.closeConnections(false)).thenReturn(Collections.emptyList());
          CommandExecutorTask actual = new CommandExecutorTask(engine, backendConnection, handlerContext, message);
          actual.run();
          verify(connectionStatus).waitUntilConnectionRelease();
          verify(connectionStatus).switchToUsing();
          verify(handlerContext).write(databasePacket);
          verify(handlerContext).flush();
      }
test_case.class_method_signature: CommandExecutorTaskTest.assertRunByCommandExecutor()
test_case.full_signature: @Test public void assertRunByCommandExecutor()
test_case.identifier: assertRunByCommandExecutor
test_case.invocations: thenReturn when isFlushForPerCommandPacket thenReturn when getFrontendContext thenReturn when getConnectionSize thenReturn when execute singletonList thenReturn when getCommandPacket eq eq eq thenReturn when getCommandExecutor eq eq eq thenReturn when getCommandPacketType eq thenReturn when getCommandExecuteEngine thenReturn when getConnectionStatus thenReturn when createPacketPayload eq thenReturn when getCodecEngine thenReturn when closeResultSets emptyList thenReturn when closeStatements emptyList thenReturn when closeConnections emptyList run waitUntilConnectionRelease verify switchToUsing verify write verify flush verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void assertRunByCommandExecutor()
focal_class.declarator: databaseProtocolFrontendEngine
focal_class.modifier: private final
focal_class.original_string: private final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine;
focal_class.type: DatabaseProtocolFrontendEngine
focal_class.var_name: databaseProtocolFrontendEngine
focal_class.declarator: backendConnection
focal_class.modifier: private final
focal_class.original_string: private final BackendConnection backendConnection;
focal_class.type: BackendConnection
focal_class.var_name: backendConnection
focal_class.declarator: context
focal_class.modifier: private final
focal_class.original_string: private final ChannelHandlerContext context;
focal_class.type: ChannelHandlerContext
focal_class.var_name: context
focal_class.declarator: message
focal_class.modifier: private final
focal_class.original_string: private final Object message;
focal_class.type: Object
focal_class.var_name: message
focal_class.file: shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
focal_class.identifier: CommandExecutorTask
focal_class.interfaces: implements Runnable
focal_class.class_method_signature: CommandExecutorTask.run()
focal_class.full_signature: @Override public void run()
focal_class.identifier: run
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void run()
focal_class.class_method_signature: CommandExecutorTask.executeCommand(final ChannelHandlerContext context, final PacketPayload payload, final BackendConnection backendConnection)
focal_class.full_signature: private boolean executeCommand(final ChannelHandlerContext context, final PacketPayload payload, final BackendConnection backendConnection)
focal_class.identifier: executeCommand
focal_class.modifiers: private
focal_class.parameters: (final ChannelHandlerContext context, final PacketPayload payload, final BackendConnection backendConnection)
focal_class.return: boolean
focal_class.signature: boolean executeCommand(final ChannelHandlerContext context, final PacketPayload payload, final BackendConnection backendConnection)
focal_class.class_method_signature: CommandExecutorTask.processException(final Exception cause)
focal_class.full_signature: private void processException(final Exception cause)
focal_class.identifier: processException
focal_class.modifiers: private
focal_class.parameters: (final Exception cause)
focal_class.return: void
focal_class.signature: void processException(final Exception cause)
focal_class.class_method_signature: CommandExecutorTask.closeExecutionResources()
focal_class.full_signature: private Collection<SQLException> closeExecutionResources()
focal_class.identifier: closeExecutionResources
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: Collection<SQLException>
focal_class.signature: Collection<SQLException> closeExecutionResources()
focal_class.class_method_signature: CommandExecutorTask.processClosedExceptions(final Collection<SQLException> exceptions)
focal_class.full_signature: private void processClosedExceptions(final Collection<SQLException> exceptions)
focal_class.identifier: processClosedExceptions
focal_class.modifiers: private
focal_class.parameters: (final Collection<SQLException> exceptions)
focal_class.return: void
focal_class.signature: void processClosedExceptions(final Collection<SQLException> exceptions)
focal_method.body: @Override
      public void run() {
          RootInvokeHook rootInvokeHook = new SPIRootInvokeHook();
          rootInvokeHook.start();
          boolean isNeedFlush = false;
          int connectionSize = 0;
          try (PacketPayload payload = databaseProtocolFrontendEngine.getCodecEngine().createPacketPayload((ByteBuf) message)) {
              ConnectionStatus connectionStatus = backendConnection.getConnectionStatus();
              if (!backendConnection.getTransactionStatus().isInConnectionHeldTransaction()) {
                  connectionStatus.waitUntilConnectionRelease();
                  connectionStatus.switchToUsing();
              }
              isNeedFlush = executeCommand(context, payload, backendConnection);
              connectionSize = backendConnection.getConnectionSize();
              // CHECKSTYLE:OFF
          } catch (final Exception ex) {
              // CHECKSTYLE:ON
              processException(ex);
          } finally {
              Collection<SQLException> exceptions = closeExecutionResources();
              if (isNeedFlush) {
                  context.flush();
              }
              if (!backendConnection.getTransactionStatus().isInConnectionHeldTransaction()) {
                  exceptions.addAll(backendConnection.closeConnections(false));
              }
              processClosedExceptions(exceptions);
              rootInvokeHook.finish(connectionSize);
          }
      }
focal_method.class_method_signature: CommandExecutorTask.run()
focal_method.full_signature: @Override public void run()
focal_method.identifier: run
focal_method.invocations: start createPacketPayload getCodecEngine getConnectionStatus isInConnectionHeldTransaction getTransactionStatus waitUntilConnectionRelease switchToUsing executeCommand getConnectionSize processException closeExecutionResources flush isInConnectionHeldTransaction getTransactionStatus addAll closeConnections processClosedExceptions finish
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void run()