use of com.google.api.server.spi.config.Api 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);
}
use of com.google.api.server.spi.config.Api 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
}
}
use of com.google.api.server.spi.config.Api 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.Api in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testParameterAnnotations_javax.
@Test
public void testParameterAnnotations_javax() throws Exception {
@Api
class Endpoint {
@SuppressWarnings("unused")
public void method(@javax.inject.Named("foo") @javax.annotation.Nullable 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, null, int.class, null, int.class);
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class ApiConfigValidatorTest method testApiMethodConfigWithApiMethodNameContainingSpecialCharacter.
@Test
public void testApiMethodConfigWithApiMethodNameContainingSpecialCharacter() throws Exception {
@Api(name = "testApi", version = "v1", resource = "bar")
final class Test {
@ApiMethod(name = "Api.Test#Method")
public void test() {
}
}
ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), Test.class);
try {
validator.validate(config);
fail("Expected InvalidMethodNameException.");
} catch (InvalidMethodNameException expected) {
}
}
Aggregations