use of org.talend.sdk.component.runtime.manager.ComponentManager in project component-runtime by Talend.
the class DIBatchSimulationTest method toBeam.
@Test
void toBeam() {
final ComponentManager manager = ComponentManager.instance();
final Collection<Object> sourceData = new ArrayList<>();
final Collection<Object> processorData = new ArrayList<>();
To.RECORDS.clear();
doDi(manager, sourceData, processorData, manager.findProcessor("DIBatchSimulationTest", "to", 1, new HashMap<>()).map(p -> {
assertTrue(QueueOutput.class.isInstance(p), p.getClass().getName());
return p;
}), manager.findMapper("DIBatchSimulationTest", "passthroughinput", 1, singletonMap("count", "1000")));
assertEquals(1000, sourceData.size());
assertEquals(1000, processorData.size());
assertEquals(1000, To.RECORDS.size());
}
use of org.talend.sdk.component.runtime.manager.ComponentManager in project component-runtime by Talend.
the class DIBatchSimulationTest method fromBeam.
@Test
void fromBeam() {
final ComponentManager manager = ComponentManager.instance();
final Collection<Object> sourceData = new ArrayList<>();
final Collection<Object> processorData = new ArrayList<>();
doDi(manager, sourceData, processorData, manager.findProcessor("DIBatchSimulationTest", "passthroughoutput", 1, new HashMap<>()), manager.findMapper("DIBatchSimulationTest", "from", 1, singletonMap("count", "1000")).map(m -> {
assertTrue(QueueMapper.class.isInstance(m), m.getClass().getName());
return m;
}));
assertEquals(1000, sourceData.size());
assertEquals(1000, processorData.size());
}
use of org.talend.sdk.component.runtime.manager.ComponentManager in project component-runtime by Talend.
the class DIBatchSimulationTest method emptyToBeam.
@Test
void emptyToBeam() {
final ComponentManager manager = ComponentManager.instance();
final Collection<Object> sourceData = new ArrayList<>();
doDi(manager, sourceData, new ArrayList<>(), manager.findProcessor("DIBatchSimulationTest", "to", 1, new HashMap<>()).map(p -> {
assertTrue(QueueOutput.class.isInstance(p), p.getClass().getName());
return p;
}), manager.findMapper("DIBatchSimulationTest", "passthroughinput", 1, singletonMap("count", "0")));
assertEquals(0, sourceData.size());
}
use of org.talend.sdk.component.runtime.manager.ComponentManager in project component-runtime by Talend.
the class AutoKVWrapperTest method test.
@Test
public void test() {
final ComponentManager instance = ComponentManager.instance();
final JsonBuilderFactory factory = instance.getJsonpBuilderFactory();
PAssert.that(buildBaseJsonPipeline(pipeline, factory).setCoder(JsonpJsonObjectCoder.of(null)).apply(AutoKVWrapper.of(null, JobImpl.LocalSequenceHolder.cleanAndGet(getClass().getName() + ".test"), "", ""))).satisfies(values -> {
final List<KV<String, JsonObject>> items = StreamSupport.stream(values.spliterator(), false).sorted(comparing(k -> k.getValue().getJsonArray("b1").getJsonObject(0).getString("foo"))).collect(toList());
assertEquals(2, items.size());
// ensure we got 2 ids
assertEquals(2, new HashSet<>(items).size());
assertEquals(asList("a", "b"), items.stream().map(k -> k.getValue().getJsonArray("b1").getJsonObject(0).getString("foo")).collect(toList()));
return null;
});
assertEquals(PipelineResult.State.DONE, pipeline.run().waitUntilFinish());
}
use of org.talend.sdk.component.runtime.manager.ComponentManager in project component-runtime by Talend.
the class RepositoryModelBuilderTest method test.
@Test
void test(final TemporaryFolder temporaryFolder, final TestInfo testInfo) throws Exception {
final String pluginName = testInfo.getTestMethod().get().getName() + ".jar";
final File pluginJar = createChainPlugin(temporaryFolder.getRoot(), pluginName);
try (final ComponentManager manager = new ComponentManager(new File("target/fake-m2"), "TALEND-INF/dependencies.txt", null)) {
manager.addPlugin(pluginJar.getAbsolutePath());
Container pluginContainer = manager.findPlugin(pluginName).orElseThrow(() -> new Exception("test plugin don't exist"));
assertNotNull(pluginContainer);
RepositoryModel rm = pluginContainer.get(RepositoryModel.class);
assertNotNull(rm);
assertEquals(1, rm.getFamilies().size());
Family family = rm.getFamilies().get(0);
String ds1Id = IdGenerator.get("family1", "datastore", "dataStore1");
Config dataStore1Config = family.getConfigs().stream().filter(c -> c.getId().equals(ds1Id)).findFirst().get();
assertNotNull(dataStore1Config);
assertEquals(1, dataStore1Config.getChildConfigs().size());
assertEquals("configuration1", dataStore1Config.getChildConfigs().get(0).getMeta().getName());
String ds2Id = IdGenerator.get("family1", "datastore", "dataStore2");
Config dataStore2Config = family.getConfigs().stream().filter(c -> c.getId().equals(ds2Id)).findFirst().get();
assertNotNull(dataStore2Config);
assertEquals(1, dataStore2Config.getChildConfigs().size());
assertEquals("configuration2", dataStore2Config.getChildConfigs().get(0).getMeta().getName());
}
}
Aggregations