use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyDeserializedEvent in project bender by Nextdoor.
the class PartitionOperationTest method testGetEvaluatedPartitionsNoSuchElementException.
@Test
public void testGetEvaluatedPartitionsNoSuchElementException() {
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);
DummyDeserializedEvent devent = spy(new DummyDeserializedEvent("baz"));
ievent.setEventObj(devent);
doThrow(new NoSuchElementException()).when(devent).getField(any());
op.perform(ievent);
LinkedHashMap<String, String> actual = ievent.getPartitions();
LinkedHashMap<String, String> expected = new LinkedHashMap<String, String>(1);
expected.put("foo", null);
assertEquals(expected, actual);
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyDeserializedEvent in project bender by Nextdoor.
the class PartitionOperationTest method testGetEvaluatedPartitionsStringMultipleFields.
@Test
public void testGetEvaluatedPartitionsStringMultipleFields() {
List<PartitionSpec> partitionSpecs = new ArrayList<PartitionSpec>(1);
List<String> sources = Arrays.asList("one", "two");
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(null).doReturn("5").when(devent).getField(any());
op.perform(ievent);
LinkedHashMap<String, String> actual = ievent.getPartitions();
LinkedHashMap<String, String> expected = new LinkedHashMap<String, String>(1);
expected.put("foo", "5");
assertEquals(expected, actual);
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyDeserializedEvent in project bender by Nextdoor.
the class PartitionOperationTest method testGetEvaluatedPartitionsStringMultipleFieldsNull.
@Test
public void testGetEvaluatedPartitionsStringMultipleFieldsNull() {
List<PartitionSpec> partitionSpecs = new ArrayList<PartitionSpec>(1);
List<String> sources = Arrays.asList("one", "two");
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("baz"));
ievent.setEventObj(devent);
doReturn(null).doReturn(null).when(devent).getField(any());
op.perform(ievent);
LinkedHashMap<String, String> actual = ievent.getPartitions();
LinkedHashMap<String, String> expected = new LinkedHashMap<String, String>(1);
expected.put("foo", null);
assertEquals(expected, actual);
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyDeserializedEvent in project bender by Nextdoor.
the class PartitionOperationTest method testOperationThroughProcessor.
@Test
public void testOperationThroughProcessor() {
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");
DummyOperationFactory opFact = new DummyOperationFactory(op);
OperationProcessor opProc = new OperationProcessor(opFact);
opProc.perform(Stream.of(ievent)).count();
LinkedHashMap<String, String> actual = ievent.getPartitions();
LinkedHashMap<String, String> expected = new LinkedHashMap<String, String>(1);
expected.put("foo", "baz");
assertEquals(expected, actual);
}
Aggregations