Search in sources :

Example 6 with ApiConfigValidator

use of com.google.api.server.spi.config.validation.ApiConfigValidator 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

ApiConfigValidator (com.google.api.server.spi.config.validation.ApiConfigValidator)6 TypeLoader (com.google.api.server.spi.TypeLoader)5 ApiConfig (com.google.api.server.spi.config.model.ApiConfig)5 ApiKey (com.google.api.server.spi.config.model.ApiKey)4 SchemaRepository (com.google.api.server.spi.config.model.SchemaRepository)3 Test (org.junit.Test)3 Api (com.google.api.server.spi.config.Api)2 ApiConfigLoader (com.google.api.server.spi.config.ApiConfigLoader)2 File (java.io.File)2 URLClassLoader (java.net.URLClassLoader)2 Map (java.util.Map)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 ServiceContext (com.google.api.server.spi.ServiceContext)1 ApiConfigWriter (com.google.api.server.spi.config.ApiConfigWriter)1 ApiConfigAnnotationReader (com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader)1 JsonConfigWriter (com.google.api.server.spi.config.jsonwriter.JsonConfigWriter)1 DiscoveryGenerator (com.google.api.server.spi.discovery.DiscoveryGenerator)1 DiscoveryContext (com.google.api.server.spi.discovery.DiscoveryGenerator.DiscoveryContext)1 EndpointsPrettyPrinter (com.google.api.server.spi.response.EndpointsPrettyPrinter)1 RestDescription (com.google.api.services.discovery.model.RestDescription)1