use of org.talend.designer.core.ui.editor.connections.Connection in project tdi-studio-se by Talend.
the class ConnectionManagerTest method testCanRename.
/**
* Test method for
* {@link org.talend.designer.core.model.process.ConnectionManager#canRename(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)}
* .
*/
@Test
public void testCanRename() {
try {
connection = new Connection(source, target, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "test", "test", "test", false);
boolean canRename = ConnectionManager.canRename(source, target, EConnectionType.FLOW_MAIN, "test1");
assertTrue(canRename);
canRename = ConnectionManager.canRename(source, target, EConnectionType.FLOW_MAIN, "test");
assertTrue(canRename);
} 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 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;
}
Aggregations