Search in sources :

Example 56 with ApiConfig

use of com.google.api.server.spi.config.model.ApiConfig 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 57 with ApiConfig

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

the class ApiConfigAnnotationReaderTest method testLevelOverridingWithMethodOverrides.

@Test
public void testLevelOverridingWithMethodOverrides() throws Exception {
    final class Test extends SimpleLevelOverridingInheritedApi {

        @ApiMethod(scopes = { "s0c", "s1c" }, audiences = { "a0c", "a1c" }, clientIds = { "c0c", "c1c" })
        @Override
        public void overrides() {
            super.overrides();
        }
    }
    ApiConfig config = createConfig(Test.class);
    annotationReader.loadEndpointClass(serviceContext, Test.class, config);
    annotationReader.loadEndpointMethods(serviceContext, Test.class, config.getApiClassConfig().getMethods());
    ApiMethodConfig overrides = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Test.class.getMethod("overrides")));
    assertEquals(toScopeExpression("s0c", "s1c"), overrides.getScopeExpression());
    assertEquals(Lists.newArrayList("a0c", "a1c"), overrides.getAudiences());
    assertEquals(Lists.newArrayList("c0c", "c1c"), overrides.getClientIds());
}
Also used : ApiMethodConfig(com.google.api.server.spi.config.model.ApiMethodConfig) SimpleLevelOverridingInheritedApi(com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 58 with ApiConfig

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

the class ApiConfigAnnotationReaderTest method testServiceWithSimpleReference.

@Test
public void testServiceWithSimpleReference() throws Exception {
    ApiConfig config = createConfig(SimpleReferenceEndpoint.class);
    annotationReader.loadEndpointClass(serviceContext, SimpleReferenceEndpoint.class, config);
    // Especially should not be "api4" as provided by the inherited Endpoint4.
    assertEquals("api", config.getName());
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 59 with ApiConfig

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

the class ApiConfigAnnotationReaderTest method testFrontendLimitsRulesNotDuplicatedInInheritance.

@Test
public void testFrontendLimitsRulesNotDuplicatedInInheritance() throws Exception {
    @Api(frontendLimits = @ApiFrontendLimits(rules = { @ApiFrontendLimitRule(match = "test", qps = 1) }))
    class Test {
    }
    final class Child extends Test {
    }
    ApiConfig config = createConfig(Child.class);
    annotationReader.loadEndpointClass(serviceContext, Child.class, config);
    assertEquals(1, config.getFrontendLimitsConfig().getRules().size());
}
Also used : Test(org.junit.Test) ApiFrontendLimits(com.google.api.server.spi.config.ApiFrontendLimits) 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 60 with ApiConfig

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

the class ApiConfigAnnotationReaderTest method testSimpleLevelOverridingWithInheritance.

@Test
public void testSimpleLevelOverridingWithInheritance() throws Exception {
    ApiConfig config = createConfig(SimpleLevelOverridingInheritedApi.class);
    annotationReader.loadEndpointClass(serviceContext, SimpleLevelOverridingInheritedApi.class, config);
    annotationReader.loadEndpointMethods(serviceContext, SimpleLevelOverridingInheritedApi.class, config.getApiClassConfig().getMethods());
    verifySimpleLevelOverriding(config);
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Aggregations

ApiConfig (com.google.api.server.spi.config.model.ApiConfig)91 Test (org.junit.Test)72 Api (com.google.api.server.spi.config.Api)29 ApiMethodConfig (com.google.api.server.spi.config.model.ApiMethodConfig)26 SimpleLevelOverridingInheritedApi (com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi)20 SimpleLevelOverridingApi (com.google.api.server.spi.testing.SimpleLevelOverridingApi)18 ApiKey (com.google.api.server.spi.config.model.ApiKey)9 Swagger (io.swagger.models.Swagger)8 ApiParameterConfig (com.google.api.server.spi.config.model.ApiParameterConfig)7 TypeLoader (com.google.api.server.spi.TypeLoader)5 ApiConfigLoader (com.google.api.server.spi.config.ApiConfigLoader)4 ApiConfigValidator (com.google.api.server.spi.config.validation.ApiConfigValidator)4 ServiceContext (com.google.api.server.spi.ServiceContext)3 ApiConfigAnnotationReader (com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ApiClass (com.google.api.server.spi.config.ApiClass)2 ApiFrontendLimits (com.google.api.server.spi.config.ApiFrontendLimits)2 ApiReference (com.google.api.server.spi.config.ApiReference)2 Named (com.google.api.server.spi.config.Named)2 ApiAuthConfig (com.google.api.server.spi.config.model.ApiAuthConfig)2