use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testServiceWithMergedInheritance.
@Test
public void testServiceWithMergedInheritance() throws Exception {
ApiConfig config = createConfig(SubclassedEndpoint.class);
annotationReader.loadEndpointClass(serviceContext, SubclassedEndpoint.class, config);
annotationReader.loadEndpointMethods(serviceContext, SubclassedEndpoint.class, config.getApiClassConfig().getMethods());
validateEndpoint1(config, SubclassedEndpoint.class);
}
use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testSerializedParameter.
@Test
public void testSerializedParameter() throws Exception {
@Api
final class Test {
@SuppressWarnings("unused")
public void method(@Named("serialized") TestBean tb) {
}
}
ApiConfig config = createConfig(Test.class);
annotationReader.loadEndpointClass(serviceContext, Test.class, config);
annotationReader.loadEndpointMethods(serviceContext, Test.class, config.getApiClassConfig().getMethods());
ApiMethodConfig methodConfig = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Test.class.getMethod("method", TestBean.class)));
validateMethod(methodConfig, "Test.method", "method/{serialized}", ApiMethod.HttpMethod.POST, DEFAULT_SCOPES, DEFAULT_AUDIENCES, DEFAULT_CLIENTIDS, null, null);
validateParameter(methodConfig.getParameterConfigs().get(0), "serialized", false, null, TestBean.class, TestSerializer.class, String.class);
}
use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testMethodAuthDefaults.
@Test
public void testMethodAuthDefaults() throws Exception {
// Default.
@Api
final class Test1 {
@SuppressWarnings("unused")
public void method() {
}
}
ApiConfig config = createConfig(Test1.class);
annotationReader.loadEndpointMethods(serviceContext, Test1.class, config.getApiClassConfig().getMethods());
ApiMethodConfig methodConfig = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Test1.class.getMethod("method")));
validateMethodForAuth(methodConfig, DEFAULT_SCOPES, DEFAULT_AUDIENCES, DEFAULT_CLIENTIDS, DEFAULT_AUTH_LEVEL);
// Method explicitly set scopes, etc. empty.
@Api
final class Test2 {
@SuppressWarnings("unused")
@ApiMethod(scopes = {}, audiences = {}, clientIds = {})
public void method() {
}
}
config = createConfig(Test2.class);
annotationReader.loadEndpointMethods(serviceContext, Test2.class, config.getApiClassConfig().getMethods());
methodConfig = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Test2.class.getMethod("method")));
String[] empty = {};
validateMethodForAuth(methodConfig, empty, empty, empty, DEFAULT_AUTH_LEVEL);
// Api explicitly set scopes, etc. empty.
@Api(scopes = {}, audiences = {}, clientIds = {})
final class Test3 {
@SuppressWarnings("unused")
public void method() {
}
}
config = createConfig(Test3.class);
annotationReader.loadEndpointClass(serviceContext, Test3.class, config);
annotationReader.loadEndpointMethods(serviceContext, Test3.class, config.getApiClassConfig().getMethods());
methodConfig = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Test3.class.getMethod("method")));
validateMethodForAuth(methodConfig, empty, empty, empty, DEFAULT_AUTH_LEVEL);
// Method explicitly set scopes, etc. empty and overwrite Api.
@Api(scopes = { "s0", "s1 s2" }, audiences = { "a0", "a1" }, clientIds = { "c0", "c1" })
final class Test4 {
@SuppressWarnings("unused")
@ApiMethod(scopes = {}, audiences = {}, clientIds = {})
public void method() {
}
}
config = createConfig(Test4.class);
annotationReader.loadEndpointClass(serviceContext, Test4.class, config);
annotationReader.loadEndpointMethods(serviceContext, Test4.class, config.getApiClassConfig().getMethods());
methodConfig = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(Test4.class.getMethod("method")));
validateMethodForAuth(methodConfig, empty, empty, empty, DEFAULT_AUTH_LEVEL);
}
use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testServiceWithOverridingInterfaceReference.
@Test
public void testServiceWithOverridingInterfaceReference() throws Exception {
ApiConfig config = createConfig(InterfaceReferenceEndpoint.class);
annotationReader.loadEndpointClass(serviceContext, InterfaceReferenceEndpoint.class, config);
assertEquals("interfaceBasedApi", config.getName());
assertEquals("v2", config.getVersion());
}
use of com.google.api.server.spi.config.model.ApiConfig in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testWildcardParameterTypes.
@Test
public void testWildcardParameterTypes() throws Exception {
@Api
final class WildcardEndpoint {
@SuppressWarnings("unused")
public void foo(Map<String, ? extends Integer> map) {
}
}
try {
ApiConfig config = createConfig(WildcardEndpoint.class);
annotationReader.loadEndpointMethods(serviceContext, WildcardEndpoint.class, config.getApiClassConfig().getMethods());
fail("Config generation for service class with wildcard parameter type should have failed");
} catch (IllegalArgumentException e) {
// expected
}
}
Aggregations