use of com.hotels.styx.api.extension.retrypolicy.spi.RetryPolicy in project styx by ExpediaGroup.
the class StyxBackendServiceClientTest method mockRetryPolicy.
private RetryPolicy mockRetryPolicy(Boolean first, Boolean... outcomes) {
RetryPolicy retryPolicy = mock(RetryPolicy.class);
RetryPolicy.Outcome retryOutcome = mock(RetryPolicy.Outcome.class);
when(retryOutcome.shouldRetry()).thenReturn(first, outcomes);
RetryPolicy.Outcome[] retryOutcomes = stream(outcomes).map(outcome -> retryOutcome).toArray(RetryPolicy.Outcome[]::new);
when(retryPolicy.evaluate(any(RetryPolicy.Context.class), any(LoadBalancer.class), any(LoadBalancer.Preferences.class))).thenReturn(retryOutcome).thenReturn(retryOutcome, retryOutcomes);
return retryPolicy;
}
use of com.hotels.styx.api.extension.retrypolicy.spi.RetryPolicy in project styx by ExpediaGroup.
the class RetryPolicyFactoryTest method shouldCreateRetryPolicyAccordingToConfiguration.
@Test
public void shouldCreateRetryPolicyAccordingToConfiguration() {
Configuration configuration = new MapBackedConfiguration().set("count", 2);
RetryPolicy retryPolicy = new RetryPolicyFactory().create(environment, configuration);
assertThat(retryPolicy, is(instanceOf(RetryNTimes.class)));
assertThat(((RetryNTimes) retryPolicy).maxAttempts(), is(2));
}
Aggregations