Search in sources :

Example 66 with ApiConfig

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

the class ApiConfigValidatorTest method testApiMethodConfigWithApiMethodNameContainingStartingDot.

@Test
public void testApiMethodConfigWithApiMethodNameContainingStartingDot() throws Exception {
    @Api(name = "testApi", version = "v1", resource = "bar")
    final class Test {

        @ApiMethod(name = ".Api.TestMethod")
        public void test() {
        }
    }
    ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), Test.class);
    try {
        validator.validate(config);
        fail("Expected InvalidMethodNameException.");
    } catch (InvalidMethodNameException expected) {
    }
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Api(com.google.api.server.spi.config.Api) Test(org.junit.Test)

Example 67 with ApiConfig

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

the class ApiConfigValidatorTest method testNonuniqueRestSignatures_multiClass.

@Test
public void testNonuniqueRestSignatures_multiClass() throws Exception {
    @Api
    class Foo {

        @ApiMethod(path = "path")
        public void foo() {
        }
    }
    ApiConfig config1 = configLoader.loadConfiguration(ServiceContext.create(), Foo.class);
    @Api
    class Bar {

        @ApiMethod(path = "path")
        public void bar() {
        }
    }
    ApiConfig config2 = configLoader.loadConfiguration(ServiceContext.create(), Bar.class);
    try {
        validator.validate(Lists.newArrayList(config1, config2));
        fail();
    } catch (DuplicateRestPathException expected) {
    }
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Api(com.google.api.server.spi.config.Api) Test(org.junit.Test)

Example 68 with ApiConfig

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

the class DiscoveryGeneratorTest method testDirectoryIsCloneable.

@Test
public void testDirectoryIsCloneable() throws Exception {
    ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), FooEndpoint.class);
    DiscoveryGenerator.Result result = generator.writeDiscovery(ImmutableList.of(config), context);
    result.directory().clone();
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 69 with ApiConfig

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

the class ApiConfigValidatorTest method testNamespaceValidation_fullySpecified.

@Test
public void testNamespaceValidation_fullySpecified() throws Exception {
    ApiConfig validNamespaceFullySpecified = configFactory.copy(config);
    validNamespaceFullySpecified.getNamespaceConfig().setOwnerDomain("domain");
    validNamespaceFullySpecified.getNamespaceConfig().setOwnerName("name");
    validNamespaceFullySpecified.getNamespaceConfig().setPackagePath("package");
    validator.validate(validNamespaceFullySpecified);
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 70 with ApiConfig

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

the class SwaggerGeneratorTest method testWriteSwagger_FooEndpoint.

@Test
public void testWriteSwagger_FooEndpoint() throws Exception {
    ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), FooEndpoint.class);
    Swagger swagger = generator.writeSwagger(ImmutableList.of(config), false, context);
    Swagger expected = readExpectedAsSwagger("foo_endpoint.swagger");
    compareSwagger(expected, swagger);
}
Also used : Swagger(io.swagger.models.Swagger) 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