use of com.google.api.server.spi.config.ApiConfigWriter 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);
}
Aggregations