Search in sources :

Example 1 with TestProperties

use of org.talend.designer.core.utils.TestProperties in project tdi-studio-se by Talend.

the class ChangeMetadataCommandTest method testComponentSchemaPropagated.

/**
     * Test disabled since for now the propagation is done by the component itself.<br>
     * A new test need to be created with a custom component setting
     */
@Test
@Ignore
public void testComponentSchemaPropagated() {
    Node simpleInputNode = NodeTestCreator.createSimpleInputNode(process);
    //$NON-NLS-1$
    TestProperties inputProps = (TestProperties) new TestProperties("testInput").init();
    simpleInputNode.setComponentProperties(inputProps);
    simpleInputNode.getMetadataList().clear();
    IMetadataTable table = createSimpleMetadata(inputProps.schema);
    table.setTableName(simpleInputNode.getUniqueName());
    table.setLabel(simpleInputNode.getUniqueName());
    //$NON-NLS-1$
    table.setAttachedConnector("FLOW");
    simpleInputNode.getMetadataList().add(table);
    List<Object> args = new ArrayList<>();
    args.add(simpleInputNode.getUniqueName());
    //$NON-NLS-1$
    args.add("connectionName");
    // set null, the command should take the schema from the component directly
    args.add(null);
    //$NON-NLS-1$
    ConnectionCreateCommand ccc = new ConnectionCreateCommand(simpleInputNode, "FLOW", args);
    ConnectionCreateCommand.setCreatingConnection(true);
    IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceOutput", "DI");
    Node node = new Node(component, new Process(new FakePropertyImpl()));
    ccc.setTarget(node);
    ccc.execute();
    IElementParameter schemaParam = null;
    for (IElementParameter param : node.getElementParameters()) {
        if (EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType()) && param.getContext().equals("MAIN")) {
            schemaParam = param;
            break;
        }
    }
    assertNotNull(schemaParam);
    table = node.getMetadataList().get(0);
    String avroSchemaStr = inputProps.schema.schema.getStringValue();
    assertNotNull(avroSchemaStr);
    Schema avroSchema = new Schema.Parser().parse(avroSchemaStr);
    assertEquals(3, avroSchema.getFields().size());
    //$NON-NLS-1$
    assertNotNull(avroSchema.getField("C1"));
    //$NON-NLS-1$
    assertNotNull(avroSchema.getField("C2"));
    //$NON-NLS-1$
    assertNotNull(avroSchema.getField("C3"));
    assertEquals(avroSchema.getFields().toString(), ((Schema) schemaParam.getValue()).getFields().toString());
}
Also used : TestProperties(org.talend.designer.core.utils.TestProperties) 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) ArrayList(java.util.ArrayList) Process(org.talend.designer.core.ui.editor.process.Process) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with TestProperties

use of org.talend.designer.core.utils.TestProperties in project tdi-studio-se by Talend.

the class DataProcessTest method before.

@Before
public void before() {
    process = new Process(TestUtils.createDefaultProperty());
    dataProcess = new DataProcess(process);
    testNode = new Node(testComponent, process);
    //$NON-NLS-1$
    TestProperties testProps = (TestProperties) new TestProperties("test").init();
    testNode.setComponentProperties(testProps);
}
Also used : TestProperties(org.talend.designer.core.utils.TestProperties) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) Process(org.talend.designer.core.ui.editor.process.Process) Before(org.junit.Before)

Aggregations

Node (org.talend.designer.core.ui.editor.nodes.Node)2 Process (org.talend.designer.core.ui.editor.process.Process)2 TestProperties (org.talend.designer.core.utils.TestProperties)2 ArrayList (java.util.ArrayList)1 Schema (org.apache.avro.Schema)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 IComponent (org.talend.core.model.components.IComponent)1 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 INode (org.talend.core.model.process.INode)1 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)1