use of com.airbnb.spinaltap.common.source.SourceEvent in project SpinalTap by airbnb.
the class EventOrderValidatorTest method testReset.
@Test
public void testReset() throws Exception {
List<SourceEvent> unorderedEvents = Lists.newArrayList();
when(firstEvent.getOffset()).thenReturn(1L);
when(secondEvent.getOffset()).thenReturn(2L);
EventOrderValidator validator = new EventOrderValidator(unorderedEvents::add);
validator.validate(firstEvent);
validator.validate(secondEvent);
validator.reset();
validator.validate(firstEvent);
validator.validate(secondEvent);
assertTrue(unorderedEvents.isEmpty());
}
use of com.airbnb.spinaltap.common.source.SourceEvent in project SpinalTap by airbnb.
the class EventOrderValidatorTest method testEventInOrder.
@Test
public void testEventInOrder() throws Exception {
List<SourceEvent> unorderedEvents = Lists.newArrayList();
when(firstEvent.getOffset()).thenReturn(1L);
when(secondEvent.getOffset()).thenReturn(2L);
EventOrderValidator validator = new EventOrderValidator(unorderedEvents::add);
validator.validate(firstEvent);
validator.validate(secondEvent);
assertTrue(unorderedEvents.isEmpty());
}
use of com.airbnb.spinaltap.common.source.SourceEvent in project SpinalTap by airbnb.
the class EventOrderValidatorTest method testEventOutOfOrder.
@Test
public void testEventOutOfOrder() throws Exception {
List<SourceEvent> unorderedEvents = Lists.newArrayList();
when(firstEvent.getOffset()).thenReturn(2L);
when(secondEvent.getOffset()).thenReturn(1L);
EventOrderValidator validator = new EventOrderValidator(unorderedEvents::add);
validator.validate(firstEvent);
validator.validate(secondEvent);
assertEquals(Collections.singletonList(secondEvent), unorderedEvents);
}
Aggregations