use of com.google.api.server.spi.config.ApiClass 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());
}
use of com.google.api.server.spi.config.ApiClass in project endpoints-java by cloudendpoints.
the class ApiConfigValidatorTest method testDifferentApisWithSameApiWideConfig.
@Test
public void testDifferentApisWithSameApiWideConfig() throws Exception {
@Api(name = "testApi", version = "v1", resource = "foo")
final class Test1 {
}
ApiConfig config1 = configLoader.loadConfiguration(ServiceContext.create(), Test1.class);
@Api(name = "testApi", version = "v1", resource = "foo")
@ApiClass(resource = "bar")
final class Test2 {
}
ApiConfig config2 = configLoader.loadConfiguration(ServiceContext.create(), Test2.class);
validator.validate(Lists.newArrayList(config1, config2));
}
Aggregations