test_class.declarator: select = new SelectTelnetHandler()
test_class.modifier: private static
test_class.original_string: private static TelnetHandler select = new SelectTelnetHandler();
test_class.type: TelnetHandler
test_class.var_name: select
test_class.declarator: mockChannel
test_class.modifier: private
test_class.original_string: private Channel mockChannel;
test_class.type: Channel
test_class.var_name: mockChannel
test_class.declarator: methods
test_class.original_string: List<Method> methods;
test_class.type: List<Method>
test_class.var_name: methods
test_class.declarator: repository = ApplicationModel.getServiceRepository()
test_class.modifier: private final
test_class.original_string: private final ServiceRepository repository = ApplicationModel.getServiceRepository();
test_class.type: ServiceRepository
test_class.var_name: repository
test_class.file: dubbo-plugin/dubbo-qos/src/test/java/org/apache/dubbo/qos/legacy/SelectTelnetHandlerTest.java
test_class.identifier: SelectTelnetHandlerTest
test_case.body: @Test
      public void testInvokeWithIllegalMessage() throws RemotingException {
          mockChannel = mock(Channel.class);
          given(mockChannel.getAttribute("telnet.service")).willReturn(DemoService.class.getName());
          given(mockChannel.getAttribute(InvokeTelnetHandler.INVOKE_METHOD_LIST_KEY)).willReturn(methods);
          given(mockChannel.getLocalAddress()).willReturn(NetUtils.toAddress("127.0.0.1:5555"));
          given(mockChannel.getRemoteAddress()).willReturn(NetUtils.toAddress("127.0.0.1:20886"));
  
          registerProvider(DemoService.class.getName(), new DemoServiceImpl(), DemoService.class);
  
          String result = select.telnet(mockChannel, "index");
          assertTrue(result.contains("Illegal index ,please input select 1"));
  
          result = select.telnet(mockChannel, "0");
          assertTrue(result.contains("Illegal index ,please input select 1"));
  
          result = select.telnet(mockChannel, "1000");
          assertTrue(result.contains("Illegal index ,please input select 1"));
      }
test_case.class_method_signature: SelectTelnetHandlerTest.testInvokeWithIllegalMessage()
test_case.full_signature: @Test public void testInvokeWithIllegalMessage()
test_case.identifier: testInvokeWithIllegalMessage
test_case.invocations: mock willReturn given getAttribute getName willReturn given getAttribute willReturn given getLocalAddress toAddress willReturn given getRemoteAddress toAddress registerProvider getName telnet assertTrue contains telnet assertTrue contains telnet assertTrue contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testInvokeWithIllegalMessage()
focal_class.declarator: SELECT_METHOD_KEY = "telnet.select.method"
focal_class.modifier: public static final
focal_class.original_string: public static final String SELECT_METHOD_KEY = "telnet.select.method";
focal_class.type: String
focal_class.var_name: SELECT_METHOD_KEY
focal_class.declarator: SELECT_KEY = "telnet.select"
focal_class.modifier: public static final
focal_class.original_string: public static final String SELECT_KEY = "telnet.select";
focal_class.type: String
focal_class.var_name: SELECT_KEY
focal_class.declarator: invokeTelnetHandler = new InvokeTelnetHandler()
focal_class.modifier: private
focal_class.original_string: private InvokeTelnetHandler invokeTelnetHandler = new InvokeTelnetHandler();
focal_class.type: InvokeTelnetHandler
focal_class.var_name: invokeTelnetHandler
focal_class.file: dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/legacy/SelectTelnetHandler.java
focal_class.identifier: SelectTelnetHandler
focal_class.interfaces: implements TelnetHandler
focal_class.class_method_signature: SelectTelnetHandler.telnet(Channel channel, String message)
focal_class.full_signature: @Override @SuppressWarnings("unchecked") public String telnet(Channel channel, String message)
focal_class.identifier: telnet
focal_class.modifiers: @Override @SuppressWarnings("unchecked") public
focal_class.parameters: (Channel channel, String message)
focal_class.return: String
focal_class.signature: String telnet(Channel channel, String message)
focal_method.body: @Override
      @SuppressWarnings("unchecked")
      public String telnet(Channel channel, String message) {
          if (message == null || message.length() == 0) {
              return "Please input the index of the method you want to invoke, eg: \r\n select 1";
          }
          List<Method> methodList = (List<Method>) channel.getAttribute(InvokeTelnetHandler.INVOKE_METHOD_LIST_KEY);
          if (CollectionUtils.isEmpty(methodList)) {
              return "Please use the invoke command first.";
          }
          if (!StringUtils.isInteger(message) || Integer.parseInt(message) < 1 || Integer.parseInt(message) > methodList.size()) {
              return "Illegal index ,please input select 1~" + methodList.size();
          }
          Method method = methodList.get(Integer.parseInt(message) - 1);
          channel.setAttribute(SELECT_METHOD_KEY, method);
          channel.setAttribute(SELECT_KEY, Boolean.TRUE);
          String invokeMessage = (String) channel.getAttribute(InvokeTelnetHandler.INVOKE_MESSAGE_KEY);
          return invokeTelnetHandler.telnet(channel, invokeMessage);
      }
focal_method.class_method_signature: SelectTelnetHandler.telnet(Channel channel, String message)
focal_method.full_signature: @Override @SuppressWarnings("unchecked") public String telnet(Channel channel, String message)
focal_method.identifier: telnet
focal_method.invocations: length getAttribute isEmpty isInteger parseInt parseInt size size get parseInt setAttribute setAttribute getAttribute telnet
focal_method.modifiers: @Override @SuppressWarnings("unchecked") public
focal_method.parameters: (Channel channel, String message)
focal_method.return: String
focal_method.signature: String telnet(Channel channel, String message)