use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testSerializedPropertyInResourceSchema.
@Test
public void testSerializedPropertyInResourceSchema() throws Exception {
class BazToDateSerializer extends DefaultValueSerializer<Baz, Date> {
}
@Api(transformers = { BazToDateSerializer.class, BarResourceSerializer.class })
class BarEndpoint {
@SuppressWarnings("unused")
public Bar getBar() {
return null;
}
}
String apiConfigSource = g.generateConfig(BarEndpoint.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
JsonNode bar = root.path("descriptor").path("schemas").path("Bar");
verifyObjectPropertySchema(bar, "someBaz", "string", "date-time");
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testMethodPaths_inheritanceResourceInheritedAndSpecified.
@Test
public void testMethodPaths_inheritanceResourceInheritedAndSpecified() throws Exception {
@Api(resource = "foos")
class Foos extends GenBars<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 testValidDateInParameter.
@Test
public void testValidDateInParameter() throws Exception {
@Api
class DateParameter {
@SuppressWarnings("unused")
public void foo(@Named("date") Date date) {
}
}
String apiConfigSource = g.generateConfig(DateParameter.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
JsonNode request = root.path("methods").path("myapi.dateParameter.foo").path("request");
verifyMethodRequestParameter(request, "date", "datetime", true, false);
assertTrue(root.path("descriptor").path("schemas").path("Outcome").isMissingNode());
verifyEmptyMethodRequest(root, DateParameter.class.getName() + ".pick");
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testTitle.
@Test
public void testTitle() throws Exception {
@Api(name = "myapi", title = "My API Title")
class ApiWithTitle {
}
String apiConfigSource = g.generateConfig(ApiWithTitle.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
assertEquals("myapi", root.path("name").asText());
assertEquals("My API Title", root.path("title").asText());
}
use of com.google.api.server.spi.config.Api in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testMethodPaths_apiAtCustomPath.
@Test
public void testMethodPaths_apiAtCustomPath() throws Exception {
@SuppressWarnings("unused")
@Api(resource = "foos")
class Foos {
public List<Foo> list() {
return null;
}
public Foo get(@Named("id") Long id) {
return null;
}
}
String apiConfigSource = g.generateConfig(Foos.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
verifyMethodPathAndHttpMethod(root, "myapi.foos.list", "foos", "GET");
verifyMethodPathAndHttpMethod(root, "myapi.foos.get", "foos/{id}", "GET");
}
Aggregations