@Test(expected = IllegalArgumentException.class) public void collectIrregularTupleEntry() { stub = new FunctionCallStub.Builder<String>(FIELDS).build(); assertThat(stub.result().asTupleEntryList().isEmpty(), is(true)); stub.getOutputCollector().add(new TupleEntry(new Fields("X", String.class), new Tuple(1))); }
@Test public void collectTuple() { stub = new FunctionCallStub.Builder<String>(FIELDS).build(); assertThat(stub.result().asTupleEntryList().isEmpty(), is(true)); stub.getOutputCollector().add(new Tuple(1)); assertThat(stub.result().asTupleEntryList().size(), is(1)); assertThat(stub.result().asTupleEntryList().get(0), is(new TupleEntry(FIELDS, new Tuple(1)))); }
@Test public void context() { stub = new FunctionCallStub.Builder<String>(FIELDS).addTuple(1).addTuple(2).build(); assertThat(stub.getContext(), is(nullValue())); stub.setContext("VALUE"); assertThat(stub.getContext(), is("VALUE")); stub.nextOperateCall(); assertThat(stub.getContext(), is("VALUE")); }
@Test public void next() { stub = new FunctionCallStub.Builder<String>(FIELDS).addTuple(1).addTuple(2).build(); assertThat(stub.getArguments(), is(nullValue())); stub.nextOperateCall(); assertThat(stub.getArguments(), is(new TupleEntry(FIELDS, new Tuple(1)))); stub.nextOperateCall(); assertThat(stub.getArguments(), is(new TupleEntry(FIELDS, new Tuple(2)))); }
@Test public void argumentsFieldsIgnoreOutputFields() { stub = new FunctionCallStub.Builder<String>(FIELDS).outputFields(OUTPUT).build(); assertThat(stub.getArgumentFields(), is(FIELDS)); assertThat(stub.getDeclaredFields(), is(OUTPUT)); }
@Test public void fields() { stub = new FunctionCallStub.Builder<String>(FIELDS).build(); assertThat(stub.getArgumentFields(), is(FIELDS)); assertThat(stub.getDeclaredFields(), is(FIELDS)); }