@Test
public void testNonuniqueJavaNames() throws Exception {

  // Steal two overloaded methods from another class.
  EndpointMethod method1 = mock(EndpointMethod.class);
  when(method1.getMethod()).thenReturn(DuplicateMethodEndpoint.class.getMethod(
      "foo", String.class));
  doReturn(TestEndpoint.class).when(method1).getEndpointClass();
  when(method1.getReturnType()).thenReturn((TypeToken) TypeToken.of(Void.class));
  EndpointMethod method2 = mock(EndpointMethod.class);
  when(method2.getMethod()).thenReturn(DuplicateMethodEndpoint.class.getMethod(
      "foo", Integer.class));
  doReturn(TestEndpoint.class).when(method2).getEndpointClass();
  when(method2.getReturnType()).thenReturn((TypeToken) TypeToken.of(Void.class));
  config.getApiClassConfig().getMethods().getOrCreate(method1).setPath("fn1");
  config.getApiClassConfig().getMethods().getOrCreate(method2).setPath("fn2");
  try {
    validator.validate(config);
    fail("Expected OverloadedMethodException.");
  } catch (OverloadedMethodException expected) {
  }
}