use of com.amazonaws.xray.strategy.sampling.reservoir.CentralizedReservoir in project aws-xray-sdk-java by aws.
the class CentralizedRuleTest method testReservoirReset.
@Test
public void testReservoirReset() {
Mockito.when(clock.instant()).thenReturn(Instant.ofEpochSecond(1500000000));
SamplingRule input = createInput("r1", 300, 10, 0.0);
CentralizedRule rule = new CentralizedRule(input, new RandImpl());
SamplingTargetDocument target = createTarget(2, 0.0, 1500000010);
rule.update(target, clock.instant());
rule.sample(clock.instant());
CentralizedReservoir reservoir = Whitebox.getInternalState(rule, "centralizedReservoir", CentralizedRule.class);
Assert.assertEquals(1, reservoir.getUsed());
Mockito.when(clock.instant()).thenReturn(Instant.ofEpochSecond(1500000001));
rule.sample(clock.instant());
// Assert to ensure reservoir was reset before being updated
Assert.assertEquals(1, reservoir.getUsed());
}
Aggregations