MessageBuilder { @Deprecated public static SofaRequest buildSofaRequest(Class<?> clazz, String method, Class[] argTypes, Object[] args) { SofaRequest request = new SofaRequest(); request.setInterfaceName(clazz.getName()); request.setMethodName(method); request.setMethodArgs(args == null ? CodecUtils.EMPTY_OBJECT_ARRAY : args); request.setMethodArgSigs(ClassTypeUtils.getTypeStrs(argTypes, true)); return request; }  @Deprecated static SofaRequest buildSofaRequest(Class<?> clazz, String method, Class[] argTypes, Object[] args); static SofaRequest buildSofaRequest(Class<?> clazz, Method method, Class[] argTypes, Object[] args); static SofaResponse buildSofaErrorResponse(String errorMsg);  }
@Test public void buildSofaRequest() throws Exception { SofaRequest request = MessageBuilder.buildSofaRequest(Number.class, "intValue", new Class[0], CodecUtils.EMPTY_OBJECT_ARRAY); Assert.assertEquals(request.getInterfaceName(), Number.class.getName()); Assert.assertEquals(request.getMethodName(), "intValue"); Assert.assertArrayEquals(CodecUtils.EMPTY_OBJECT_ARRAY, request.getMethodArgs()); Assert.assertArrayEquals(StringUtils.EMPTY_STRING_ARRAY, request.getMethodArgSigs()); request = MessageBuilder.buildSofaRequest(Comparable.class, "compareTo", new Class[] { Object.class }, new Object[] { null }); Assert.assertEquals(request.getInterfaceName(), Comparable.class.getName()); Assert.assertEquals(request.getMethodName(), "compareTo"); Assert.assertArrayEquals(request.getMethodArgs(), new Object[] { null }); Assert.assertArrayEquals(request.getMethodArgSigs(), new String[] { "java.lang.Object" }); }
@Test public void buildSofaRequest1() throws Exception { Method method = Number.class.getMethod("intValue"); SofaRequest request = MessageBuilder.buildSofaRequest(Number.class, method, new Class[0], StringUtils.EMPTY_STRING_ARRAY); Assert.assertEquals(request.getInterfaceName(), Number.class.getName()); Assert.assertEquals(request.getMethodName(), "intValue"); Assert.assertArrayEquals(StringUtils.EMPTY_STRING_ARRAY, request.getMethodArgs()); Assert.assertArrayEquals(StringUtils.EMPTY_STRING_ARRAY, request.getMethodArgSigs()); method = Comparable.class.getMethod("compareTo", Object.class); request = MessageBuilder.buildSofaRequest(Comparable.class, method, new Class[] { Object.class }, new Object[] { null }); Assert.assertEquals(request.getInterfaceName(), Comparable.class.getName()); Assert.assertEquals(request.getMethodName(), "compareTo"); Assert.assertArrayEquals(request.getMethodArgs(), new Object[] { null }); Assert.assertArrayEquals(request.getMethodArgSigs(), new String[] { "java.lang.Object" }); }