Search in sources :

Example 11 with Connection

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

the class ChangeOutputConnectionOrderCommandTest method test.

@Test
public void test() {
    tSAPBapiComponent = ComponentsFactoryProvider.getInstance().get("tSAPBapi", ComponentCategory.CATEGORY_4_DI.getName());
    tLogRowComponent = ComponentsFactoryProvider.getInstance().get("tLogRow", 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 tSAPBapi_1 = new Node(tSAPBapiComponent, process);
    tSAPBapi_1.getMetadataList().add(createMetadataTable("row_IV_KOKRS_1"));
    tSAPBapi_1.getMetadataList().add(createMetadataTable("row_ES_RETURN_1"));
    tSAPBapi_1.getMetadataList().add(createMetadataTable("row_ET_COSTELEMGRP_HIER_1"));
    tSAPBapi_1.getMetadataList().add(createMetadataTable("row_SINGLE_PARAM_1"));
    Node tLogRow_1 = new Node(tLogRowComponent, process);
    Connection conn1 = new Connection(tSAPBapi_1, tLogRow_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tSAPBapi_1", "row_ES_RETURN_1", "row_ES_RETURN_1", false);
    Connection conn2 = new Connection(tSAPBapi_1, tLogRow_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tSAPBapi_1", "row_ET_COSTELEMGRP_HIER_1", "row_ET_COSTELEMGRP_HIER_1", false);
    Connection conn3 = new Connection(tSAPBapi_1, tLogRow_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tSAPBapi_1", "row_SINGLE_PARAM_1", "row_SINGLE_PARAM_1", false);
    List<IConnection> reoderConnection = new ArrayList<IConnection>();
    reoderConnection.add(conn2);
    reoderConnection.add(conn3);
    reoderConnection.add(conn1);
    ChangeOutputConnectionOrderCommand command = new ChangeOutputConnectionOrderCommand(tSAPBapi_1, reoderConnection);
    command.execute();
    Assert.assertEquals(conn1.getConnectionLabel().getLabelText(), "row_ES_RETURN_1 (Main order:3)");
    Assert.assertEquals(conn2.getConnectionLabel().getLabelText(), "row_ET_COSTELEMGRP_HIER_1 (Main order:1)");
    Assert.assertEquals(conn3.getConnectionLabel().getLabelText(), "row_SINGLE_PARAM_1 (Main order:2)");
    command.undo();
    Assert.assertEquals(conn1.getConnectionLabel().getLabelText(), "row_ES_RETURN_1 (Main order:1)");
    Assert.assertEquals(conn2.getConnectionLabel().getLabelText(), "row_ET_COSTELEMGRP_HIER_1 (Main order:2)");
    Assert.assertEquals(conn3.getConnectionLabel().getLabelText(), "row_SINGLE_PARAM_1 (Main order:3)");
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) Process(org.talend.designer.core.ui.editor.process.Process) IConnection(org.talend.core.model.process.IConnection) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 12 with Connection

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

the class ConnectionManagerTest method testCanConnectToSource.

/**
     * Test method for
     * {@link org.talend.designer.core.model.process.ConnectionManager#canConnectToSource(org.talend.designer.core.ui.editor.nodes.Node, org.talend.designer.core.ui.editor.nodes.Node, org.talend.designer.core.ui.editor.nodes.Node, org.talend.core.model.process.EConnectionType, java.lang.String, java.lang.String)}
     * .
     */
@Test
public void testCanConnectToSource() {
    try {
        connection = new Connection(source, target, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "test", "test", "test", false);
        // Check the circle, certainly, you can try to test with some other conditions.
        boolean canConnect = ConnectionManager.canConnectToSource(source, target, target, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "test");
        // The right result is can't be connected.
        assertTrue(!canConnect);
    } catch (Exception e) {
        e.printStackTrace();
        fail("Test CanConnectToSource() method failure.");
    }
}
Also used : Connection(org.talend.designer.core.ui.editor.connections.Connection) Test(org.junit.Test)

Example 13 with Connection

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

the class ConnectionManagerTest method testCanConnectToTargetWithLoop2.

/**
     * Test method for
     * {@link org.talend.designer.core.model.process.ConnectionManager#canConnectToTarget(org.talend.designer.core.ui.editor.nodes.Node, org.talend.designer.core.ui.editor.nodes.Node, org.talend.designer.core.ui.editor.nodes.Node, org.talend.core.model.process.EConnectionType, java.lang.String, java.lang.String)}
     * .
     */
@Test
public void testCanConnectToTargetWithLoop2() {
    try {
        IComponent component = ComponentsFactoryProvider.getInstance().get("tJava", ComponentCategory.CATEGORY_4_DI.getName());
        Node source2 = new Node(component, sourceProcess);
        Node middle2 = new Node(component, sourceProcess);
        Node target2 = new Node(component, sourceProcess);
        Connection connection3 = new Connection(source2, middle2, EConnectionType.ON_SUBJOB_OK, EConnectionType.ON_SUBJOB_OK.getName(), "test5", "test5", "test5", false);
        Connection connection4 = new Connection(middle2, target2, EConnectionType.ON_SUBJOB_ERROR, EConnectionType.ON_SUBJOB_ERROR.getName(), "test6", "test6", "test6", false);
        boolean canConnect = ConnectionManager.canConnectToTarget(target2, null, source2, EConnectionType.RUN_IF, EConnectionType.RUN_IF.getName(), "test_5_6");
        assertTrue(!canConnect);
    } catch (Exception e) {
        e.printStackTrace();
        fail("Test CanConnectToSource() method failure.");
    }
}
Also used : IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) Connection(org.talend.designer.core.ui.editor.connections.Connection) Test(org.junit.Test)

Example 14 with Connection

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

the class ConnectionManagerTest method testCanConnectToTargetWithLoop3.

/**
     * Test method for
     * {@link org.talend.designer.core.model.process.ConnectionManager#canConnectToTarget(org.talend.designer.core.ui.editor.nodes.Node, org.talend.designer.core.ui.editor.nodes.Node, org.talend.designer.core.ui.editor.nodes.Node, org.talend.core.model.process.EConnectionType, java.lang.String, java.lang.String)}
     * .
     */
@Test
public void testCanConnectToTargetWithLoop3() {
    try {
        IComponent component = ComponentsFactoryProvider.getInstance().get("tJava", ComponentCategory.CATEGORY_4_DI.getName());
        Node source2 = new Node(component, sourceProcess);
        Node middle2 = new Node(component, sourceProcess);
        Node target2 = new Node(component, sourceProcess);
        Connection connection3 = new Connection(middle2, source2, EConnectionType.ON_SUBJOB_OK, EConnectionType.ON_SUBJOB_OK.getName(), "test5", "test5", "test5", false);
        Connection connection4 = new Connection(middle2, target2, EConnectionType.ON_SUBJOB_ERROR, EConnectionType.ON_SUBJOB_ERROR.getName(), "test6", "test6", "test6", false);
        boolean canConnect = ConnectionManager.canConnectToTarget(target2, null, source2, EConnectionType.RUN_IF, EConnectionType.RUN_IF.getName(), "test_5_6");
        assertTrue(canConnect);
    } catch (Exception e) {
        e.printStackTrace();
        fail("Test CanConnectToSource() method failure.");
    }
}
Also used : IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) Connection(org.talend.designer.core.ui.editor.connections.Connection) Test(org.junit.Test)

Example 15 with Connection

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

the class UpdateELTMapComponentCommandTest method before.

@Before
public void before() {
    Process process = new Process(createProperty());
    sourceNode = new Node(sourceComponent, process);
    INodeConnector connector = new NodeConnector(sourceNode);
    connector.setName("connector");
    connector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    ArrayList<INodeConnector> connectors = new ArrayList<INodeConnector>();
    connectors.add(connector);
    sourceNode.setListConnector(connectors);
    targetNode = new Node(targetComponent, process);
    DbMapComponent component = new DbMapComponent();
    targetNode.setExternalNode(component);
    connection = new Connection(sourceNode, targetNode, EConnectionType.FLOW_MAIN, "connector", "meta", "oldTable", true);
    inputs = (List<ExternalDbMapTable>) targetNode.getExternalData().getInputTables();
    ExternalDbMapTable input = new ExternalDbMapTable();
    input.setName("oldTable");
    input.setTableName("oldTable");
    inputs.add(input);
    outputs = (List<ExternalDbMapTable>) targetNode.getExternalData().getOutputTables();
    ExternalDbMapTable output = new ExternalDbMapTable();
    ExternalDbMapEntry entry = new ExternalDbMapEntry("oldTable", "oldTable.column");
    output.setMetadataTableEntries(new ArrayList<ExternalDbMapEntry>());
    output.getMetadataTableEntries().add(entry);
    outputs.add(output);
}
Also used : DbMapComponent(org.talend.designer.dbmap.DbMapComponent) INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) ExternalDbMapTable(org.talend.designer.dbmap.external.data.ExternalDbMapTable) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) Process(org.talend.designer.core.ui.editor.process.Process) INodeConnector(org.talend.core.model.process.INodeConnector) ExternalDbMapEntry(org.talend.designer.dbmap.external.data.ExternalDbMapEntry) Before(org.junit.Before)

Aggregations

Connection (org.talend.designer.core.ui.editor.connections.Connection)84 IConnection (org.talend.core.model.process.IConnection)52 ArrayList (java.util.ArrayList)47 List (java.util.List)46 Node (org.talend.designer.core.ui.editor.nodes.Node)44 INode (org.talend.core.model.process.INode)35 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)28 Process (org.talend.designer.core.ui.editor.process.Process)24 IElementParameter (org.talend.core.model.process.IElementParameter)20 INodeConnector (org.talend.core.model.process.INodeConnector)18 HashMap (java.util.HashMap)12 IComponent (org.talend.core.model.components.IComponent)12 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)12 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)11 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)11 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)10 Property (org.talend.core.model.properties.Property)10 Test (org.junit.Test)9 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)9 Map (java.util.Map)8