PartitionOperation implements EventOperation { @Override public InternalEvent perform(InternalEvent ievent) { ievent.setPartitions(getPartitions(ievent.getEventObj())); return ievent; } PartitionOperation(final List<PartitionSpec> partitionSpecs); @Override InternalEvent perform(InternalEvent ievent);  }
@Test(expected = OperationException.class) public void testGetEvaluatedPartitionsStringMultipleFieldsNull() throws FieldNotFoundException { 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); DummyStringEvent devent = spy(new DummyStringEvent("baz")); ievent.setEventObj(devent); doThrow(FieldNotFoundException.class).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; } }
@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; } }