Search in sources :

Example 1 with InvalidReturnTypeException

use of com.google.api.server.spi.config.validation.InvalidReturnTypeException 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.
    }
}
Also used : ApiConfigAnnotationReader(com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader) InvalidReturnTypeException(com.google.api.server.spi.config.validation.InvalidReturnTypeException) Test(org.junit.Test)

Example 2 with InvalidReturnTypeException

use of com.google.api.server.spi.config.validation.InvalidReturnTypeException in project endpoints-java by cloudendpoints.

the class JsonConfigWriterTest method primitiveResponseIsBlocked.

@Test
public void primitiveResponseIsBlocked() throws Exception {
    final class Endpoint {

        @SuppressWarnings("unused")
        public int get() {
            return 4;
        }
    }
    new ApiConfigAnnotationReader().loadEndpointMethods(serviceContext, Endpoint.class, apiConfig.getApiClassConfig().getMethods());
    try {
        writer.writeConfig(Collections.singleton(apiConfig));
        fail();
    } catch (InvalidReturnTypeException e) {
    // Expected.
    }
}
Also used : ApiConfigAnnotationReader(com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader) InvalidReturnTypeException(com.google.api.server.spi.config.validation.InvalidReturnTypeException) Test(org.junit.Test)

Aggregations

ApiConfigAnnotationReader (com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader)2 InvalidReturnTypeException (com.google.api.server.spi.config.validation.InvalidReturnTypeException)2 Test (org.junit.Test)2