Search in sources :

Example 6 with DummyOperationFactory

use of com.nextdoor.bender.testutils.DummyOperationHelper.DummyOperationFactory 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);
}
Also used : DummyDeserializedEvent(com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyDeserializedEvent) ArrayList(java.util.ArrayList) DummyOperationFactory(com.nextdoor.bender.testutils.DummyOperationHelper.DummyOperationFactory) OperationProcessor(com.nextdoor.bender.operation.OperationProcessor) InternalEvent(com.nextdoor.bender.InternalEvent) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Aggregations

InternalEvent (com.nextdoor.bender.InternalEvent)6 DummyOperationFactory (com.nextdoor.bender.testutils.DummyOperationHelper.DummyOperationFactory)6 Test (org.junit.Test)6 DummyOperation (com.nextdoor.bender.testutils.DummyOperationHelper.DummyOperation)4 Stat (com.nextdoor.bender.monitoring.Stat)2 DummyDeserializerHelper (com.nextdoor.bender.testutils.DummyDeserializerHelper)2 OperationProcessor (com.nextdoor.bender.operation.OperationProcessor)1 DummyDeserializedEvent (com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyDeserializedEvent)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1