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));
}
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"));
}
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());
}
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));
}
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);
}
Aggregations