Search in sources :

Example 51 with IComponent

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());
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) FakePropertyImpl(org.talend.core.model.repository.FakePropertyImpl) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) Schema(org.apache.avro.Schema) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Test(org.junit.Test)

Example 52 with IComponent

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);
}
Also used : IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) Test(org.junit.Test)

Example 53 with IComponent

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.");
    }
}
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 54 with IComponent

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.");
    }
}
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 55 with IComponent

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);
}
Also used : IComponentsFactory(org.talend.core.model.components.IComponentsFactory) IComponent(org.talend.core.model.components.IComponent) Test(org.junit.Test)

Aggregations

IComponent (org.talend.core.model.components.IComponent)146 Node (org.talend.designer.core.ui.editor.nodes.Node)54 ArrayList (java.util.ArrayList)47 IElementParameter (org.talend.core.model.process.IElementParameter)36 Process (org.talend.designer.core.ui.editor.process.Process)36 Test (org.junit.Test)35 INode (org.talend.core.model.process.INode)33 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)22 List (java.util.List)15 Property (org.talend.core.model.properties.Property)15 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)15 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)13 IComponentsFactory (org.talend.core.model.components.IComponentsFactory)12 Connection (org.talend.designer.core.ui.editor.connections.Connection)12 HashMap (java.util.HashMap)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)10 DataNode (org.talend.designer.core.model.process.DataNode)10 HashSet (java.util.HashSet)9 IConnection (org.talend.core.model.process.IConnection)9 Rectangle (org.eclipse.swt.graphics.Rectangle)8