use of org.talend.sdk.component.runtime.di.beam.LoopState in project component-runtime by Talend.
the class QueueOutputTest method execution.
@Test
void execution() {
final QueueOutput output = new QueueOutput("test", "test", "test", null);
output.setState(new JobStateAware.State());
output.onNext(name -> Branches.DEFAULT_BRANCH.equals(name) ? Json.createObjectBuilder().add("id", 1).build() : null, name -> value -> {
throw new UnsupportedOperationException();
});
final LoopState loopState = LoopState.lookup(output.getStateId());
loopState.end();
final JsonObject next = loopState.next();
assertNotNull(next);
assertEquals(1, next.getInt("id"));
assertNull(loopState.next());
}
use of org.talend.sdk.component.runtime.di.beam.LoopState in project component-runtime by Talend.
the class QueueMapperTest method execution.
@Test
void execution() {
final QueueMapper mapper = new QueueMapper("test", "test", "test", null);
try {
mapper.setState(new JobStateAware.State());
} catch (final NullPointerException npe) {
// not sexy but for the test it is ok
}
final Input input = mapper.create();
final LoopState lookup = LoopState.lookup(mapper.getStateId());
lookup.push(Json.createObjectBuilder().add("id", 1).build());
lookup.end();
assertEquals(1, JsonObject.class.cast(input.next()).getInt("id"));
assertNull(input.next());
}
Aggregations