MethodHierarchyReader { public Iterable<Method> getLeafMethods() { readMethodHierarchyIfNecessary(); ImmutableList.Builder<Method> builder = ImmutableList.builder(); for (List<EndpointMethod> overrides : asMap(endpointMethods).values()) { builder.add(getLeafMethod(overrides).getMethod()); } return builder.build(); } MethodHierarchyReader(Class<?> endpointClass); Iterable<Method> getLeafMethods(); Iterable<EndpointMethod> getLeafEndpointMethods(); Iterable<List<Method>> getMethodOverrides(); Iterable<List<EndpointMethod>> getEndpointOverrides(); Map<String, Method> getNameToLeafMethodMap(); ListMultimap<String, EndpointMethod> getNameToEndpointOverridesMap();  }
@Test public void testGetLeafMethods() { Iterable<Method> methods = methodReader.getLeafMethods(); TestHelper helper = new TestHelper(Iterables.size(methods)); for (Method method : methods) { helper.verifySingleMethod(method); } helper.verifyAllMethodsSeen(); }
@Test public void testReturnsAreCopies_getLeafMethods() { Iterable<Method> methods = methodReader.getLeafMethods(); Iterable<Method> methods2 = methodReader.getLeafMethods(); assertNotSame(methods, methods2); assertEquals(methods, methods2); }
@Test public void testOverloads() throws Exception { methodReader = new MethodHierarchyReader(SimpleOverloadEndpoint.class); Iterable<Method> methods = methodReader.getLeafMethods(); boolean foundInt = false; boolean foundString = false; for (Method method : methods) { if (method.equals(SimpleOverloadEndpoint.class.getMethod("foo", Integer.class))) { foundInt = true; } else if (method.equals( SimpleOverloadEndpoint.class.getSuperclass().getMethod("foo", String.class))) { foundString = true; } else { fail("Unexpected method: " + method); } } assertTrue(foundInt); assertTrue(foundString); }