use of org.talend.sdk.component.runtime.output.ProcessorImpl 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());
}
}
use of org.talend.sdk.component.runtime.output.ProcessorImpl in project component-runtime by Talend.
the class AdvancedProcessorImplTest method subclassing.
@Test
void subclassing() {
final Processor processor = new ProcessorImpl("Root", "Test", "Plugin", new SampleOutput());
final AtomicReference<Object> ref = new AtomicReference<>();
// just to enforce the init
processor.beforeGroup();
processor.onNext(name -> new Whatever(1), name -> value -> assertTrue(ref.compareAndSet(null, value)));
final Object out = ref.get();
assertNotNull(out);
assertTrue(() -> String.class.isInstance(out));
assertEquals("1", out.toString());
}
use of org.talend.sdk.component.runtime.output.ProcessorImpl in project component-runtime by Talend.
the class AdvancedProcessorImplTest method serialization.
@Test
void serialization() throws IOException, ClassNotFoundException {
final Processor processor = new ProcessorImpl("Root", "Test", "Plugin", new SampleOutput());
final Processor copy = Serializer.roundTrip(processor);
assertNotSame(copy, processor);
assertEquals("Root", copy.rootName());
assertEquals("Test", copy.name());
assertEquals("Plugin", copy.plugin());
}
Aggregations