use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class PostgresGenerationManagerTest method mockConnection.
private IConnection mockConnection(String schemaName, String tableName, String[] columns) {
Connection connection = mock(Connection.class);
Node node = mock(Node.class);
ElementParameter param = new ElementParameter(node);
param.setName("ELT_SCHEMA_NAME");
param.setValue(schemaName);
when(node.getElementParameter("ELT_SCHEMA_NAME")).thenReturn(param);
param = new ElementParameter(node);
param.setName("ELT_TABLE_NAME");
param.setValue(tableName);
when(node.getElementParameter("ELT_TABLE_NAME")).thenReturn(param);
when(connection.getName()).thenReturn(schemaName + "." + tableName);
when(connection.getSource()).thenReturn(node);
IMetadataTable table = new MetadataTable();
table.setLabel(tableName);
table.setTableName(tableName);
List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
for (String columnName : columns) {
IMetadataColumn column = new MetadataColumn();
column.setLabel(columnName);
column.setOriginalDbColumnName(columnName);
listColumns.add(column);
}
table.setListColumns(listColumns);
when(connection.getMetadataTable()).thenReturn(table);
return connection;
}
use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class DbGenerationManagerTest method createConnection.
private IConnection createConnection(String schemaName, String tableName, String label, String[] columns) {
Connection connection = mock(Connection.class);
when(connection.getName()).thenReturn(tableName);
IMetadataTable metadataTable = new MetadataTable();
metadataTable.setLabel(tableName);
metadataTable.setTableName(tableName);
List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
for (String columnName : columns) {
IMetadataColumn column = new MetadataColumn();
column.setLabel(label);
column.setOriginalDbColumnName(columnName);
listColumns.add(column);
}
metadataTable.setListColumns(listColumns);
when(connection.getMetadataTable()).thenReturn(metadataTable);
return connection;
}
use of org.talend.designer.core.ui.editor.connections.Connection 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;
}
use of org.talend.designer.core.ui.editor.connections.Connection 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");
}
use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class ConnectionManagerTest method testCanConnectToTargetWithLoop1.
/**
* 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 testCanConnectToTargetWithLoop1() {
try {
IComponent component = ComponentsFactoryProvider.getInstance().get("tJava", ComponentCategory.CATEGORY_4_DI.getName());
Node source1 = new Node(component, sourceProcess);
Node middle1 = new Node(component, sourceProcess);
Node target1 = new Node(component, sourceProcess);
Connection connection1 = new Connection(source1, middle1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "test3", "test3", "test3", false);
Connection connection2 = new Connection(middle1, target1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "test4", "test4", "test4", false);
boolean canConnect = ConnectionManager.canConnectToTarget(target1, null, source1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "test_3_4");
assertTrue(!canConnect);
} catch (Exception e) {
e.printStackTrace();
fail("Test CanConnectToSource() method failure.");
}
}
Aggregations