use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class ChangeMetadataCommandTest method testComponentSchemaUpdated.
@Test
public void testComponentSchemaUpdated() {
IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceInput", "DI");
Node node = new Node(component, new Process(new FakePropertyImpl()));
IMetadataTable table = node.getMetadataList().get(0);
IMetadataColumn column = new MetadataColumn();
column.setLabel("C1");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
column = new MetadataColumn();
column.setLabel("C2");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
column = new MetadataColumn();
column.setLabel("C3");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
IMetadataTable newTable = table.clone(true);
newTable.getListColumns().remove(0);
IElementParameter schemaParam = null;
for (IElementParameter param : node.getElementParameters()) {
if (EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType())) {
schemaParam = param;
break;
}
}
assertNotNull(schemaParam);
ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand(node, schemaParam, null, null, null, table, newTable);
changeMetadataCommand.execute();
String avroSchemaStr = ((SchemaProperties) node.getComponentProperties().getProperties("module.main")).schema.getStringValue();
assertNotNull(avroSchemaStr);
Schema avroSchema = new Schema.Parser().parse(avroSchemaStr);
assertEquals(2, avroSchema.getFields().size());
//$NON-NLS-1$
assertNull(avroSchema.getField("C1"));
assertEquals(avroSchemaStr, schemaParam.getValue().toString());
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class TalendEditorPaletteFactoryTest method testGetRelatedComponents_partOfComponentName.
@Test
public void testGetRelatedComponents_partOfComponentName() {
storeRecentlyUsed();
IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
String keyword = "row";
List<IComponent> componentHits = TalendEditorPaletteFactory.getRelatedComponents(componentsFactory, keyword);
Assert.assertFalse("Can't find any components", componentHits.isEmpty());
assertExistedComponent(TJAVAROW, keyword, componentHits);
assertExistedComponent(TMYSQLROW, keyword, componentHits);
keyword = "Row";
componentHits = TalendEditorPaletteFactory.getRelatedComponents(componentsFactory, keyword);
Assert.assertFalse("Can't find any components", componentHits.isEmpty());
assertExistedComponent(TJAVAROW, keyword, componentHits);
assertExistedComponent(TMYSQLROW, keyword, componentHits);
}
use of org.talend.core.model.components.IComponent 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.core.model.components.IComponent 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.core.model.components.IComponent in project tdi-studio-se by Talend.
the class TalendEditorPaletteFactoryTest method testGetRelatedComponents_help.
@Test
public void testGetRelatedComponents_help() {
storeRecentlyUsed();
IComponentsFactory componentsFactory = ComponentsFactoryProvider.getInstance();
String keyword = "enter code";
List<IComponent> componentHits = TalendEditorPaletteFactory.getRelatedComponents(componentsFactory, keyword);
Assert.assertFalse("Can't find any components", componentHits.isEmpty());
assertExistedComponent(TJAVA, keyword, componentHits);
keyword = "enter";
componentHits = TalendEditorPaletteFactory.getRelatedComponents(componentsFactory, keyword);
Assert.assertFalse("Can't find any components", componentHits.isEmpty());
assertExistedComponent(TJAVA, keyword, componentHits);
assertExistedComponent(TJAVAROW, keyword, componentHits);
}
Aggregations