use of org.talend.sdk.component.runtime.input.LocalPartitionMapper in project component-runtime by Talend.
the class JobTest method validateJobLifeCycle.
@Test
void validateJobLifeCycle(final TestInfo info, final TemporaryFolder temporaryFolder) {
final String testName = info.getTestMethod().get().getName();
final String plugin = testName + ".jar";
final File jar = pluginGenerator.createChainPlugin(temporaryFolder.getRoot(), plugin);
try (final ComponentManager manager = new ComponentManager(new File("target/fake-m2"), "TALEND-INF/dependencies.txt", null) {
{
CONTEXTUAL_INSTANCE.set(this);
addPlugin(jar.getAbsolutePath());
}
@Override
public void close() {
super.close();
CONTEXTUAL_INSTANCE.set(null);
}
}) {
Job.components().component("countdown", "lifecycle://countdown?__version=1&start=2").component("square", "lifecycle://square?__version=1").connections().from("countdown").to("square").build().run();
final LocalPartitionMapper mapper = LocalPartitionMapper.class.cast(manager.findMapper("lifecycle", "countdown", 1, emptyMap()).get());
assertEquals(asList("start", "produce(1)", "produce(0)", "produce(null)", "stop"), ((Supplier<List<String>>) mapper.getDelegate()).get());
final ProcessorImpl processor = (ProcessorImpl) manager.findProcessor("lifecycle", "square", 1, emptyMap()).get();
assertEquals(asList("start", "beforeGroup", "onNext(1)", "afterGroup", "beforeGroup", "onNext(0)", "afterGroup", "stop"), ((Supplier<List<String>>) processor.getDelegate()).get());
}
}
Aggregations