@Test public void testOneParameter() throws ClassNotFoundException { MethodDescriptor methodDescrtiptor = new MethodDescriptor("myMethod(java.lang.String)"); Assert.assertEquals("myMethod", methodDescrtiptor.getMethodName()); Assert.assertArrayEquals( new String[] {String.class.getName()}, methodDescrtiptor.getParameterTypeNames()); }
@Test public void testMethodNameOnly() throws ClassNotFoundException { MethodDescriptor methodDescrtiptor = new MethodDescriptor("myMethod"); Assert.assertEquals("myMethod", methodDescrtiptor.getMethodName()); Assert.assertNull(methodDescrtiptor.getParameterTypeNames()); }
@Test public void testMultipleParams() throws ClassNotFoundException { MethodDescriptor methodDescrtiptor = new MethodDescriptor("myMethod(boolean, byte)"); String[] parameterTypes = methodDescrtiptor.getParameterTypeNames(); Assert.assertArrayEquals(new String[] {"boolean", "byte"}, parameterTypes); }
@Test public void testEmptyParameters() throws ClassNotFoundException { MethodDescriptor methodDescrtiptor = new MethodDescriptor("myMethod()"); Assert.assertEquals("myMethod", methodDescrtiptor.getMethodName()); Assert.assertEquals(0, methodDescrtiptor.getParameterTypeNames().length); }