use of com.google.api.server.spi.testing.Foo in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method genericParameterTypeTestImpl.
private <T> void genericParameterTypeTestImpl() throws Exception {
@Api
class Bar<T1> {
@SuppressWarnings("unused")
public void bar(T1 t1) {
}
}
class Foo extends Bar<T> {
}
ApiConfig config = createConfig(Foo.class);
annotationReader.loadEndpointMethods(serviceContext, Foo.class, config.getApiClassConfig().getMethods());
ApiParameterConfig parameter = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Foo.class.getSuperclass().getDeclaredMethod("bar", Object.class))).getParameterConfigs().get(0);
assertEquals(ApiParameterConfig.Classification.UNKNOWN, parameter.getClassification());
}
use of com.google.api.server.spi.testing.Foo in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testSuperclassWithoutApi.
@Test
public void testSuperclassWithoutApi() throws Exception {
@Api
class Foo {
@SuppressWarnings("unused")
public void foo() {
}
}
class Bar extends Foo {
@ApiMethod(name = "overridden")
@Override
public void foo() {
}
}
ApiConfig config = createConfig(Bar.class);
annotationReader.loadEndpointClass(serviceContext, Bar.class, config);
annotationReader.loadEndpointMethods(serviceContext, Bar.class, config.getApiClassConfig().getMethods());
// Make sure method comes from Bar even though that class is not annotated with @Api.
ApiMethodConfig methodConfig = Iterables.getOnlyElement(config.getApiClassConfig().getMethods().values());
assertEquals("overridden", methodConfig.getName());
assertEquals(Bar.class.getName() + ".foo", methodConfig.getFullJavaName());
}
use of com.google.api.server.spi.testing.Foo in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testKnownParameterizedType.
@Test
public void testKnownParameterizedType() throws Exception {
@Api
class Bar<T1> {
@SuppressWarnings("unused")
public void bar(T1 t1) {
}
}
class Foo extends Bar<Integer> {
}
ApiConfig config = createConfig(Foo.class);
annotationReader.loadEndpointMethods(serviceContext, Foo.class, config.getApiClassConfig().getMethods());
ApiParameterConfig parameter = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Foo.class.getSuperclass().getDeclaredMethod("bar", Object.class))).getParameterConfigs().get(0);
assertEquals(ApiParameterConfig.Classification.API_PARAMETER, parameter.getClassification());
}
Aggregations