use of org.talend.sdk.component.design.extension.RepositoryModel 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());
}
}
use of org.talend.sdk.component.design.extension.RepositoryModel in project component-runtime by Talend.
the class RepositoryModelBuilderTest method notRootConfig.
@Test
void notRootConfig() {
final RepositoryModel model = new RepositoryModelBuilder().create(new ComponentManager.AllServices(emptyMap()), singleton(new ComponentFamilyMeta("test", emptyList(), "noicon", "test", "test") {
{
final ParameterMeta store = new ParameterMeta(null, DataStore1.class, ParameterMeta.Type.OBJECT, "config.store", "store", new String[0], emptyList(), emptyList(), new HashMap<String, String>() {
{
put("tcomp::configurationtype::type", "datastore");
put("tcomp::configurationtype::name", "testDatastore");
}
});
final ParameterMeta wrapper = new ParameterMeta(null, WrappingStore.class, ParameterMeta.Type.OBJECT, "config", "config", new String[0], singletonList(store), emptyList(), emptyMap());
getPartitionMappers().put("test", new PartitionMapperMeta(this, "mapper", "noicon", 1, PartitionMapper1.class, singletonList(wrapper), m -> null, (a, b) -> null, true) {
});
}
}), new MigrationHandlerFactory(new ReflectionService(new ParameterModelService())));
final List<Config> configs = model.getFamilies().stream().flatMap(f -> f.getConfigs().stream()).collect(toList());
assertEquals(1, configs.size());
}
Aggregations