Search in sources :

Example 6 with ApiSerializationConfig

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

the class ApiAnnotationIntrospectorTest method testApiDeserializationByConfig.

@Test
public void testApiDeserializationByConfig() throws Exception {
    ApiSerializationConfig config = new ApiSerializationConfig();
    config.addSerializationConfig(TestApiSerializationByConfigConverter.class);
    objectMapper.setAnnotationIntrospector(new ApiAnnotationIntrospector(config));
    TestApiSerializationByConfig value = objectMapper.readValue("\"test2serialized\"", TestApiSerializationByConfig.class);
    assertEquals("test2", value.getFoo());
}
Also used : ApiSerializationConfig(com.google.api.server.spi.config.model.ApiSerializationConfig) Test(org.junit.Test)

Example 7 with ApiSerializationConfig

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

the class RestServletRequestParamReaderTest method setUp.

@Before
public void setUp() throws Exception {
    endpointMethod = EndpointMethod.create(TestApi.class, TestApi.class.getMethod("test", Long.TYPE, List.class, SimpleDate.class, TestResource.class));
    request = new MockHttpServletRequest();
    ServiceContext serviceContext = ServiceContext.create();
    serializationConfig = new ApiSerializationConfig();
    TypeLoader typeLoader = new TypeLoader();
    apiConfig = new ApiConfig.Factory().create(serviceContext, typeLoader, TestApi.class);
    ApiConfigAnnotationReader annotationReader = new ApiConfigAnnotationReader();
    annotationReader.loadEndpointClass(serviceContext, TestApi.class, apiConfig);
    annotationReader.loadEndpointMethods(serviceContext, TestApi.class, apiConfig.getApiClassConfig().getMethods());
    methodConfig = apiConfig.getApiClassConfig().getMethods().get(endpointMethod);
}
Also used : ApiConfigAnnotationReader(com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServiceContext(com.google.api.server.spi.ServiceContext) TypeLoader(com.google.api.server.spi.TypeLoader) ApiSerializationConfig(com.google.api.server.spi.config.model.ApiSerializationConfig) Before(org.junit.Before)

Example 8 with ApiSerializationConfig

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

the class ApiAnnotationIntrospectorTest method testApiSerializationByConfig.

@Test
public void testApiSerializationByConfig() throws Exception {
    ApiSerializationConfig config = new ApiSerializationConfig();
    config.addSerializationConfig(TestApiSerializationByConfigConverter.class);
    objectMapper.setAnnotationIntrospector(new ApiAnnotationIntrospector(config));
    String json = objectMapper.writeValueAsString(new TestApiSerializationByConfig());
    JsonNode value = objectMapper.readValue(json, JsonNode.class);
    assertEquals("testserialized", value.asText());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ApiSerializationConfig(com.google.api.server.spi.config.model.ApiSerializationConfig) Test(org.junit.Test)

Example 9 with ApiSerializationConfig

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

the class ApiAnnotationIntrospectorTest method testApiSerializationByParameterizedConfig.

@Test
public void testApiSerializationByParameterizedConfig() throws Exception {
    ApiSerializationConfig config = new ApiSerializationConfig();
    config.addSerializationConfig(TestApiSerializationByParameterizedConfigConverter.class);
    objectMapper.setAnnotationIntrospector(new ApiAnnotationIntrospector(config));
    String json = objectMapper.writeValueAsString(new TestApiSerializationByParameterizedConfig<String>("paramtest"));
    JsonNode value = objectMapper.readValue(json, JsonNode.class);
    assertEquals("paramtestserialized", value.asText());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ApiSerializationConfig(com.google.api.server.spi.config.model.ApiSerializationConfig) Test(org.junit.Test)

Aggregations

ApiSerializationConfig (com.google.api.server.spi.config.model.ApiSerializationConfig)9 Test (org.junit.Test)4 Before (org.junit.Before)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 TypeLoader (com.google.api.server.spi.TypeLoader)2 ApiMethodConfig (com.google.api.server.spi.config.model.ApiMethodConfig)2 PassAuthenticator (com.google.api.server.spi.testing.PassAuthenticator)2 PassPeerAuthenticator (com.google.api.server.spi.testing.PassPeerAuthenticator)2 EndpointMethod (com.google.api.server.spi.EndpointMethod)1 ServiceContext (com.google.api.server.spi.ServiceContext)1 EndpointsAuthenticator (com.google.api.server.spi.auth.EndpointsAuthenticator)1 EndpointsPeerAuthenticator (com.google.api.server.spi.auth.EndpointsPeerAuthenticator)1 Authenticator (com.google.api.server.spi.config.Authenticator)1 PeerAuthenticator (com.google.api.server.spi.config.PeerAuthenticator)1 ApiConfigAnnotationReader (com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader)1 ApiAuthConfig (com.google.api.server.spi.config.model.ApiAuthConfig)1 ApiCacheControlConfig (com.google.api.server.spi.config.model.ApiCacheControlConfig)1 ApiFrontendLimitsConfig (com.google.api.server.spi.config.model.ApiFrontendLimitsConfig)1 SerializerConfig (com.google.api.server.spi.config.model.ApiSerializationConfig.SerializerConfig)1 FailAuthenticator (com.google.api.server.spi.testing.FailAuthenticator)1