use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testMethodPaths_inheritanceResourceSpecified.
@Test
public void testMethodPaths_inheritanceResourceSpecified() throws Exception {
@Api(resource = "foos")
class Foos extends GenFoos<Foo> {
}
String apiConfigSource = g.generateConfig(Foos.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
GenFoos.verifyMethodPathsAndHttpMethods(Foos.class, "foos", root, "foos");
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testArrayOfSerializedResources.
@Test
public void testArrayOfSerializedResources() throws Exception {
@Api
class ResourceCollection {
@SuppressWarnings("unused")
public void foo(@Named("beans") List<StringBean> beans) {
}
}
String apiConfigSource = g.generateConfig(ResourceCollection.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
JsonNode methodNode = root.path("methods").path("myapi.resourceCollection.foo");
assertFalse(methodNode.isMissingNode());
verifyMethodRequestParameter(methodNode.get("request"), "beans", "string", true, true);
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testGenericCollectionRequest.
@Test
public void testGenericCollectionRequest() throws Exception {
@Api
abstract class GenericCollection<T> {
@SuppressWarnings("unused")
public void foo(@Named("collection") Collection<T> t) {
}
}
// TODO: remove with JDK8, dummy to force inclusion of GenericArray to InnerClass attribute
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=2210448
GenericCollection<Long> dummy = new GenericCollection<Long>() {
};
class Int64Collection extends GenericCollection<Long> {
}
String apiConfigSource = g.generateConfig(Int64Collection.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
JsonNode methodNode = root.path("methods").path("myapi.int64Collection.foo");
assertFalse(methodNode.isMissingNode());
verifyMethodRequestParameter(methodNode.get("request"), "collection", "int64", true, true);
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testChainedSerializer.
@Test
public void testChainedSerializer() throws Exception {
class BarToBazSerializer extends DefaultValueSerializer<Bar, Baz> {
}
class BazToDateSerializer extends DefaultValueSerializer<Baz, Date> {
}
class Qux {
@SuppressWarnings("unused")
public Bar getSomeBar() {
return null;
}
}
@Api(transformers = { BazToDateSerializer.class, BarToBazSerializer.class })
class QuxEndpoint {
@SuppressWarnings("unused")
public Qux getQux() {
return null;
}
}
String apiConfigSource = g.generateConfig(QuxEndpoint.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
JsonNode qux = root.path("descriptor").path("schemas").path("Qux");
verifyObjectPropertySchema(qux, "someBar", "string", "date-time");
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testMultipleCollectionRequests.
@Test
public void testMultipleCollectionRequests() throws Exception {
@Api
class MultipleCollections {
@SuppressWarnings("unused")
public void foo(@Named("ids") Long[] ids, @Named("authors") List<String> authors) {
}
}
String apiConfigSource = g.generateConfig(MultipleCollections.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
JsonNode methodNode = root.path("methods").path("myapi.multipleCollections.foo");
assertFalse(methodNode.isMissingNode());
verifyMethodRequestParameter(methodNode.get("request"), "ids", "int64", true, true);
verifyMethodRequestParameter(methodNode.get("request"), "authors", "string", true, true);
}
Aggregations