Search in sources :

Example 61 with ApiConfig

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

the class ApiConfigValidatorTest method testNamespaceValidation_emptyDomain.

@Test
public void testNamespaceValidation_emptyDomain() throws Exception {
    ApiConfig badNamespaceEmptyDomain = configFactory.copy(config);
    badNamespaceEmptyDomain.getNamespaceConfig().setOwnerDomain("");
    badNamespaceEmptyDomain.getNamespaceConfig().setOwnerName("name");
    try {
        validator.validate(badNamespaceEmptyDomain);
        fail("Expected InvalidNamespaceException.");
    } catch (InvalidNamespaceException expected) {
    }
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 62 with ApiConfig

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

the class ApiConfigValidatorTest method testInconsistentApiWideConfig.

@Test
public void testInconsistentApiWideConfig() throws Exception {
    @Api(name = "testApi", version = "v1", resource = "foo")
    final class Test1 {
    }
    ApiConfig config1 = configLoader.loadConfiguration(ServiceContext.create(), Test1.class);
    @Api(name = "testApi", version = "v1", resource = "bar")
    final class Test2 {
    }
    ApiConfig config2 = configLoader.loadConfiguration(ServiceContext.create(), Test2.class);
    try {
        validator.validate(Lists.newArrayList(config1, config2));
        fail("Expected InconsistentApiConfigurationException.");
    } catch (InconsistentApiConfigurationException 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 63 with ApiConfig

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

the class ApiConfigValidatorTest method testApiMethodConfigWithApiMethodNameContainingEndingDot.

@Test
public void testApiMethodConfigWithApiMethodNameContainingEndingDot() 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 64 with ApiConfig

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

the class ApiConfigValidatorTest method testNamespaceValidation_emptyName.

@Test
public void testNamespaceValidation_emptyName() throws Exception {
    ApiConfig badNamespaceEmptyName = configFactory.copy(config);
    badNamespaceEmptyName.getNamespaceConfig().setOwnerDomain("domain");
    badNamespaceEmptyName.getNamespaceConfig().setOwnerName("");
    try {
        validator.validate(badNamespaceEmptyName);
        fail("Expected InvalidNamespaceException.");
    } catch (InvalidNamespaceException expected) {
    }
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Test(org.junit.Test)

Example 65 with ApiConfig

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

the class ApiConfigValidatorTest method testDifferentApisWithSameApiWideConfig.

@Test
public void testDifferentApisWithSameApiWideConfig() throws Exception {
    @Api(name = "testApi", version = "v1", resource = "foo")
    final class Test1 {
    }
    ApiConfig config1 = configLoader.loadConfiguration(ServiceContext.create(), Test1.class);
    @Api(name = "testApi", version = "v1", resource = "foo")
    @ApiClass(resource = "bar")
    final class Test2 {
    }
    ApiConfig config2 = configLoader.loadConfiguration(ServiceContext.create(), Test2.class);
    validator.validate(Lists.newArrayList(config1, config2));
}
Also used : ApiConfig(com.google.api.server.spi.config.model.ApiConfig) Api(com.google.api.server.spi.config.Api) ApiClass(com.google.api.server.spi.config.ApiClass) 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