Search in sources :

Example 1 with ConfigurationContextResolver

use of com.hotels.styx.api.configuration.ConfigurationContextResolver in project styx by ExpediaGroup.

the class ConfigurationContextResolverInterceptorTest method resolvesConfigurationContext.

@Test
public void resolvesConfigurationContext() {
    LiveHttpRequest request = get("/").build();
    Configuration.Context context = context(Map.of("key1", "value1", "key2", "value2"));
    ConfigurationContextResolver configurationContextResolver = configurationContextResolver(request, context);
    ConfigurationContextResolverInterceptor interceptor = new ConfigurationContextResolverInterceptor(configurationContextResolver);
    TestChain chain = new TestChain();
    Eventual<LiveHttpResponse> responseObservable = interceptor.intercept(request, chain);
    assertThat(Mono.from(responseObservable).block(), hasStatus(OK));
    assertThat(chain.proceedWasCalled, is(true));
    assertThat(chain.context().get("config.context", Configuration.Context.class), is(context));
}
Also used : ConfigurationContextResolver(com.hotels.styx.api.configuration.ConfigurationContextResolver) Support.requestContext(com.hotels.styx.support.Support.requestContext) Configuration(com.hotels.styx.api.configuration.Configuration) LiveHttpRequest(com.hotels.styx.api.LiveHttpRequest) LiveHttpResponse(com.hotels.styx.api.LiveHttpResponse) Test(org.junit.jupiter.api.Test)

Example 2 with ConfigurationContextResolver

use of com.hotels.styx.api.configuration.ConfigurationContextResolver in project styx by ExpediaGroup.

the class ConfigurationContextResolverInterceptorTest method configurationContextResolver.

private ConfigurationContextResolver configurationContextResolver(LiveHttpRequest request, Configuration.Context context) {
    ConfigurationContextResolver configurationContextResolver = mock(ConfigurationContextResolver.class);
    when(configurationContextResolver.resolve(request)).thenReturn(context);
    return configurationContextResolver;
}
Also used : ConfigurationContextResolver(com.hotels.styx.api.configuration.ConfigurationContextResolver)

Aggregations

ConfigurationContextResolver (com.hotels.styx.api.configuration.ConfigurationContextResolver)2 LiveHttpRequest (com.hotels.styx.api.LiveHttpRequest)1 LiveHttpResponse (com.hotels.styx.api.LiveHttpResponse)1 Configuration (com.hotels.styx.api.configuration.Configuration)1 Support.requestContext (com.hotels.styx.support.Support.requestContext)1 Test (org.junit.jupiter.api.Test)1