Search in sources :

Example 11 with DefinitionRegistry

use of org.talend.components.api.service.common.DefinitionRegistry in project components by Talend.

the class GoogleDriveTestBase method getDefinitionRegistry.

@Override
public DefinitionRegistryService getDefinitionRegistry() {
    if (definitionRegistry == null) {
        definitionRegistry = new DefinitionRegistry();
        definitionRegistry.registerComponentFamilyDefinition(new GoogleDriveFamilyDefinition());
    }
    return definitionRegistry;
}
Also used : DefinitionRegistry(org.talend.components.api.service.common.DefinitionRegistry)

Example 12 with DefinitionRegistry

use of org.talend.components.api.service.common.DefinitionRegistry in project components by Talend.

the class TestFixedConnectorComponentProperties method getComponentService.

// default implementation for pure java test. Shall be overriden of Spring or OSGI tests
public ComponentService getComponentService() {
    DefinitionRegistry testComponentRegistry = new DefinitionRegistry();
    SimpleComponentDefinition componentDef = new SimpleComponentDefinition("foo", ExecutionEngine.DI);
    componentDef.setPropertyClass(TestProperties.class);
    testComponentRegistry.registerDefinition(Arrays.asList(componentDef));
    return new ComponentServiceImpl(testComponentRegistry);
}
Also used : SimpleComponentDefinition(org.talend.components.api.test.SimpleComponentDefinition) ComponentServiceImpl(org.talend.components.api.service.common.ComponentServiceImpl) DefinitionRegistry(org.talend.components.api.service.common.DefinitionRegistry)

Example 13 with DefinitionRegistry

use of org.talend.components.api.service.common.DefinitionRegistry in project components by Talend.

the class FormatPropertiesProviderTest method testProperties.

@Test
public void testProperties() throws Throwable {
    FormatPropertiesProvider<AbstractTestFormatProperties> propertiesProvider = new FormatPropertiesProvider<AbstractTestFormatProperties>("propertiesProvider", AbstractTestFormatDefinition.class) {
    };
    DefinitionRegistry reg = new DefinitionRegistry();
    TestFormatDefinition1Impl def1 = new TestFormatDefinition1Impl();
    TestFormatDefinition2Impl def2 = new TestFormatDefinition2Impl();
    reg.registerDefinition(Arrays.asList(def1, def2));
    reg.injectDefinitionRegistry(propertiesProvider);
    propertiesProvider.init();
    // Check that possible format values include both of registered definitions
    Assert.assertEquals(propertiesProvider.format.getPossibleValues().size(), 2);
    // Set the format value to first registered definition
    propertiesProvider.format.setValue(def1.getName());
    PropertiesDynamicMethodHelper.afterProperty(propertiesProvider, propertiesProvider.format.getName());
    AbstractTestFormatProperties formatProperties = propertiesProvider.getFormatProperties();
    Assert.assertNotEquals(def2.getName(), propertiesProvider.format.getValue());
    Assert.assertEquals(def1.getName(), propertiesProvider.format.getValue());
    // Format properties class in PropertiesProvider should be the same as properties class for definition
    Assert.assertEquals(def1.getPropertiesClass(), formatProperties.getClass());
    propertiesProvider.format.setValue(def2.getName());
    PropertiesDynamicMethodHelper.afterProperty(propertiesProvider, propertiesProvider.format.getName());
    formatProperties = propertiesProvider.getFormatProperties();
    Assert.assertNotEquals(def1.getName(), propertiesProvider.format.getValue());
    Assert.assertEquals(def2.getName(), propertiesProvider.format.getValue());
    Assert.assertEquals(TestFormatProperties2Impl.class, formatProperties.getClass());
}
Also used : TestFormatDefinition2Impl(org.talend.components.common.format.instances.TestFormatDefinition2Impl) AbstractTestFormatProperties(org.talend.components.common.format.instances.AbstractTestFormatProperties) TestFormatDefinition1Impl(org.talend.components.common.format.instances.TestFormatDefinition1Impl) DefinitionRegistry(org.talend.components.api.service.common.DefinitionRegistry) Test(org.junit.Test)

Example 14 with DefinitionRegistry

use of org.talend.components.api.service.common.DefinitionRegistry in project components by Talend.

the class FullExamplePropertiesTest method getComponentService.

@Override
public ComponentService getComponentService() {
    if (simpleComponentService == null) {
        DefinitionRegistry componentRegistry = new DefinitionRegistry();
        componentRegistry.registerComponentFamilyDefinition(new FullExampleFamilyDefinition());
        simpleComponentService = new ComponentServiceImpl(componentRegistry);
    }
    return simpleComponentService;
}
Also used : ComponentServiceImpl(org.talend.components.api.service.common.ComponentServiceImpl) DefinitionRegistry(org.talend.components.api.service.common.DefinitionRegistry)

Example 15 with DefinitionRegistry

use of org.talend.components.api.service.common.DefinitionRegistry in project components by Talend.

the class ServiceSpiFactoryTest method testUpdateClassLoaderService.

@Test
public void testUpdateClassLoaderService() throws MalformedURLException {
    // this will check that create an update registry with the new url
    // given
    DefinitionRegistry definitionRegistry = ServiceSpiFactory.createDefinitionRegistry(new URL[] { new URL("mvn:org.talend.components/multiple-runtime-comp/0.18.0") });
    assertThat(definitionRegistry.getComponentFamilies(), hasKey(is("MultiRuntimeExample")));
    assertThat(definitionRegistry.getComponentFamilies(), not(hasKey(is("Jdbc"))));
    // when
    DefinitionRegistry definitionRegistry2 = ServiceSpiFactory.createUpdatedDefinitionRegistry(new URL[] { new URL("mvn:org.talend.components/components-jdbc-definition/0.18.0") });
    // then
    assertThat(definitionRegistry2.getComponentFamilies(), hasKey(is("MultiRuntimeExample")));
    assertThat(definitionRegistry2.getComponentFamilies(), hasKey(is("Jdbc")));
    // this will check that same registry is returned if no classpath is passed
    assertThat(definitionRegistry2, equalTo(ServiceSpiFactory.createDefinitionRegistry(null)));
    assertThat(definitionRegistry2, equalTo(ServiceSpiFactory.createDefinitionRegistry(new URL[0])));
}
Also used : DefinitionRegistry(org.talend.components.api.service.common.DefinitionRegistry) URL(java.net.URL) Test(org.junit.Test)

Aggregations

DefinitionRegistry (org.talend.components.api.service.common.DefinitionRegistry)27 ComponentServiceImpl (org.talend.components.api.service.common.ComponentServiceImpl)12 Test (org.junit.Test)5 URL (java.net.URL)3 ComponentInstaller (org.talend.components.api.ComponentInstaller)3 SalesforceFamilyDefinition (org.talend.components.salesforce.SalesforceFamilyDefinition)3 BeforeClass (org.junit.BeforeClass)2 TJiraInputDefinition (org.talend.components.jira.tjirainput.TJiraInputDefinition)2 SnowflakeFamilyDefinition (org.talend.components.snowflake.SnowflakeFamilyDefinition)2 ComponentFamilyDefinition (org.talend.components.api.ComponentFamilyDefinition)1 ComponentService (org.talend.components.api.service.ComponentService)1 SimpleComponentDefinition (org.talend.components.api.test.SimpleComponentDefinition)1 AbstractTestFormatProperties (org.talend.components.common.format.instances.AbstractTestFormatProperties)1 TestFormatDefinition1Impl (org.talend.components.common.format.instances.TestFormatDefinition1Impl)1 TestFormatDefinition2Impl (org.talend.components.common.format.instances.TestFormatDefinition2Impl)1 LocalIOComponentFamilyDefinition (org.talend.components.localio.LocalIOComponentFamilyDefinition)1 FixedFlowInputDefinition (org.talend.components.localio.fixedflowinput.FixedFlowInputDefinition)1 SimpleFileIOComponentFamilyDefinition (org.talend.components.simplefileio.SimpleFileIOComponentFamilyDefinition)1 SimpleFileIODatasetDefinition (org.talend.components.simplefileio.SimpleFileIODatasetDefinition)1 SimpleFileIODatastoreDefinition (org.talend.components.simplefileio.SimpleFileIODatastoreDefinition)1