Search in sources :

Example 81 with Process

use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.

the class RepositoryUpdateTest method testRepositoryUpdate.

@SuppressWarnings("unchecked")
@Test
public void testRepositoryUpdate() throws PersistenceException {
    //$NON-NLS-1$
    String id = "testId";
    try {
        //$NON-NLS-1$ //$NON-NLS-2$
        IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceInput", "DI");
        Process process = new Process(new FakePropertyImpl());
        Node node = new Node(component, process);
        ((List<INode>) process.getGraphicalNodes()).add(node);
        GenericConnectionItem connectionItem = createBasicConnection(id);
        setupPropertiesWithoutProxy(id);
        prepareTableForTest(id);
        // get updatedItem
        IRepositoryViewObject object = ProxyRepositoryFactory.getInstance().getLastVersion(id);
        connectionItem = (GenericConnectionItem) object.getProperty().getItem();
        Assert.assertEquals(1, SchemaUtils.getMetadataTables(connectionItem.getConnection(), SubContainer.class).size());
        updateNode(id, node, (GenericConnection) connectionItem.getConnection());
        setupPropertiesWithProxy(id);
        prepareTableForTest(id);
        launchRepositoryUpdateOnNode(id, process, node);
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.userPassword.userId", "\"myUser\"");
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.userPassword.password", "\"myPassword\"");
        //$NON-NLS-1$
        testRepositoryValue(node, "connection.proxy.useProxy", Boolean.TRUE);
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.proxy.host", "\"host\"");
        //$NON-NLS-1$
        testRepositoryValue(node, "connection.proxy.port", 1234);
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.proxy.userPassword.userId", "\"proxyUser\"");
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.proxy.userPassword.password", "\"proxyPassword\"");
        setupPropertiesWithoutProxy(id);
        prepareTableForTest(id);
        launchRepositoryUpdateOnNode(id, process, node);
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.userPassword.userId", "\"myUser\"");
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.userPassword.password", "\"myPassword\"");
        //$NON-NLS-1$
        testRepositoryValue(node, "connection.proxy.useProxy", Boolean.FALSE);
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.proxy.host", "\"\"");
        //$NON-NLS-1$
        testRepositoryValue(node, "connection.proxy.port", null);
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.proxy.userPassword.userId", "\"\"");
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.proxy.userPassword.password", "\"\"");
        setupPropertiesWithProxyEmptyVars(id);
        prepareTableForTest(id);
        launchRepositoryUpdateOnNode(id, process, node);
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.userPassword.userId", "\"myUser\"");
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.userPassword.password", "\"myPassword\"");
        //$NON-NLS-1$
        testRepositoryValue(node, "connection.proxy.useProxy", Boolean.TRUE);
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.proxy.host", "\"\"");
        //$NON-NLS-1$
        testRepositoryValue(node, "connection.proxy.port", null);
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.proxy.userPassword.userId", "\"\"");
        //$NON-NLS-1$  //$NON-NLS-2$
        testRepositoryValue(node, "connection.proxy.userPassword.password", "\"\"");
    } finally {
        IRepositoryViewObject object = ProxyRepositoryFactory.getInstance().getLastVersion(id);
        if (object != null) {
            ProxyRepositoryFactory.getInstance().deleteObjectPhysical(object);
        }
    }
}
Also used : FakePropertyImpl(org.talend.core.model.repository.FakePropertyImpl) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Process(org.talend.designer.core.ui.editor.process.Process) List(java.util.List) ArrayList(java.util.ArrayList) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem) Test(org.junit.Test)

Example 82 with Process

use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.

the class MapperHelperTest method test.

@Test
public void test() {
    Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    //$NON-NLS-1$
    property1.setId("property1");
    //$NON-NLS-1$
    property1.setVersion("0.1");
    //$NON-NLS-1$
    property1.setLabel("test1");
    Process process = new Process(property1);
    IComponent sparkComponent = ComponentsFactoryProvider.getInstance().get("tMap", ComponentCategory.CATEGORY_4_SPARK.getName());
    Node sparkTMap = new Node(sparkComponent, process);
    assertFalse("Spark tMap should not be a virtual component", MapperHelper.isGeneratedAsVirtualComponent(sparkTMap));
    IComponent sparkStreamingComponent = ComponentsFactoryProvider.getInstance().get("tMap", ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName());
    Node sparkStreamingTMap = new Node(sparkStreamingComponent, process);
    assertFalse("Spark Streaming tMap should not be a virtual component", MapperHelper.isGeneratedAsVirtualComponent(sparkStreamingTMap));
    IComponent mapReduceComponent = ComponentsFactoryProvider.getInstance().get("tMap", ComponentCategory.CATEGORY_4_MAPREDUCE.getName());
    Node mapReduceTMap = new Node(mapReduceComponent, process);
    assertFalse("Spark Streaming tMap should not be a virtual component", MapperHelper.isGeneratedAsVirtualComponent(mapReduceTMap));
}
Also used : IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) Process(org.talend.designer.core.ui.editor.process.Process) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 83 with Process

use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.

the class ProblemsAnalyserTest method createMapperComponent.

private MapperComponent createMapperComponent() {
    IComponent tMysqlComponent = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    IComponent tMapComponent = ComponentsFactoryProvider.getInstance().get("tMap", ComponentCategory.CATEGORY_4_DI.getName());
    Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    //$NON-NLS-1$
    property1.setId("property1");
    //$NON-NLS-1$
    property1.setVersion("0.1");
    //$NON-NLS-1$
    property1.setLabel("test1");
    Process process = new Process(property1);
    Node tMysqlInput_1 = new Node(tMysqlComponent, process);
    IMetadataTable tMysqlInput_1_table = tMysqlInput_1.getMetadataTable("tMysqlInput_1");
    createMetadataColumns(tMysqlInput_1_table, 2);
    Node tMysqlInput_2 = new Node(tMysqlComponent, process);
    IMetadataTable tMysqlInput_2_table = tMysqlInput_2.getMetadataTable("tMysqlInput_2");
    createMetadataColumns(tMysqlInput_2_table, 2);
    Node tMap_1 = new Node(tMapComponent, process);
    Connection row1 = new Connection(tMysqlInput_1, tMap_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tMysqlInput_1", "row1", "row1", false);
    Connection row2 = new Connection(tMysqlInput_2, tMap_1, EConnectionType.FLOW_REF, EConnectionType.FLOW_MAIN.getName(), "tMysqlInput_1", "row2", "row2", false);
    tMap_1.getExternalNode().initialize();
    MapperComponent mapperComponent = (MapperComponent) tMap_1.getExternalNode();
    ExternalMapperData externalData = (ExternalMapperData) mapperComponent.getExternalData();
    ExternalMapperTable externalTable = prepareExternalData(tMysqlInput_1_table);
    externalTable.setName(row1.getName());
    externalData.getInputTables().add(externalTable);
    externalTable = prepareExternalData(tMysqlInput_2_table);
    externalTable.setName(row2.getName());
    externalData.getInputTables().add(externalTable);
    return mapperComponent;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) IConnection(org.talend.core.model.process.IConnection) IOConnection(org.talend.designer.mapper.external.connection.IOConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) Process(org.talend.designer.core.ui.editor.process.Process) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData) Property(org.talend.core.model.properties.Property) MapperComponent(org.talend.designer.mapper.MapperComponent)

Example 84 with Process

use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.

the class ChangeConnTextCommandTest method testChangeConnectionLabel.

@Test
public void testChangeConnectionLabel() {
    Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    //$NON-NLS-1$
    property1.setId("property1");
    //$NON-NLS-1$
    property1.setVersion("0.1");
    //$NON-NLS-1$
    property1.setLabel("test1");
    Process process = new Process(property1);
    IComponent tMysqlComponent = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    IComponent tRunjobComponent = ComponentsFactoryProvider.getInstance().get("tRunJob", ComponentCategory.CATEGORY_4_DI.getName());
    Node tMysqlInput_1 = new Node(tMysqlComponent, process);
    Node tRunJob_1 = new Node(tRunjobComponent, process);
    List contextList = new ArrayList();
    Map<String, String> map = new HashMap<String, String>();
    map.put("PARAM_NAME_COLUMN", "new1");
    map.put("PARAM_VALUE_COLUMN", "log4j.newColumn");
    contextList.add(map);
    tRunJob_1.getElementParameter("CONTEXTPARAMS").setValue(contextList);
    Connection connection = new Connection(tMysqlInput_1, tRunJob_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tMysqlInput_1", "log4j", "log4j", false);
    ChangeConnTextCommand command = new ChangeConnTextCommand(connection, "validLabel");
    command.execute();
    Assert.assertEquals(connection.getName(), "validLabel");
    Assert.assertEquals(map.get("PARAM_VALUE_COLUMN"), "validLabel.newColumn");
    command.undo();
    Assert.assertEquals(connection.getName(), "log4j");
    Assert.assertEquals(map.get("PARAM_VALUE_COLUMN"), "log4j.newColumn");
}
Also used : HashMap(java.util.HashMap) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) Connection(org.talend.designer.core.ui.editor.connections.Connection) Process(org.talend.designer.core.ui.editor.process.Process) ArrayList(java.util.ArrayList) List(java.util.List) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 85 with Process

use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.

the class ChangeMetadataCommandTest method testComponentSchemaPropagated.

/**
     * Test disabled since for now the propagation is done by the component itself.<br>
     * A new test need to be created with a custom component setting
     */
@Test
@Ignore
public void testComponentSchemaPropagated() {
    Node simpleInputNode = NodeTestCreator.createSimpleInputNode(process);
    //$NON-NLS-1$
    TestProperties inputProps = (TestProperties) new TestProperties("testInput").init();
    simpleInputNode.setComponentProperties(inputProps);
    simpleInputNode.getMetadataList().clear();
    IMetadataTable table = createSimpleMetadata(inputProps.schema);
    table.setTableName(simpleInputNode.getUniqueName());
    table.setLabel(simpleInputNode.getUniqueName());
    //$NON-NLS-1$
    table.setAttachedConnector("FLOW");
    simpleInputNode.getMetadataList().add(table);
    List<Object> args = new ArrayList<>();
    args.add(simpleInputNode.getUniqueName());
    //$NON-NLS-1$
    args.add("connectionName");
    // set null, the command should take the schema from the component directly
    args.add(null);
    //$NON-NLS-1$
    ConnectionCreateCommand ccc = new ConnectionCreateCommand(simpleInputNode, "FLOW", args);
    ConnectionCreateCommand.setCreatingConnection(true);
    IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceOutput", "DI");
    Node node = new Node(component, new Process(new FakePropertyImpl()));
    ccc.setTarget(node);
    ccc.execute();
    IElementParameter schemaParam = null;
    for (IElementParameter param : node.getElementParameters()) {
        if (EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType()) && param.getContext().equals("MAIN")) {
            schemaParam = param;
            break;
        }
    }
    assertNotNull(schemaParam);
    table = node.getMetadataList().get(0);
    String avroSchemaStr = inputProps.schema.schema.getStringValue();
    assertNotNull(avroSchemaStr);
    Schema avroSchema = new Schema.Parser().parse(avroSchemaStr);
    assertEquals(3, avroSchema.getFields().size());
    //$NON-NLS-1$
    assertNotNull(avroSchema.getField("C1"));
    //$NON-NLS-1$
    assertNotNull(avroSchema.getField("C2"));
    //$NON-NLS-1$
    assertNotNull(avroSchema.getField("C3"));
    assertEquals(avroSchema.getFields().toString(), ((Schema) schemaParam.getValue()).getFields().toString());
}
Also used : TestProperties(org.talend.designer.core.utils.TestProperties) FakePropertyImpl(org.talend.core.model.repository.FakePropertyImpl) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) Schema(org.apache.avro.Schema) ArrayList(java.util.ArrayList) Process(org.talend.designer.core.ui.editor.process.Process) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Process (org.talend.designer.core.ui.editor.process.Process)119 Node (org.talend.designer.core.ui.editor.nodes.Node)69 INode (org.talend.core.model.process.INode)48 ArrayList (java.util.ArrayList)45 IComponent (org.talend.core.model.components.IComponent)36 IElementParameter (org.talend.core.model.process.IElementParameter)28 Test (org.junit.Test)26 List (java.util.List)25 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)25 IProcess (org.talend.core.model.process.IProcess)24 Connection (org.talend.designer.core.ui.editor.connections.Connection)24 Property (org.talend.core.model.properties.Property)23 INodeConnector (org.talend.core.model.process.INodeConnector)22 IConnection (org.talend.core.model.process.IConnection)20 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)20 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)15 ProcessItem (org.talend.core.model.properties.ProcessItem)12 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)11 HashMap (java.util.HashMap)10 Before (org.junit.Before)9