use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent in project bender by Nextdoor.
the class ForkOperationTest 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();
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent in project bender by Nextdoor.
the class PartitionOperationTest method testGetEvaluatedPartitionsString.
@Test
public void testGetEvaluatedPartitionsString() throws FieldNotFoundException {
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);
DummyStringEvent devent = spy(new DummyStringEvent(""));
ievent.setEventObj(devent);
doReturn("baz").when(devent).getFieldAsString("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);
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent in project bender by Nextdoor.
the class PartitionOperationTest method testGetEvaluatedPartitionsStatic.
@Test
public void testGetEvaluatedPartitionsStatic() {
List<PartitionSpec> partitionSpecs = new ArrayList<PartitionSpec>(1);
PartitionSpec spec = new PartitionSpec("foo", Collections.emptyList(), PartitionSpec.Interpreter.STATIC, "123", 0);
partitionSpecs.add(spec);
PartitionOperation op = new PartitionOperation(partitionSpecs);
InternalEvent ievent = new InternalEvent("foo", null, 1);
DummyStringEvent devent = new DummyStringEvent("");
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);
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent in project bender by Nextdoor.
the class PartitionOperationTest method testGetEvaluatedPartitionsFieldNotFoundException.
@Test(expected = OperationException.class)
public void testGetEvaluatedPartitionsFieldNotFoundException() throws FieldNotFoundException {
List<PartitionSpec> partitionSpecs = new ArrayList<PartitionSpec>(1);
List<String> sources = Arrays.asList("one");
PartitionSpec spec = new PartitionSpec("foo", sources, PartitionSpec.Interpreter.STRING);
partitionSpecs.add(spec);
PartitionOperation op = new PartitionOperation(partitionSpecs);
InternalEvent ievent = new InternalEvent("foo", null, 1);
DummyStringEvent devent = spy(new DummyStringEvent("baz"));
ievent.setEventObj(devent);
doThrow(FieldNotFoundException.class).when(devent).getFieldAsString(any());
try {
op.perform(ievent);
} catch (OperationException e) {
assertEquals("unable to find value for partition 'foo'", e.getMessage());
throw e;
}
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyStringEvent in project bender by Nextdoor.
the class TimeOperationTest method testNullField.
@Test(expected = OperationException.class)
public void testNullField() throws FieldNotFoundException {
InternalEvent ievent = new InternalEvent("foo", null, 1);
DummyStringEvent devent = spy(new DummyStringEvent(""));
ievent.setEventObj(devent);
doThrow(FieldNotFoundException.class).when(devent).getFieldAsString("foo");
TimeOperation op = new TimeOperation("foo", TimeFieldType.SECONDS);
op.perform(ievent);
}
Aggregations