Search in sources :

Example 1 with DummyDeserializedEvent

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

the class PartitionOperationTest method testGetEvaluatedPartitionsStatic.

@Test
public void testGetEvaluatedPartitionsStatic() {
    List<PartitionSpec> partitionSpecs = new ArrayList<PartitionSpec>(1);
    List<String> sources = Arrays.asList("foo");
    PartitionSpec spec = new PartitionSpec("foo", sources, PartitionSpec.Interpreter.STATIC, "123", 0);
    partitionSpecs.add(spec);
    PartitionOperation op = new PartitionOperation(partitionSpecs);
    InternalEvent ievent = new InternalEvent("foo", null, 1);
    DummyDeserializedEvent devent = new DummyDeserializedEvent("");
    ievent.setEventObj(devent);
    op.perform(ievent);
    LinkedHashMap<String, String> actual = ievent.getPartitions();
    LinkedHashMap<String, String> expected = new LinkedHashMap<String, String>(1);
    expected.put("foo", "123");
    assertEquals(expected, actual);
}
Also used : DummyDeserializedEvent(com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyDeserializedEvent) ArrayList(java.util.ArrayList) InternalEvent(com.nextdoor.bender.InternalEvent) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 2 with DummyDeserializedEvent

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

the class PartitionOperationTest method testGetEvaluatedPartitionsString.

@Test
public void testGetEvaluatedPartitionsString() {
    List<PartitionSpec> partitionSpecs = new ArrayList<PartitionSpec>(1);
    List<String> sources = Arrays.asList("foo");
    PartitionSpec spec = new PartitionSpec("foo", sources, PartitionSpec.Interpreter.STRING);
    partitionSpecs.add(spec);
    PartitionOperation op = new PartitionOperation(partitionSpecs);
    InternalEvent ievent = new InternalEvent("foo", null, 1);
    DummyDeserializedEvent devent = spy(new DummyDeserializedEvent(""));
    ievent.setEventObj(devent);
    doReturn("baz").when(devent).getField("foo");
    op.perform(ievent);
    LinkedHashMap<String, String> actual = ievent.getPartitions();
    LinkedHashMap<String, String> expected = new LinkedHashMap<String, String>(1);
    expected.put("foo", "baz");
    assertEquals(expected, actual);
}
Also used : DummyDeserializedEvent(com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyDeserializedEvent) ArrayList(java.util.ArrayList) InternalEvent(com.nextdoor.bender.InternalEvent) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 3 with DummyDeserializedEvent

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

the class TimeOperationTest method testValidTime.

@Test
public void testValidTime() {
    InternalEvent ievent = new InternalEvent("foo", null, 1);
    DummyDeserializedEvent devent = spy(new DummyDeserializedEvent(""));
    ievent.setEventObj(devent);
    doReturn("1504728473").when(devent).getField("foo");
    TimeOperation op = new TimeOperation("foo", TimeFieldType.SECONDS);
    op.perform(ievent);
    assertEquals(1504728473000l, ievent.getEventTime());
}
Also used : DummyDeserializedEvent(com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyDeserializedEvent) InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test)

Example 4 with DummyDeserializedEvent

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

the class TimeOperationTest method testNullField.

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

Example 5 with DummyDeserializedEvent

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

the class TimeOperationTest method testInvalidTime.

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

Aggregations

InternalEvent (com.nextdoor.bender.InternalEvent)9 DummyDeserializedEvent (com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyDeserializedEvent)9 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)6 LinkedHashMap (java.util.LinkedHashMap)6 OperationProcessor (com.nextdoor.bender.operation.OperationProcessor)1 DummyOperationFactory (com.nextdoor.bender.testutils.DummyOperationHelper.DummyOperationFactory)1 NoSuchElementException (java.util.NoSuchElementException)1