Search in sources :

Example 1 with BeamMapperImpl

use of org.talend.sdk.component.runtime.beam.impl.BeamMapperImpl in project component-runtime by Talend.

the class BeamIOWrappingTest method mapper.

@Test
public void mapper() {
    final Object source = newComponent("beamio_input", ComponentManager.ComponentType.MAPPER);
    assertThat(source, instanceOf(BeamSource.class));
    final Mapper mapper = new BeamMapperImpl((PTransform<PBegin, ?>) source, getPlugin(), "test", "beamio_input");
    mapper.start();
    assertEquals(2, mapper.assess());
    final Input input = mapper.create();
    assertNotNull(input);
    input.start();
    assertEquals(new Sample("a"), input.next());
    assertEquals(new Sample("b"), input.next());
    assertNull(input.next());
    input.stop();
    mapper.stop();
}
Also used : PartitionMapper(org.talend.sdk.component.api.input.PartitionMapper) Mapper(org.talend.sdk.component.runtime.input.Mapper) Input(org.talend.sdk.component.runtime.input.Input) BeamMapperImpl(org.talend.sdk.component.runtime.beam.impl.BeamMapperImpl) Sample(org.talend.sdk.component.runtime.beam.data.Sample) PBegin(org.apache.beam.sdk.values.PBegin) Test(org.junit.Test)

Example 2 with BeamMapperImpl

use of org.talend.sdk.component.runtime.beam.impl.BeamMapperImpl in project component-runtime by Talend.

the class BeamIOWrappingTest method inputChain.

@Test
public void inputChain() {
    MySink.DATA.clear();
    final Object source = newComponent("beamio_input_chain", ComponentManager.ComponentType.MAPPER);
    final Mapper mapper = new BeamMapperImpl((PTransform<PBegin, ?>) source, getPlugin(), "test", "beamio_input_chain");
    mapper.start();
    assertEquals(4, mapper.assess());
    final Input input = mapper.create();
    assertNotNull(input);
    input.start();
    assertNotNull(input.next());
    assertNotNull(input.next());
    assertNull(input.next());
    try {
        input.stop();
    } catch (final IllegalArgumentException iae) {
        // for now we ignore this error which is issuing an output in an after bundle
        assertEquals("chunk outputs are not yet supported", iae.getMessage());
    }
    mapper.stop();
    assertEquals(asList("setup", "start-bundle", "1a", "2b", "teardown"), MySink.DATA);
}
Also used : PartitionMapper(org.talend.sdk.component.api.input.PartitionMapper) Mapper(org.talend.sdk.component.runtime.input.Mapper) Input(org.talend.sdk.component.runtime.input.Input) BeamMapperImpl(org.talend.sdk.component.runtime.beam.impl.BeamMapperImpl) PBegin(org.apache.beam.sdk.values.PBegin) Test(org.junit.Test)

Aggregations

PBegin (org.apache.beam.sdk.values.PBegin)2 Test (org.junit.Test)2 PartitionMapper (org.talend.sdk.component.api.input.PartitionMapper)2 BeamMapperImpl (org.talend.sdk.component.runtime.beam.impl.BeamMapperImpl)2 Input (org.talend.sdk.component.runtime.input.Input)2 Mapper (org.talend.sdk.component.runtime.input.Mapper)2 Sample (org.talend.sdk.component.runtime.beam.data.Sample)1