use of com.hotels.styx.api.Environment in project styx by ExpediaGroup.
the class ServiceProvision method servicesMap.
private static <U> Map<String, U> servicesMap(JsonNode jsonNode, Environment environment, Class<? extends U> serviceClass) {
JsonNode factories = jsonNode.get("factories");
JsonNodeConfig jsonNodeConfig = new JsonNodeConfig(factories);
return iteratorToList(factories.fieldNames()).stream().flatMap(name -> {
if (isType(name, jsonNodeConfig, SpiExtension.class)) {
return namedExtensionFromSpiExtension(environment, serviceClass, jsonNodeConfig, name);
} else if (isType(name, jsonNodeConfig, ServiceFactoryConfig.class)) {
return namedExtensionFromServiceFactoryConfig(environment, serviceClass, jsonNodeConfig, name);
} else {
String content = factories.get(name).toString();
String message = format("Unexpected configuration object 'services.factories.%s', Configuration='%s'", name, content);
throw new ConfigurationException(message);
}
}).collect(toMap(Pair::key, Pair::value));
}
use of com.hotels.styx.api.Environment in project styx by ExpediaGroup.
the class ServiceProvisionTest method ignoresDisabledServices.
@Test
public void ignoresDisabledServices() {
Environment env = environmentWithConfig(mixedDisabledServices);
Map<String, StyxService> services = loadServices(env.configuration(), env, "multi", StyxService.class);
assertThat(services.isEmpty(), is(true));
}
use of com.hotels.styx.api.Environment in project styx by ExpediaGroup.
the class ServiceProvisionTest method loadsFromMixedConfigFormat.
@Test
public void loadsFromMixedConfigFormat() {
Environment env = environmentWithConfig(yamlForMixedServiceFactories);
Map<String, StyxService> services = loadServices(env.configuration(), env, "multi", StyxService.class);
assertThat(services.get("backendProvider"), instanceOf(BackendServiceProvider.class));
assertThat(services.get("routingProvider"), instanceOf(RoutingObjectProvider.class));
}
Aggregations