use of com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader in project endpoints-java by cloudendpoints.
the class JsonConfigWriterTest method multipleResourceParametersErrorMessage.
/**
* Tests that if a method has multiple resource parameters, a helpful message is thrown.
*/
@Test
public void multipleResourceParametersErrorMessage() throws Exception {
final class Endpoint {
@SuppressWarnings("unused")
public void get(Bean bean1, Bean bean2) {
}
}
new ApiConfigAnnotationReader().loadEndpointMethods(serviceContext, Endpoint.class, apiConfig.getApiClassConfig().getMethods());
try {
writer.writeConfig(Collections.singleton(apiConfig));
fail("Method with multiple resources should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage()).contains("cannot have multiple resource parameters");
}
}
use of com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader in project endpoints-java by cloudendpoints.
the class JsonConfigWriterTest method idIsASpecialCaseForPropertyConflicts.
@Test
public void idIsASpecialCaseForPropertyConflicts() throws Exception {
final class Endpoint {
@SuppressWarnings("unused")
public void set(@Named("id") String id, IdBean resource) {
}
@SuppressWarnings("unused")
public IdBean get(@Named("id") String id) {
return null;
}
@SuppressWarnings("unused")
public IdBean update(@Named("id") String id) {
return null;
}
@SuppressWarnings("unused")
public void remove(@Named("id") String id) {
}
}
new ApiConfigAnnotationReader().loadEndpointMethods(serviceContext, Endpoint.class, apiConfig.getApiClassConfig().getMethods());
writer.writeConfig(Collections.singleton(apiConfig));
}
use of com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader in project endpoints-java by cloudendpoints.
the class JsonConfigWriterTest method enumResponseIsBlocked.
@Test
public void enumResponseIsBlocked() throws Exception {
final class Endpoint {
@SuppressWarnings("unused")
public TestEnum get() {
return TestEnum.A;
}
}
new ApiConfigAnnotationReader().loadEndpointMethods(serviceContext, Endpoint.class, apiConfig.getApiClassConfig().getMethods());
try {
writer.writeConfig(Collections.singleton(apiConfig));
fail();
} catch (InvalidReturnTypeException e) {
// Expected.
}
}
use of com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader in project endpoints-java by cloudendpoints.
the class JsonConfigWriterTest method writeConfigWithParameterizedTypeNoTransformerConfig.
/**
* This tests writeConfig with a parameterized type, which should be supported by adding a schema
* named Qux_String.
*/
@Test
public void writeConfigWithParameterizedTypeNoTransformerConfig() throws Exception {
final class Endpoint {
@SuppressWarnings("unused")
public ParameterizedBean get(@Named("date") String id) {
return null;
}
}
new ApiConfigAnnotationReader().loadEndpointMethods(serviceContext, Endpoint.class, apiConfig.getApiClassConfig().getMethods());
Map<ApiKey, String> apiKeyStringMap = writer.writeConfig(Collections.singleton(apiConfig));
String configString = Iterables.getFirst(apiKeyStringMap.values(), null);
assertThat(configString).contains("Qux_String");
}
use of com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader in project endpoints-java by cloudendpoints.
the class JsonConfigWriterTest method bodyFieldConflictsWithParameter.
@Test
@Ignore("ignored until we find a proper solution")
public void bodyFieldConflictsWithParameter() throws Exception {
final class Endpoint {
@SuppressWarnings("unused")
public void set(@Named("date") String id, Bean resource) {
}
}
new ApiConfigAnnotationReader().loadEndpointMethods(serviceContext, Endpoint.class, apiConfig.getApiClassConfig().getMethods());
try {
writer.writeConfig(Collections.singleton(apiConfig));
fail();
} catch (PropertyParameterNameConflictException e) {
// Expected.
}
}
Aggregations