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)");
}
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.");
}
}
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.");
}
}
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.");
}
}
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);
}
Aggregations