Search in sources :

Example 51 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class ExpressionTest method testEvaluateDistrib_invalidcase.

@Test
public void testEvaluateDistrib_invalidcase() {
    List<IElementParameter> params = new ArrayList<>();
    ElementParameter param1 = createMockParameter("PARA1", true, null);
    params.add(param1);
    ElementParameter distrib = createMockParameter("DISTRIB", "CUSTOM");
    params.add(distrib);
    ElementParameter version = createMockParameter("VERSION", "testVersion");
    params.add(version);
    ElementParameter invaliddistrib = createMockParameter("INVALDDISTRIB", "INVALID");
    params.add(invaliddistrib);
    // Invalid distrib and version
    assertFalse(Expression.evaluateDistrib("DISTRIB[NOPE, NOPE].doSupportUseDatanodeHostname[]", params, param1));
    assertFalse(Expression.evaluateDistrib("!DISTRIB[NOPE, NOPE].doSupportUseDatanodeHostname[]", params, param1));
    assertFalse(Expression.evaluateDistrib("DISTRIB[NOPE, VERSION].doSupportUseDatanodeHostname[]", params, param1));
    assertFalse(Expression.evaluateDistrib("!DISTRIB[NOPE, VERSION].doSupportUseDatanodeHostname[]", params, param1));
    assertFalse(Expression.evaluateDistrib("DISTRIB[INVALDDISTRIB, VERSION].doSupportUseDatanodeHostname[]", params, param1));
    assertFalse(Expression.evaluateDistrib("!DISTRIB[INVALDDISTRIB, VERSION].doSupportUseDatanodeHostname[]", params, param1));
    // invalid link
    assertFalse(Expression.evaluateDistrib("DISTRIB[DISTRIB, #LINK@NODE.CONNECTION.HIVE_VERSION]].doSupportUseDatanodeHostname[]", params, param1));
    assertFalse(Expression.evaluateDistrib("DISTRIB[#LINK@NODE.CONNECTION.DISTRIBUTION, VERSION]].doSupportUseDatanodeHostname[]", params, param1));
    assertFalse(Expression.evaluateDistrib("!DISTRIB[DISTRIB, #LINK@NODE.CONNECTION.HIVE_VERSION]].doSupportUseDatanodeHostname[]", params, param1));
    assertFalse(Expression.evaluateDistrib("!DISTRIB[#LINK@NODE.CONNECTION.DISTRIBUTION, VERSION]].doSupportUseDatanodeHostname[]", params, param1));
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) TextElementParameter(org.talend.core.model.runprocess.shadow.TextElementParameter) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) Test(org.junit.Test)

Example 52 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class ComponentListControllerTest method testrenameComponentUniqueName.

@Test
public void testrenameComponentUniqueName() {
    //---first
    String oldConnectionName = "joblet3_1";
    String newConnectionName = "joblet1_1_joblet2_1_joblet3_1";
    List<Node> nodesToUpdate = new ArrayList<Node>();
    IComponent component = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
    property.setVersion(VersionUtils.DEFAULT_VERSION);
    Process process = new Process(property);
    Node node = new Node(component, process);
    nodesToUpdate.add(node);
    IElementParameter param = node.getElementParameter("CONNECTION");
    param.setValue("joblet3_1_joblet4_1_joblet5_1_tMysqlConnection_1");
    ComponentListController.renameComponentUniqueName(oldConnectionName, newConnectionName, nodesToUpdate);
    assertTrue(param.getValue().equals("joblet1_1_joblet2_1_joblet3_1_joblet4_1_joblet5_1_tMysqlConnection_1"));
    //---second
    oldConnectionName = "tMysqlConnection_1";
    newConnectionName = "joblet1_1_joblet2_1_tMysqlConnection_1";
    param.setValue("tMysqlConnection_1_joblet4_1_joblet5_1_tMysqlConnection_1");
    ComponentListController.renameComponentUniqueName(oldConnectionName, newConnectionName, nodesToUpdate);
    assertTrue(param.getValue().equals("joblet1_1_joblet2_1_tMysqlConnection_1_joblet4_1_joblet5_1_tMysqlConnection_1"));
}
Also used : IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 53 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class JavaProcessUtilTest method testFindMoreLibraries.

@Test
public void testFindMoreLibraries() {
    // ensure the CAMEL is not added as jar dependency
    DummyComponent comp = mock(DummyComponent.class);
    when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_CAMEL.getName());
    //$NON-NLS-1$
    INode node = new DataNode(comp, "");
    IElementParameter param = new ElementParameter(node);
    param.setName("HOTLIBS");
    List<Map<String, Object>> table = new ArrayList<Map<String, Object>>();
    Map<String, Object> line = new HashMap<String, Object>();
    line.put("LIBPATH", "CAMEL");
    table.add(line);
    param.setValue(table);
    List<ModuleNeeded> modulesNeeded = new ArrayList<ModuleNeeded>();
    JavaProcessUtil.findMoreLibraries(null, modulesNeeded, param);
    assertTrue(modulesNeeded.isEmpty());
    table = new ArrayList<Map<String, Object>>();
    line = new HashMap<String, Object>();
    line.put("LIBPATH", "\"camel.jar\"");
    table.add(line);
    param.setValue(table);
    modulesNeeded = new ArrayList<ModuleNeeded>();
    JavaProcessUtil.findMoreLibraries(null, modulesNeeded, param);
    assertEquals(1, modulesNeeded.size());
    assertEquals("camel.jar", modulesNeeded.get(0).getModuleName());
}
Also used : INode(org.talend.core.model.process.INode) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) DummyComponent(org.talend.designer.core.model.components.DummyComponent) DataNode(org.talend.designer.core.model.process.DataNode) IElementParameter(org.talend.core.model.process.IElementParameter) HashMap(java.util.HashMap) Map(java.util.Map) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Test(org.junit.Test)

Example 54 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class JavaProcessUtilTest method testGetHadoopClusterItemId.

@Test
public void testGetHadoopClusterItemId() {
    Process process = new Process(TestUtils.createDefaultProperty());
    Node simpleInputNode = NodeTestCreator.createSimpleInputNode(process);
    // Built in mode
    assertNull(JavaProcessUtil.getHadoopClusterItemId(simpleInputNode));
    // Repository mode but repository value is null
    IElementParameter propertyElementParameter = simpleInputNode.getElementParameterFromField((EParameterFieldType.PROPERTY_TYPE));
    propertyElementParameter.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
    propertyElementParameter.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).setValue(null);
    assertNull(JavaProcessUtil.getHadoopClusterItemId(simpleInputNode));
}
Also used : INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) DataNode(org.talend.designer.core.model.process.DataNode) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) Test(org.junit.Test)

Example 55 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class NodeTest method testGetNodeConnectorsShowIf1FlowConnector.

@Test
public void testGetNodeConnectorsShowIf1FlowConnector() {
    Process process = new Process(new FakePropertyImpl());
    IComponent sourceCom = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
    Node node = new Node(sourceCom, process);
    // create node connector for test
    List<INodeConnector> listConnector = new ArrayList<>();
    NodeConnector connector = new NodeConnector(node);
    connector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
    connector.setName(EConnectionType.FLOW_MAIN.getName());
    connector.setMaxLinkOutput(1);
    connector.setShowIf("SHOW_FLOW_CONNECTOR == 'true'");
    listConnector.add(connector);
    node.setListConnector(listConnector);
    // create a test param with default value 'false'
    IElementParameter param = addShowIfParam(node);
    Assert.assertNull(node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()));
    Assert.assertNull(node.getConnectorFromType(EConnectionType.FLOW_MAIN));
    Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 0);
    // make connector show if to 'true'
    param.setValue(true);
    Assert.assertNotNull(node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()));
    Assert.assertNotNull(node.getConnectorFromType(EConnectionType.FLOW_MAIN));
    Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 1);
}
Also used : FakePropertyImpl(org.talend.core.model.repository.FakePropertyImpl) INodeConnector(org.talend.core.model.process.INodeConnector) NodeConnector(org.talend.designer.core.model.components.NodeConnector) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) Process(org.talend.designer.core.ui.editor.process.Process) INodeConnector(org.talend.core.model.process.INodeConnector) Test(org.junit.Test)

Aggregations

IElementParameter (org.talend.core.model.process.IElementParameter)439 ArrayList (java.util.ArrayList)165 List (java.util.List)112 Node (org.talend.designer.core.ui.editor.nodes.Node)108 Map (java.util.Map)99 INode (org.talend.core.model.process.INode)94 HashMap (java.util.HashMap)87 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)73 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)69 Point (org.eclipse.swt.graphics.Point)57 ElementParameter (org.talend.designer.core.model.components.ElementParameter)48 ConnectionItem (org.talend.core.model.properties.ConnectionItem)45 IConnection (org.talend.core.model.process.IConnection)40 PersistenceException (org.talend.commons.exception.PersistenceException)39 Item (org.talend.core.model.properties.Item)38 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)37 IComponent (org.talend.core.model.components.IComponent)36 CCombo (org.eclipse.swt.custom.CCombo)33 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)29 Connection (org.talend.core.model.metadata.builder.connection.Connection)28