Search in sources :

Example 1 with SimpleLevelOverridingInheritedApi

use of com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi in project endpoints-java by cloudendpoints.

the class ApiConfigAnnotationReaderTest method testLevelOverridingWithDefaultOverrides.

@Test
public void testLevelOverridingWithDefaultOverrides() throws Exception {
    @Api(scopes = { "s0c", "s1c" }, audiences = { "a0c", "a1c" }, clientIds = { "c0c", "c1c" }, resource = "resource2", useDatastoreForAdditionalConfig = AnnotationBoolean.TRUE)
    final class Test extends SimpleLevelOverridingInheritedApi {
    }
    ApiConfig config = createConfig(Test.class);
    annotationReader.loadEndpointClass(serviceContext, Test.class, config);
    annotationReader.loadEndpointMethods(serviceContext, Test.class, config.getApiClassConfig().getMethods());
    // All values overridden at a lower level, so nothing should change.
    verifySimpleLevelOverriding(config);
}
Also used : SimpleLevelOverridingInheritedApi(com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi) 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 2 with SimpleLevelOverridingInheritedApi

use of com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi in project endpoints-java by cloudendpoints.

the class ApiConfigAnnotationReaderTest method testLevelOverridingWithClassOverrides.

@Test
public void testLevelOverridingWithClassOverrides() throws Exception {
    @ApiClass(scopes = { "s0c", "s1c" }, audiences = { "a0c", "a1c" }, clientIds = { "c0c", "c1c" }, resource = "resource2", useDatastoreForAdditionalConfig = AnnotationBoolean.TRUE)
    final class Test extends SimpleLevelOverridingInheritedApi {
    }
    ApiConfig config = createConfig(Test.class);
    annotationReader.loadEndpointClass(serviceContext, Test.class, config);
    assertEquals("resource2", config.getApiClassConfig().getResource());
    assertTrue(config.getApiClassConfig().getUseDatastore());
    annotationReader.loadEndpointMethods(serviceContext, Test.class, config.getApiClassConfig().getMethods());
    ApiMethodConfig noOverrides = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(SimpleLevelOverridingApi.class.getMethod("noOverrides")));
    assertEquals(toScopeExpression("s0c", "s1c"), noOverrides.getScopeExpression());
    assertEquals(Lists.newArrayList("a0c", "a1c"), noOverrides.getAudiences());
    assertEquals(Lists.newArrayList("c0c", "c1c"), noOverrides.getClientIds());
    ApiMethodConfig overrides = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(SimpleLevelOverridingApi.class.getMethod("overrides")));
    assertEquals(toScopeExpression("s0b", "s1b"), overrides.getScopeExpression());
    assertEquals(Lists.newArrayList("a0b", "a1b"), overrides.getAudiences());
    assertEquals(Lists.newArrayList("c0b", "c1b"), 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) ApiClass(com.google.api.server.spi.config.ApiClass) Test(org.junit.Test)

Example 3 with SimpleLevelOverridingInheritedApi

use of com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi 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)

Aggregations

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