Search in sources :

Example 86 with ApiConfig

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

the class ApiConfigAnnotationReaderTest method testSimpleLevelOverriding.

@Test
public void testSimpleLevelOverriding() throws Exception {
    ApiConfig config = createConfig(SimpleLevelOverridingApi.class);
    annotationReader.loadEndpointClass(serviceContext, SimpleLevelOverridingApi.class, config);
    annotationReader.loadEndpointMethods(serviceContext, SimpleLevelOverridingApi.class, config.getApiClassConfig().getMethods());
    verifySimpleLevelOverriding(config);
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 87 with ApiConfig

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

the class JsonConfigWriterTest method writeConfigWithParameterizedTypeTransformerConfig.

/**
 * This tests writeConfig with a parameterized type which is transformed to {@code String}.
 * When the transformer is present, writeConfig should not throw an exception.
 */
@Test
public void writeConfigWithParameterizedTypeTransformerConfig() throws Exception {
    ApiConfig transformedApiConfig = configFactory.copy(apiConfig);
    transformedApiConfig.getSerializationConfig().addSerializationConfig(ParameterizedTypeTransformer.class);
    final class Endpoint {

        @SuppressWarnings("unused")
        public ParameterizedBean get(@Named("date") String id) {
            return null;
        }
    }
    new ApiConfigAnnotationReader().loadEndpointMethods(serviceContext, Endpoint.class, transformedApiConfig.getApiClassConfig().getMethods());
    writer.writeConfig(Collections.singleton(transformedApiConfig));
}
Also used : ApiConfigAnnotationReader(com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader) Named(javax.inject.Named) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 88 with ApiConfig

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

the class ApiConfigAnnotationReaderTest method testGenericBasePartiallySpecializedEndpoint.

@Test
public void testGenericBasePartiallySpecializedEndpoint() throws Exception {
    ApiConfig config = createConfig(RestfulResourceEndpointBase.PartiallySpecializedEndpoint.class);
    annotationReader.loadEndpointMethods(serviceContext, RestfulResourceEndpointBase.PartiallySpecializedEndpoint.class, config.getApiClassConfig().getMethods());
    assertEquals(6, config.getApiClassConfig().getMethods().size());
    assertNull(config.getApiClassConfig().getMethods().get(methodToEndpointMethod(RestfulResourceEndpointBase.FullySpecializedEndpoint.class.getMethod("list"))));
    assertNotNull(config.getApiClassConfig().getMethods().get(methodToEndpointMethod(RestfulResourceEndpointBase.PartiallySpecializedEndpoint.class, RestfulResourceEndpointBase.PartiallySpecializedEndpoint.class.getMethod("get", long.class))));
    assertNotNull(config.getApiClassConfig().getMethods().get(methodToEndpointMethod(RestfulResourceEndpointBase.PartiallySpecializedEndpoint.class, RestfulResourceEndpointBase.class.getMethod("list"))));
}
Also used : RestfulResourceEndpointBase(com.google.api.server.spi.testing.RestfulResourceEndpointBase) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 89 with ApiConfig

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

the class ApiConfigAnnotationReaderTest method testEndpointWithNoPublicMethods.

@Test
public void testEndpointWithNoPublicMethods() throws Exception {
    ApiConfig config = createConfig(Endpoint2.class);
    annotationReader.loadEndpointMethods(serviceContext, Endpoint2.class, config.getApiClassConfig().getMethods());
    assertEquals(0, config.getApiClassConfig().getMethods().size());
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 90 with ApiConfig

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

the class ApiConfigAnnotationReaderTest method testServiceWithApiNameOverride.

@Test
public void testServiceWithApiNameOverride() throws Exception {
    ApiConfig config = createConfig(Endpoint4.class);
    annotationReader.loadEndpointClass(serviceContext, Endpoint4.class, config);
    assertEquals("api4", config.getName());
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Aggregations

ApiConfig (com.google.api.server.spi.config.model.ApiConfig)91 Test (org.junit.Test)72 Api (com.google.api.server.spi.config.Api)29 ApiMethodConfig (com.google.api.server.spi.config.model.ApiMethodConfig)26 SimpleLevelOverridingInheritedApi (com.google.api.server.spi.testing.SimpleLevelOverridingInheritedApi)20 SimpleLevelOverridingApi (com.google.api.server.spi.testing.SimpleLevelOverridingApi)18 ApiKey (com.google.api.server.spi.config.model.ApiKey)9 Swagger (io.swagger.models.Swagger)8 ApiParameterConfig (com.google.api.server.spi.config.model.ApiParameterConfig)7 TypeLoader (com.google.api.server.spi.TypeLoader)5 ApiConfigLoader (com.google.api.server.spi.config.ApiConfigLoader)4 ApiConfigValidator (com.google.api.server.spi.config.validation.ApiConfigValidator)4 ServiceContext (com.google.api.server.spi.ServiceContext)3 ApiConfigAnnotationReader (com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ApiClass (com.google.api.server.spi.config.ApiClass)2 ApiFrontendLimits (com.google.api.server.spi.config.ApiFrontendLimits)2 ApiReference (com.google.api.server.spi.config.ApiReference)2 Named (com.google.api.server.spi.config.Named)2 ApiAuthConfig (com.google.api.server.spi.config.model.ApiAuthConfig)2