Search in sources :

Example 11 with DiscoveryContext

use of com.google.api.server.spi.discovery.DiscoveryGenerator.DiscoveryContext in project endpoints-java by cloudendpoints.

the class DiscoveryGeneratorTest method testWriteDiscovery_newHostname.

@Test
public void testWriteDiscovery_newHostname() throws Exception {
    RestDescription doc = getDiscovery(new DiscoveryContext().setApiRoot("http://notlocalhost/api").setHostname("localhost:8080"), FooEndpoint.class);
    RestDescription expected = readExpectedAsDiscovery("foo_endpoint_localhost.json");
    compareDiscovery(expected, doc);
}
Also used : DiscoveryContext(com.google.api.server.spi.discovery.DiscoveryGenerator.DiscoveryContext) RestDescription(com.google.api.services.discovery.model.RestDescription) Test(org.junit.Test)

Example 12 with DiscoveryContext

use of com.google.api.server.spi.discovery.DiscoveryGenerator.DiscoveryContext in project endpoints-java by cloudendpoints.

the class DiscoveryGeneratorTest method testWriteDiscovery_parameterOrder.

@Test
public void testWriteDiscovery_parameterOrder() throws Exception {
    RestDescription doc = getDiscovery(new DiscoveryContext(), MultipleParameterEndpoint.class);
    RestDescription expected = readExpectedAsDiscovery("multiple_parameter_endpoint.json");
    compareDiscovery(expected, doc);
}
Also used : DiscoveryContext(com.google.api.server.spi.discovery.DiscoveryGenerator.DiscoveryContext) RestDescription(com.google.api.services.discovery.model.RestDescription) Test(org.junit.Test)

Example 13 with DiscoveryContext

use of com.google.api.server.spi.discovery.DiscoveryGenerator.DiscoveryContext in project endpoints-java by cloudendpoints.

the class DiscoveryGeneratorTest method testWriteDiscovery_MapEndpoint_WithArrayValue.

@Test
public void testWriteDiscovery_MapEndpoint_WithArrayValue() throws Exception {
    System.setProperty(MAP_SCHEMA_SUPPORT_ARRAYS_VALUES.systemPropertyName, "yes");
    try {
        RestDescription doc = getDiscovery(new DiscoveryContext(), MapEndpoint.class);
        RestDescription expected = readExpectedAsDiscovery("map_endpoint_with_array.json");
        compareDiscovery(expected, doc);
    } finally {
        System.clearProperty(MAP_SCHEMA_SUPPORT_ARRAYS_VALUES.systemPropertyName);
    }
}
Also used : DiscoveryContext(com.google.api.server.spi.discovery.DiscoveryGenerator.DiscoveryContext) RestDescription(com.google.api.services.discovery.model.RestDescription) Test(org.junit.Test)

Example 14 with DiscoveryContext

use of com.google.api.server.spi.discovery.DiscoveryGenerator.DiscoveryContext in project endpoints-java by cloudendpoints.

the class DiscoveryGeneratorTest method testWriteDiscovery_FooEndpointDefaultContext.

@Test
public void testWriteDiscovery_FooEndpointDefaultContext() throws Exception {
    RestDescription doc = getDiscovery(new DiscoveryContext(), FooEndpoint.class);
    RestDescription expected = readExpectedAsDiscovery("foo_endpoint_default_context.json");
    compareDiscovery(expected, doc);
}
Also used : DiscoveryContext(com.google.api.server.spi.discovery.DiscoveryGenerator.DiscoveryContext) RestDescription(com.google.api.services.discovery.model.RestDescription) Test(org.junit.Test)

Example 15 with DiscoveryContext

use of com.google.api.server.spi.discovery.DiscoveryGenerator.DiscoveryContext in project endpoints-java by cloudendpoints.

the class DiscoveryGeneratorTest method testWriteDiscovery_multipleApisWithSharedSchema.

@Test
public void testWriteDiscovery_multipleApisWithSharedSchema() throws Exception {
    // Read in an API that uses a resource with fields that have their own schema, then read in
    // another API that uses the same resource. The discovery for the second API should contain
    // both schema, rather than just the first one.
    getDiscovery(new DiscoveryContext(), EnumEndpointV2.class);
    RestDescription doc = getDiscovery(new DiscoveryContext(), EnumEndpoint.class);
    RestDescription expected = readExpectedAsDiscovery("enum_endpoint.json");
    compareDiscovery(expected, doc);
}
Also used : DiscoveryContext(com.google.api.server.spi.discovery.DiscoveryGenerator.DiscoveryContext) RestDescription(com.google.api.services.discovery.model.RestDescription) Test(org.junit.Test)

Aggregations

DiscoveryContext (com.google.api.server.spi.discovery.DiscoveryGenerator.DiscoveryContext)16 RestDescription (com.google.api.services.discovery.model.RestDescription)14 Test (org.junit.Test)14 ApiKey (com.google.api.server.spi.config.model.ApiKey)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Map (java.util.Map)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 ServiceContext (com.google.api.server.spi.ServiceContext)1 TypeLoader (com.google.api.server.spi.TypeLoader)1 ApiConfigLoader (com.google.api.server.spi.config.ApiConfigLoader)1 ApiConfigAnnotationReader (com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader)1 ApiConfig (com.google.api.server.spi.config.model.ApiConfig)1 SchemaRepository (com.google.api.server.spi.config.model.SchemaRepository)1 ApiConfigValidator (com.google.api.server.spi.config.validation.ApiConfigValidator)1 DiscoveryGenerator (com.google.api.server.spi.discovery.DiscoveryGenerator)1 EndpointsPrettyPrinter (com.google.api.server.spi.response.EndpointsPrettyPrinter)1 File (java.io.File)1 URLClassLoader (java.net.URLClassLoader)1