use of javax.inject.Named 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 javax.inject.Named in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testSerializedEnum.
@Test
public void testSerializedEnum() throws Exception {
class OutcomeToIntegerSerializer extends DefaultValueSerializer<Outcome, Integer> {
}
@Api(transformers = { OutcomeToIntegerSerializer.class })
class EnumParameter {
@SuppressWarnings("unused")
public void foo(@Named("outcome") Outcome outcome) {
}
}
String apiConfigSource = g.generateConfig(EnumParameter.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
JsonNode request = root.path("methods").path("myapi.enumParameter.foo").path("request");
verifyMethodRequestParameter(request, "outcome", "int32", true, false);
}
use of javax.inject.Named in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testCollectionRequest.
@Test
public void testCollectionRequest() throws Exception {
@Api
class BooleanCollection {
@SuppressWarnings("unused")
public void foo(@Named("collection") Collection<Boolean> b) {
}
}
String apiConfigSource = g.generateConfig(BooleanCollection.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
JsonNode methodNode = root.path("methods").path("myapi.booleanCollection.foo");
assertFalse(methodNode.isMissingNode());
verifyMethodRequestParameter(methodNode.get("request"), "collection", "boolean", true, true);
}
use of javax.inject.Named in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testValidEnumInParameter.
@Test
public void testValidEnumInParameter() throws Exception {
@Api
class EnumParameter {
@SuppressWarnings("unused")
public void pick(@Named("outcome") Outcome outcome) {
}
}
String apiConfigSource = g.generateConfig(EnumParameter.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
JsonNode request = root.path("methods").path("myapi.enumParameter.pick").path("request");
verifyMethodRequestParameter(request, "outcome", "string", true, false, "WON", "LOST", "TIE");
assertTrue(root.path("descriptor").path("schemas").path("Outcome").isMissingNode());
verifyEmptyMethodRequest(root, EnumParameter.class.getName() + ".pick");
}
use of javax.inject.Named in project endpoints-java by cloudendpoints.
the class AnnotationApiConfigGeneratorTest method testDateCollection.
@Test
public void testDateCollection() throws Exception {
@Api
class DateParameters {
@SuppressWarnings("unused")
public void foo(@Named("date") Date date, @Named("dates1") Collection<Date> dates1, @Named("dates2") Date[] dates2) {
}
}
String apiConfigSource = g.generateConfig(DateParameters.class).get("myapi-v1.api");
ObjectNode root = objectMapper.readValue(apiConfigSource, ObjectNode.class);
JsonNode request = root.path("methods").path("myapi.dateParameters.foo").path("request");
verifyMethodRequestParameter(request, "date", "datetime", true, false);
verifyMethodRequestParameter(request, "dates1", "datetime", true, true);
verifyMethodRequestParameter(request, "dates2", "datetime", true, true);
verifyEmptyMethodRequest(root, DateParameters.class.getName() + ".foo");
}
Aggregations