Search in sources :

Example 1 with SourceEvent

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());
}
Also used : EventOrderValidator(com.airbnb.spinaltap.mysql.validator.EventOrderValidator) SourceEvent(com.airbnb.spinaltap.common.source.SourceEvent) Test(org.junit.Test)

Example 2 with SourceEvent

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());
}
Also used : EventOrderValidator(com.airbnb.spinaltap.mysql.validator.EventOrderValidator) SourceEvent(com.airbnb.spinaltap.common.source.SourceEvent) Test(org.junit.Test)

Example 3 with SourceEvent

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);
}
Also used : EventOrderValidator(com.airbnb.spinaltap.mysql.validator.EventOrderValidator) SourceEvent(com.airbnb.spinaltap.common.source.SourceEvent) Test(org.junit.Test)

Aggregations

SourceEvent (com.airbnb.spinaltap.common.source.SourceEvent)3 EventOrderValidator (com.airbnb.spinaltap.mysql.validator.EventOrderValidator)3 Test (org.junit.Test)3