Search in sources :

Example 1 with ComponentDefinition

use of org.talend.components.api.component.ComponentDefinition in project tdi-studio-se by Talend.

the class Component method createMultipleComponentManagers.

@Override
protected List<IMultipleComponentManager> createMultipleComponentManagers() {
    List<IMultipleComponentManager> multipleComponentManagers = new ArrayList<>();
    if (componentDefinition instanceof VirtualComponentDefinition) {
        VirtualComponentDefinition definition = (VirtualComponentDefinition) componentDefinition;
        String inputComponentName = null;
        String outputComponentName = null;
        ComponentDefinition inputComponentDefinition = definition.getInputComponentDefinition();
        if (inputComponentDefinition != null) {
            inputComponentName = inputComponentDefinition.getName();
        }
        ComponentDefinition outputComponentDefinition = definition.getOutputComponentDefinition();
        if (outputComponentDefinition != null) {
            outputComponentName = outputComponentDefinition.getName();
        }
        if (inputComponentName == null || outputComponentName == null) {
            return multipleComponentManagers;
        }
        IMultipleComponentManager multipleComponentManager = new MultipleComponentManager(inputComponentName, outputComponentName);
        IMultipleComponentItem inputItem = multipleComponentManager.addItem(inputComponentName, inputComponentName);
        multipleComponentManager.setExistsLinkTo(true);
        // FIXME: should get the connector type by other way.
        String cType = EConnectionType.ON_ROWS_END.getName();
        inputItem.getOutputConnections().add(new MultipleComponentConnection(cType, outputComponentName));
        multipleComponentManager.addItem(outputComponentName, outputComponentName);
        multipleComponentManager.validateItems();
        multipleComponentManagers.add(multipleComponentManager);
    }
    return multipleComponentManagers;
}
Also used : VirtualComponentDefinition(org.talend.components.api.component.VirtualComponentDefinition) MultipleComponentManager(org.talend.designer.core.model.components.MultipleComponentManager) IMultipleComponentManager(org.talend.core.model.components.IMultipleComponentManager) IMultipleComponentItem(org.talend.core.model.components.IMultipleComponentItem) MultipleComponentConnection(org.talend.designer.core.model.components.MultipleComponentConnection) ArrayList(java.util.ArrayList) IMultipleComponentManager(org.talend.core.model.components.IMultipleComponentManager) VirtualComponentDefinition(org.talend.components.api.component.VirtualComponentDefinition) ComponentDefinition(org.talend.components.api.component.ComponentDefinition)

Example 2 with ComponentDefinition

use of org.talend.components.api.component.ComponentDefinition in project tdi-studio-se by Talend.

the class ComponentsUtilsTest method testLoadComponents.

@Test
public void testLoadComponents() {
    ComponentService componentService = ComponentsUtils.getComponentService();
    Set<ComponentDefinition> componentDefinitions = componentService.getAllComponents();
    Set<IComponent> coms = ComponentsFactoryProvider.getInstance().getComponents();
    List<IComponent> comList = new ArrayList<IComponent>();
    for (ComponentDefinition componentDefinition : componentDefinitions) {
        for (IComponent com : coms) {
            if (com.getName().equals(componentDefinition.getName())) {
                comList.add(com);
                break;
            }
        }
    }
    coms.removeAll(comList);
    ComponentsUtils.loadComponents(componentService);
    coms = ComponentsFactoryProvider.getInstance().getComponents();
    for (ComponentDefinition componentDefinition : componentDefinitions) {
        if (!componentDefinition.getName().equals("tJIRAInput")) {
            continue;
        }
        for (IComponent com : coms) {
            if (com.getName().equals(componentDefinition.getName())) {
                assertFalse("Component loaded: " + componentDefinition.getName(), true);
            }
        }
    }
}
Also used : IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) ComponentService(org.talend.components.api.service.ComponentService) ComponentDefinition(org.talend.components.api.component.ComponentDefinition) Test(org.junit.Test)

Example 3 with ComponentDefinition

use of org.talend.components.api.component.ComponentDefinition in project components by Talend.

the class TSalesforceOutputBulkExecDefinitionTest method testComponents.

@Test
public void testComponents() {
    ComponentDefinition inputDefinition = definition.getInputComponentDefinition();
    assertNotNull(inputDefinition);
    assertTrue(inputDefinition.getSupportedConnectorTopologies().contains(ConnectorTopology.INCOMING));
    ComponentDefinition outputDefinition = definition.getOutputComponentDefinition();
    assertNotNull(outputDefinition);
    assertTrue(outputDefinition.getSupportedConnectorTopologies().contains(ConnectorTopology.OUTGOING));
}
Also used : ComponentDefinition(org.talend.components.api.component.ComponentDefinition) AbstractComponentDefinition(org.talend.components.api.component.AbstractComponentDefinition) Test(org.junit.Test)

Example 4 with ComponentDefinition

use of org.talend.components.api.component.ComponentDefinition in project components by Talend.

the class SalesforceComponentTestIT method generateJavaNestedCompPropClassNames.

@Test
public void generateJavaNestedCompPropClassNames() {
    Set<ComponentDefinition> allComponents = getComponentService().getAllComponents();
    for (ComponentDefinition cd : allComponents) {
        ComponentProperties props = cd.createProperties();
        String javaCode = PropertiesTestUtils.generatedNestedComponentCompatibilitiesJavaCode(props);
        LOGGER.debug("Nested Props for (" + cd.getClass().getSimpleName() + ".java:1)" + javaCode);
    }
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) ComponentDefinition(org.talend.components.api.component.ComponentDefinition) Test(org.junit.Test)

Example 5 with ComponentDefinition

use of org.talend.components.api.component.ComponentDefinition in project components by Talend.

the class SalesforceComponentTestIT method testUseExistingConnection.

@Test
public void testUseExistingConnection() throws Throwable {
    SalesforceConnectionProperties connProps = (SalesforceConnectionProperties) getComponentService().getComponentProperties(TSalesforceConnectionDefinition.COMPONENT_NAME);
    setupProps(connProps, !ADD_QUOTES);
    final String currentComponentName = TSalesforceConnectionDefinition.COMPONENT_NAME + "_1";
    RuntimeContainer connContainer = new DefaultComponentRuntimeContainerImpl() {

        @Override
        public String getCurrentComponentId() {
            return currentComponentName;
        }
    };
    SalesforceSourceOrSink salesforceSourceOrSink = new SalesforceSourceOrSink();
    salesforceSourceOrSink.initialize(connContainer, connProps);
    assertEquals(ValidationResult.Result.OK, salesforceSourceOrSink.validate(connContainer).getStatus());
    // Input component get connection from the tSalesforceConnection
    ComponentDefinition inputDefinition = getComponentService().getComponentDefinition(TSalesforceInputDefinition.COMPONENT_NAME);
    TSalesforceInputProperties inProps = (TSalesforceInputProperties) getComponentService().getComponentProperties(TSalesforceInputDefinition.COMPONENT_NAME);
    inProps.connection.referencedComponent.componentInstanceId.setValue(currentComponentName);
    SalesforceSourceOrSink salesforceInputSourceOrSink = new SalesforceSourceOrSink();
    salesforceInputSourceOrSink.initialize(connContainer, inProps);
    assertEquals(ValidationResult.Result.OK, salesforceInputSourceOrSink.validate(connContainer).getStatus());
}
Also used : SalesforceConnectionProperties(org.talend.components.salesforce.SalesforceConnectionProperties) SalesforceSourceOrSink(org.talend.components.salesforce.runtime.SalesforceSourceOrSink) DefaultComponentRuntimeContainerImpl(org.talend.components.api.container.DefaultComponentRuntimeContainerImpl) TSalesforceInputProperties(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) ComponentDefinition(org.talend.components.api.component.ComponentDefinition) Test(org.junit.Test)

Aggregations

ComponentDefinition (org.talend.components.api.component.ComponentDefinition)47 Test (org.junit.Test)28 IndexedRecord (org.apache.avro.generic.IndexedRecord)16 TSalesforceOutputProperties (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties)14 TSalesforceOutputDefinition (org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputDefinition)12 ArrayList (java.util.ArrayList)11 Result (org.talend.components.api.component.runtime.Result)11 TSalesforceInputProperties (org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)10 List (java.util.List)9 DefaultComponentRuntimeContainerImpl (org.talend.components.api.container.DefaultComponentRuntimeContainerImpl)8 ComponentProperties (org.talend.components.api.properties.ComponentProperties)7 Schema (org.apache.avro.Schema)6 DefinitionDTO (org.talend.components.service.rest.dto.DefinitionDTO)6 MockComponentDefinition (org.talend.components.service.rest.mock.MockComponentDefinition)6 Response (com.jayway.restassured.response.Response)5 Arrays.asList (java.util.Arrays.asList)5 GenericData (org.apache.avro.generic.GenericData)3 ExecutionEngine (org.talend.components.api.component.runtime.ExecutionEngine)3 IComponent (org.talend.core.model.components.IComponent)3 File (java.io.File)2