Search in sources :

Example 16 with ApiParameterConfig

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

the class ApiConfigAnnotationReaderTest method testGenericParameterTypes.

@Test
public void testGenericParameterTypes() throws Exception {
    @Api
    final class Test<T> {

        @SuppressWarnings("unused")
        public void setT(T t) {
        }
    }
    ApiConfig config = createConfig(Test.class);
    annotationReader.loadEndpointMethods(serviceContext, Test.class, config.getApiClassConfig().getMethods());
    ApiParameterConfig parameter = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Test.class.getDeclaredMethod("setT", Object.class))).getParameterConfigs().get(0);
    assertEquals(ApiParameterConfig.Classification.UNKNOWN, parameter.getClassification());
}
Also used : ApiParameterConfig(com.google.api.server.spi.config.model.ApiParameterConfig) 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 17 with ApiParameterConfig

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

the class ApiConfigAnnotationReaderTest method testParameterAnnotations_none.

@Test
public void testParameterAnnotations_none() throws Exception {
    @Api
    class Endpoint {

        @SuppressWarnings("unused")
        public void method(int foo) {
        }
    }
    ApiConfig config = createConfig(Endpoint.class);
    annotationReader.loadEndpointClass(serviceContext, Endpoint.class, config);
    annotationReader.loadEndpointMethods(serviceContext, Endpoint.class, config.getApiClassConfig().getMethods());
    ApiMethodConfig methodConfig = Iterables.getOnlyElement(config.getApiClassConfig().getMethods().values());
    ApiParameterConfig parameterConfig = Iterables.getOnlyElement(methodConfig.getParameterConfigs());
    validateParameter(parameterConfig, null, false, null, int.class, null, int.class);
}
Also used : ApiParameterConfig(com.google.api.server.spi.config.model.ApiParameterConfig) ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) 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

ApiParameterConfig (com.google.api.server.spi.config.model.ApiParameterConfig)17 Api (com.google.api.server.spi.config.Api)7 ApiConfig (com.google.api.server.spi.config.model.ApiConfig)7 SimpleLevelOverridingApi (com.google.api.server.spi.testing.SimpleLevelOverridingApi)7 SimpleLevelOverridingInheritedApi (com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi)7 Test (org.junit.Test)6 ApiMethodConfig (com.google.api.server.spi.config.model.ApiMethodConfig)4 Schema (com.google.api.server.spi.config.model.Schema)4 JsonSchema (com.google.api.services.discovery.model.JsonSchema)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 EndpointMethod (com.google.api.server.spi.EndpointMethod)2 Foo (com.google.api.server.spi.testing.Foo)2 RestMethod (com.google.api.services.discovery.model.RestMethod)2 Request (com.google.api.services.discovery.model.RestMethod.Request)2 Response (com.google.api.services.discovery.model.RestMethod.Response)2 ArrayList (java.util.ArrayList)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 DefaultValue (com.google.api.server.spi.config.DefaultValue)1 Description (com.google.api.server.spi.config.Description)1