Search in sources :

Example 11 with DummyStringEvent

use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent in project bender by Nextdoor.

the class TimeOperationTest method testValidISO8601Ms.

@Test
public void testValidISO8601Ms() throws FieldNotFoundException {
    InternalEvent ievent = new InternalEvent("foo", null, 1);
    DummyStringEvent devent = spy(new DummyStringEvent(""));
    ievent.setEventObj(devent);
    doReturn("2020-05-04T10:45:01.480Z").when(devent).getFieldAsString("foo");
    TimeOperation op = new TimeOperation("foo", TimeFieldType.ISO8601);
    op.perform(ievent);
    assertEquals(1588589101480l, ievent.getEventTime());
}
Also used : DummyStringEvent(com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent) InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test)

Example 12 with DummyStringEvent

use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent in project bender by Nextdoor.

the class TimeOperationTest method testInvalidTime.

@Test(expected = OperationException.class)
public void testInvalidTime() throws FieldNotFoundException {
    InternalEvent ievent = new InternalEvent("foo", null, 1);
    DummyStringEvent devent = spy(new DummyStringEvent(""));
    ievent.setEventObj(devent);
    doReturn("-1").when(devent).getFieldAsString("foo");
    TimeOperation op = new TimeOperation("foo", TimeFieldType.SECONDS);
    op.perform(ievent);
}
Also used : DummyStringEvent(com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent) InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test)

Example 13 with DummyStringEvent

use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent in project bender by Nextdoor.

the class TimeOperationTest method testValidISO8601Ds.

@Test
public void testValidISO8601Ds() throws FieldNotFoundException {
    InternalEvent ievent = new InternalEvent("foo", null, 1);
    DummyStringEvent devent = spy(new DummyStringEvent(""));
    ievent.setEventObj(devent);
    doReturn("2020-05-04T10:45:01Z").when(devent).getFieldAsString("foo");
    TimeOperation op = new TimeOperation("foo", TimeFieldType.ISO8601);
    op.perform(ievent);
    assertEquals(1588589101000l, ievent.getEventTime());
}
Also used : DummyStringEvent(com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent) InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test)

Example 14 with DummyStringEvent

use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent in project bender by Nextdoor.

the class ConditionalOperationTest method supply.

private void supply(int count, Queue<InternalEvent> input) {
    new Thread(new Runnable() {

        @Override
        public void run() {
            for (int i = 0; i < count; i++) {
                InternalEvent ievent = new InternalEvent("" + i, null, 1);
                ievent.setEventObj(new DummyStringEvent("" + i));
                input.add(ievent);
            }
            input.close();
        }
    }).start();
}
Also used : DummyStringEvent(com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent) InternalEvent(com.nextdoor.bender.InternalEvent)

Aggregations

InternalEvent (com.nextdoor.bender.InternalEvent)14 DummyStringEvent (com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent)14 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)6 LinkedHashMap (java.util.LinkedHashMap)4 FieldNotFoundException (com.nextdoor.bender.deserializer.FieldNotFoundException)2 OperationException (com.nextdoor.bender.operation.OperationException)2 OperationProcessor (com.nextdoor.bender.operation.OperationProcessor)1 DummyOperationFactory (com.nextdoor.bender.testutils.DummyOperationHelper.DummyOperationFactory)1