Search in sources :

Example 6 with Nullable

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

the class ApiConfigAnnotationReaderTest method testParameterAnnotations.

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

        @SuppressWarnings("unused")
        public void method(@Named("foo") @Nullable @DefaultValue("4") 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, "foo", true, "4", int.class, null, int.class);
}
Also used : Named(com.google.api.server.spi.config.Named) DefaultValue(com.google.api.server.spi.config.DefaultValue) 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) Nullable(com.google.api.server.spi.config.Nullable) Test(org.junit.Test)

Aggregations

Nullable (com.google.api.server.spi.config.Nullable)6 Test (org.junit.Test)6 EndpointMethod (com.google.api.server.spi.EndpointMethod)5 Named (com.google.api.server.spi.config.Named)5 Method (java.lang.reflect.Method)5 Api (com.google.api.server.spi.config.Api)1 DefaultValue (com.google.api.server.spi.config.DefaultValue)1 ApiConfig (com.google.api.server.spi.config.model.ApiConfig)1 ApiMethodConfig (com.google.api.server.spi.config.model.ApiMethodConfig)1 ApiParameterConfig (com.google.api.server.spi.config.model.ApiParameterConfig)1 SimpleLevelOverridingApi (com.google.api.server.spi.testing.SimpleLevelOverridingApi)1 SimpleLevelOverridingInheritedApi (com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi)1 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1