plunger icon indicating copy to clipboard operation
plunger copied to clipboard

Add a call stub and builder for exercising ValueAssertions

Open teabot opened this issue 10 years ago • 0 comments

Plunger has the FunctionCallStub, BufferCallStub, and AggregatorCallStub classes that can be used to concisely exercise Function, Buffer, and Aggregator operations with test data. These stubs handle the basic life cycle of the operations, also providing a store for any context that they might create.

However, the ValueAssertion operation type does not currently have such a stub (and associated builder class) available. This makes it harder to test ValueAssertion implementations than need be. A ValueAssertionCallStub should be provided to fill this void. It can likely be based on the existing stubs and possible extend AbstractOperationCallStub.

What differentiates this call stub from the others is that value on which we can make an assertion. Existing operations return Tuples, but the ValueAssertion either throws

An example usage might look like:

ValueAssertion assertion = new AssertDateValid();

stubCall = Plunger.newAssertionCallStubBuilder(FIELDS)
    .addTuple("2013-01-01")
    .addTuple("NOT_A_DATE")
    .build()
    .complete(mockFlowProcess, assertion);

List<AssertionException> result = stubCall.result();
assertThat(collected.get(0), is(nullValue());
assertThat(collected.get(1).getMessage(), is("argument 'TXN_DATE' value was not a valid date, in tuple: ['NOT_A_DATE']");

teabot avatar Jun 11 '15 09:06 teabot