use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class ApiConfigValidatorTest method testValidateMethods_ignoredMethod.
@Test
public void testValidateMethods_ignoredMethod() throws Exception {
final class Bean {
}
@Api
final class Endpoint {
@ApiMethod(ignored = AnnotationBoolean.TRUE)
public void thisShouldBeIgnored(Bean resource1, Bean resource2) {
}
}
ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), Endpoint.class);
// If this passes validation, then no error will be thrown. Otherwise, the validator will
// complain that the method has two resources.
validator.validate(config);
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class ApiConfigValidatorTest method testApiMethodConfigWithApiMethodNameContainingContinuousDots.
@Test
public void testApiMethodConfigWithApiMethodNameContainingContinuousDots() throws Exception {
@Api(name = "testApi", version = "v1", resource = "bar")
final class Test {
@ApiMethod(name = "TestApi..testMethod")
public void test() {
}
}
ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), Test.class);
try {
validator.validate(config);
fail("Expected InvalidMethodNameException.");
} catch (InvalidMethodNameException expected) {
}
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class ApiConfigValidatorTest method testApiWideConfigWithInvalidApiName.
@Test
public void testApiWideConfigWithInvalidApiName() throws Exception {
@Api(name = "TestApi", version = "v1", resource = "bar")
final class Test {
}
ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), Test.class);
try {
validator.validate(config);
fail("Expected InvalidApiNameException.");
} catch (InvalidApiNameException expected) {
}
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class ApiConfigAnnotationReaderTest method testMethodDescription.
@Test
public void testMethodDescription() throws Exception {
@Api
final class MethodDescriptionEndpoint {
public void noAnnotation() {
}
@ApiMethod
public void noDescription() {
}
@ApiMethod(description = "description")
public void withDescription() {
}
}
ApiConfig config = createConfig(MethodDescriptionEndpoint.class);
annotationReader.loadEndpointMethods(serviceContext, MethodDescriptionEndpoint.class, config.getApiClassConfig().getMethods());
ApiMethodConfig method1 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(MethodDescriptionEndpoint.class.getMethod("noAnnotation")));
assertNull(method1.getDescription());
ApiMethodConfig method2 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(MethodDescriptionEndpoint.class.getMethod("noDescription")));
assertNull(method2.getDescription());
ApiMethodConfig method3 = config.getApiClassConfig().getMethods().get(methodToEndpointMethod(MethodDescriptionEndpoint.class.getMethod("withDescription")));
assertEquals("description", method3.getDescription());
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testCanonicalName.
@Test
public void testCanonicalName() throws Exception {
@Api(name = "myapi", canonicalName = "My API")
class CanonicalApi {
}
String apiConfigSource = g.generateConfig(CanonicalApi.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
assertEquals("myapi", root.path("name").asText());
assertEquals("My API", root.path("canonicalName").asText());
}
Aggregations