Search in sources :

Example 91 with ApiConfig

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

the class BaseSystemServiceTest method testGetApiConfigs.

@Test
public void testGetApiConfigs() throws Exception {
    final String apiConfig1 = "api1 configuration";
    final String apiConfig2 = "api2 configuration";
    ApiConfigLoader configLoader = Mockito.spy(new ApiConfigLoader());
    ApiConfigValidator configValidator = Mockito.mock(ApiConfigValidator.class);
    ApiConfigWriter configWriter = Mockito.mock(ApiConfigWriter.class);
    ApiConfig config1 = createGenericApiConfig();
    config1.setName("api1");
    config1.setVersion("v1");
    ApiConfig config2 = createGenericApiConfig();
    config2.setName("api2");
    config2.setVersion("v10");
    Mockito.doReturn(config1).doReturn(config2).when(configLoader).loadConfiguration(Mockito.<ServiceContext>any(), Mockito.<Class<?>>any());
    ImmutableMap<ApiKey, String> expected = ImmutableMap.of(new ApiKey("api1", "v1"), apiConfig1, new ApiKey("api2", "v2"), apiConfig2);
    Mockito.doReturn(expected).when(configWriter).writeConfig(setOf(config1, config2));
    SystemService systemService = new SystemService(configLoader, "app", configWriter, new Object[] { service, getTestService2() }, false);
    Map<ApiKey, String> configs = systemService.getApiConfigs();
    Mockito.verify(configWriter, times(1)).writeConfig(setOf(config1, config2));
    assertEquals(expected, configs);
}
Also used : ApiConfigLoader(com.google.api.server.spi.config.ApiConfigLoader) ApiKey(com.google.api.server.spi.config.model.ApiKey) ApiConfigValidator(com.google.api.server.spi.config.validation.ApiConfigValidator) ApiConfig(com.google.api.server.spi.config.model.ApiConfig) ApiConfigWriter(com.google.api.server.spi.config.ApiConfigWriter) 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