Search in sources :

Example 1 with LocalPartitionMapper

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());
    }
}
Also used : LocalPartitionMapper(org.talend.sdk.component.runtime.input.LocalPartitionMapper) ProcessorImpl(org.talend.sdk.component.runtime.output.ProcessorImpl) ComponentManager(org.talend.sdk.component.runtime.manager.ComponentManager) List(java.util.List) Arrays.asList(java.util.Arrays.asList) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

File (java.io.File)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 Test (org.junit.jupiter.api.Test)1 LocalPartitionMapper (org.talend.sdk.component.runtime.input.LocalPartitionMapper)1 ComponentManager (org.talend.sdk.component.runtime.manager.ComponentManager)1 ProcessorImpl (org.talend.sdk.component.runtime.output.ProcessorImpl)1