Search in sources :

Example 1 with Foo

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());
}
Also used : ApiParameterConfig(com.google.api.server.spi.config.model.ApiParameterConfig) Foo(com.google.api.server.spi.testing.Foo) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) SimpleLevelOverridingApi(com.google.api.server.spi.testing.SimpleLevelOverridingApi) SimpleLevelOverridingInheritedApi(com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi) Api(com.google.api.server.spi.config.Api)

Example 2 with Foo

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());
}
Also used : ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) Foo(com.google.api.server.spi.testing.Foo) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) SimpleLevelOverridingApi(com.google.api.server.spi.testing.SimpleLevelOverridingApi) SimpleLevelOverridingInheritedApi(com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi) Api(com.google.api.server.spi.config.Api) Test(org.junit.Test)

Example 3 with Foo

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());
}
Also used : ApiParameterConfig(com.google.api.server.spi.config.model.ApiParameterConfig) Foo(com.google.api.server.spi.testing.Foo) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) SimpleLevelOverridingApi(com.google.api.server.spi.testing.SimpleLevelOverridingApi) SimpleLevelOverridingInheritedApi(com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi) Api(com.google.api.server.spi.config.Api) Test(org.junit.Test)

Aggregations

Api (com.google.api.server.spi.config.Api)3 ApiConfig (com.google.api.server.spi.config.model.ApiConfig)3 Foo (com.google.api.server.spi.testing.Foo)3 SimpleLevelOverridingApi (com.google.api.server.spi.testing.SimpleLevelOverridingApi)3 SimpleLevelOverridingInheritedApi (com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi)3 ApiParameterConfig (com.google.api.server.spi.config.model.ApiParameterConfig)2 Test (org.junit.Test)2 ApiMethodConfig (com.google.api.server.spi.config.model.ApiMethodConfig)1