Search in sources :

Example 6 with ApiMethodConfig

use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.

the class ApiConfigAnnotationReaderTest method testBasicEndpoint.

@Test
public void testBasicEndpoint() throws Exception {
    ApiConfig config = createConfig(Endpoint0.class);
    annotationReader.loadEndpointClass(serviceContext, Endpoint0.class, config);
    assertEquals("api", config.getName());
    assertEquals(0, config.getApiClassConfig().getMethods().size());
    annotationReader.loadEndpointMethods(serviceContext, Endpoint0.class, config.getApiClassConfig().getMethods());
    assertEquals(1, config.getApiClassConfig().getMethods().size());
    ApiMethodConfig method = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Endpoint0.class.getMethod("getFoo", String.class)));
    validateMethod(method, "Endpoint0.getFoo", "foo/{id}", ApiMethod.HttpMethod.GET, DEFAULT_SCOPES, DEFAULT_AUDIENCES, DEFAULT_CLIENTIDS, null, null);
}
Also used : ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 7 with ApiMethodConfig

use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.

the class ApiConfigAnnotationReaderTest method testSimpleOverloadEndpoint.

@Test
public void testSimpleOverloadEndpoint() throws Exception {
    ApiConfig config = createConfig(SimpleOverloadEndpoint.class);
    annotationReader.loadEndpointMethods(serviceContext, SimpleOverloadEndpoint.class, config.getApiClassConfig().getMethods());
    ApiMethodConfig method1 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(SimpleOverloadEndpoint.class.getMethod("foo", Integer.class)));
    assertEquals("api.foos.fn", method1.getName());
    ApiMethodConfig method2 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(SimpleOverloadEndpoint.class.getSuperclass().getMethod("foo", String.class)));
    assertEquals("api.foos.base", method2.getName());
}
Also used : ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) SimpleOverloadEndpoint(com.google.api.server.spi.testing.SimpleOverloadEndpoint) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 8 with ApiMethodConfig

use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.

the class ApiConfigAnnotationReaderTest method testCollectionCovarianceEndpoint.

@Test
public void testCollectionCovarianceEndpoint() throws Exception {
    ApiConfig config = createConfig(CollectionCovarianceEndpoint.class);
    annotationReader.loadEndpointMethods(serviceContext, CollectionCovarianceEndpoint.class, config.getApiClassConfig().getMethods());
    ApiMethodConfig method1 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(CollectionCovarianceEndpoint.class.getMethod("foo", List.class)));
    assertEquals("api.foos.fn", method1.getName());
    ApiMethodConfig method2 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(CollectionCovarianceEndpoint.class.getSuperclass().getMethod("foo", Collection.class)));
    assertEquals("api.foos.base", method2.getName());
}
Also used : CollectionCovarianceEndpoint(com.google.api.server.spi.testing.CollectionCovarianceEndpoint) ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 9 with ApiMethodConfig

use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.

the class ApiConfigAnnotationReaderTest method testEndpointWithInheritance.

@Test
public void testEndpointWithInheritance() throws Exception {
    ApiConfig config = createConfig(Endpoint3.class);
    annotationReader.loadEndpointClass(serviceContext, Endpoint3.class, config);
    annotationReader.loadEndpointMethods(serviceContext, Endpoint3.class, config.getApiClassConfig().getMethods());
    validateEndpoint1(config, Endpoint3.class);
    String[] defaultScopes = { "ss0", "ss1 ss2" };
    String[] defaultAudiences = { "aa0", "aa1" };
    String[] defaultClientIds = { "cc0", "cc1" };
    ApiMethodConfig getBar = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Endpoint3.class.getMethod("getBar", String.class)));
    validateMethod(getBar, "Endpoint3.getBar", "bar/{id}", ApiMethod.HttpMethod.GET, defaultScopes, defaultAudiences, defaultClientIds, ImmutableList.of(PassAuthenticator.class), ImmutableList.of(PassPeerAuthenticator.class));
    assertEquals(1, getBar.getParameterConfigs().size());
    validateParameter(getBar.getParameterConfigs().get(0), "id", false, null, String.class);
}
Also used : ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) PassPeerAuthenticator(com.google.api.server.spi.testing.PassPeerAuthenticator) PassAuthenticator(com.google.api.server.spi.testing.PassAuthenticator) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 10 with ApiMethodConfig

use of com.google.api.server.spi.config.model.ApiMethodConfig in project endpoints-java by cloudendpoints.

the class ApiConfigAnnotationReaderTest method testDeepGenericHierarchyFailEndpoint.

@Test
public void testDeepGenericHierarchyFailEndpoint() throws Exception {
    ApiConfig config = createConfig(DeepGenericHierarchyFailEndpoint.class);
    annotationReader.loadEndpointMethods(serviceContext, DeepGenericHierarchyFailEndpoint.class, config.getApiClassConfig().getMethods());
    ApiMethodConfig method1 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(DeepGenericHierarchyFailEndpoint.class, DeepGenericHierarchyFailEndpoint.class.getMethod("foo", String.class, Integer.class, Collection.class)));
    assertEquals("DeepGenericHierarchyFailEndpoint.foo", method1.getName());
    ApiMethodConfig method2 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(DeepGenericHierarchyFailEndpoint.class, DeepGenericHierarchyFailEndpoint.class.getSuperclass().getSuperclass().getSuperclass().getMethod("foo", Object.class, Object.class, Object.class)));
    assertEquals("Endpoint3.foo", method2.getName());
}
Also used : ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) DeepGenericHierarchyFailEndpoint(com.google.api.server.spi.testing.DeepGenericHierarchyFailEndpoint) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Aggregations

ApiMethodConfig (com.google.api.server.spi.config.model.ApiMethodConfig)54 Test (org.junit.Test)37 ApiConfig (com.google.api.server.spi.config.model.ApiConfig)26 EndpointMethod (com.google.api.server.spi.EndpointMethod)16 SimpleLevelOverridingInheritedApi (com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi)10 Api (com.google.api.server.spi.config.Api)8 SimpleLevelOverridingApi (com.google.api.server.spi.testing.SimpleLevelOverridingApi)8 User (com.google.api.server.spi.auth.common.User)5 PassAuthenticator (com.google.api.server.spi.testing.PassAuthenticator)5 PassPeerAuthenticator (com.google.api.server.spi.testing.PassPeerAuthenticator)5 ApiParameterConfig (com.google.api.server.spi.config.model.ApiParameterConfig)4 ApiAuthConfig (com.google.api.server.spi.config.model.ApiAuthConfig)3 ApiCacheControlConfig (com.google.api.server.spi.config.model.ApiCacheControlConfig)3 ApiFrontendLimitsConfig (com.google.api.server.spi.config.model.ApiFrontendLimitsConfig)3 Attribute (com.google.api.server.spi.request.Attribute)3 Named (com.google.api.server.spi.config.Named)2 ApiSerializationConfig (com.google.api.server.spi.config.model.ApiSerializationConfig)2 UnauthorizedException (com.google.api.server.spi.response.UnauthorizedException)2 FailAuthenticator (com.google.api.server.spi.testing.FailAuthenticator)2 FailPeerAuthenticator (com.google.api.server.spi.testing.FailPeerAuthenticator)2