protected Type[] getParameterTypes(String method) { if (method != null) { JsonRpcMethod jsonRpcMethod = handler.getJsonRpcMethod(method); if (jsonRpcMethod != null) return jsonRpcMethod.getParameterTypes(); } return EMPTY_TYPE_ARRAY; }
protected Type[] getParameterTypes(String method) { if (method != null) { JsonRpcMethod jsonRpcMethod = handler.getJsonRpcMethod(method); if (jsonRpcMethod != null) return jsonRpcMethod.getParameterTypes(); } return EMPTY_TYPE_ARRAY; }
@Test public void testRpcMethods_01() { Map<String, JsonRpcMethod> methods = ServiceEndpoints.getSupportedMethods(Foo.class); assertEquals("foo/doStuff", methods.get("foo/doStuff").getMethodName()); assertEquals(String.class, methods.get("foo/doStuff").getParameterTypes()[0]); assertFalse(methods.get("foo/doStuff").isNotification()); assertEquals("foo/myNotification", methods.get("foo/myNotification").getMethodName()); assertEquals(String.class, methods.get("foo/myNotification").getParameterTypes()[0]); assertTrue(methods.get("foo/myNotification").isNotification()); assertEquals("hubba", methods.get("hubba").getMethodName()); assertEquals(String.class, methods.get("hubba").getParameterTypes()[0]); assertTrue(methods.get("hubba").isNotification()); }
@Test public void testRpcMethods_02() { Map<String, JsonRpcMethod> methods = ServiceEndpoints.getSupportedMethods(Bar.class); final JsonRpcMethod requestMethod = methods.get("bar/doStuff2"); assertEquals("bar/doStuff2", requestMethod.getMethodName()); assertEquals(2, requestMethod.getParameterTypes().length); assertEquals(String.class, requestMethod.getParameterTypes()[0]); assertEquals(Integer.class, requestMethod.getParameterTypes()[1]); assertFalse(requestMethod.isNotification()); final JsonRpcMethod notificationMethod = methods.get("bar/myNotification2"); assertEquals("bar/myNotification2", notificationMethod.getMethodName()); assertEquals(2, notificationMethod.getParameterTypes().length); assertEquals(String.class, notificationMethod.getParameterTypes()[0]); assertEquals(Integer.class, notificationMethod.getParameterTypes()[1]); assertTrue(notificationMethod.isNotification()); final JsonRpcMethod delegateMethod = methods.get("hubba"); assertEquals("hubba", delegateMethod.getMethodName()); assertEquals(2, delegateMethod.getParameterTypes().length); assertEquals(String.class, delegateMethod.getParameterTypes()[0]); assertEquals(Integer.class, delegateMethod.getParameterTypes()[1]); assertTrue(delegateMethod.isNotification()); }
@Test public void testIssue107() { Map<String, JsonRpcMethod> methods = ServiceEndpoints.getSupportedMethods(StringConsumer.class); final JsonRpcMethod method = methods.get("consumer/accept"); assertEquals("consumer/accept", method.getMethodName()); assertEquals(1, method.getParameterTypes().length); assertEquals(String.class, method.getParameterTypes()[0]); assertTrue(method.isNotification()); }