use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class NodeTest method testGetNodeConnectorsShowIf2FlowConnector.
@Test
public void testGetNodeConnectorsShowIf2FlowConnector() {
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 connector1 = new NodeConnector(node);
connector1.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
connector1.setName(EConnectionType.FLOW_MAIN.getName());
connector1.setMaxLinkOutput(1);
listConnector.add(connector1);
connector1.setShowIf("SHOW_FLOW_CONNECTOR == 'true'");
NodeConnector connector2 = new NodeConnector(node);
connector2.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
connector2.setName(EConnectionType.FLOW_MAIN.getName());
connector2.setMaxLinkInput(-1);
connector2.setMaxLinkOutput(-1);
connector2.setShowIf("SHOW_FLOW_CONNECTOR == 'false'");
listConnector.add(connector2);
node.setListConnector(listConnector);
// create a test param with default value 'false'
IElementParameter param = addShowIfParam(node);
Assert.assertTrue(node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()) == connector2);
Assert.assertTrue(node.getConnectorFromType(EConnectionType.FLOW_MAIN) == connector2);
Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 1);
// make connector show if to 'true'
param.setValue(true);
Assert.assertTrue(node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()) == connector1);
Assert.assertTrue(node.getConnectorFromType(EConnectionType.FLOW_MAIN) == connector1);
Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 1);
// connector with same name should have the same current input/output
connector1.setCurLinkNbInput(10);
connector1.setCurLinkNbOutput(100);
Assert.assertEquals(connector1.getCurLinkNbInput(), 10);
Assert.assertEquals(connector1.getCurLinkNbOutput(), 100);
Assert.assertEquals(connector2.getCurLinkNbInput(), 10);
Assert.assertEquals(connector2.getCurLinkNbOutput(), 100);
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class RepositoryUpdateTest method testRepositoryChange.
@Test
public void testRepositoryChange() throws PersistenceException {
//$NON-NLS-1$
String id = "testId";
try {
//$NON-NLS-1$ //$NON-NLS-2$
IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceInput", "DI");
Node node = new Node(component, new Process(new FakePropertyImpl()));
GenericConnection connection = (GenericConnection) createBasicConnection(id).getConnection();
setupPropertiesWithoutProxy(id);
updateNode(id, node, connection);
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.userPassword.userId", "\"myUser\"");
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.userPassword.password", "\"myPassword\"");
//$NON-NLS-1$
testRepositoryValue(node, "connection.proxy.useProxy", Boolean.FALSE);
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.proxy.host", "\"\"");
//$NON-NLS-1$
testRepositoryValue(node, "connection.proxy.port", null);
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.proxy.userPassword.userId", "\"\"");
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.proxy.userPassword.password", "\"\"");
setupPropertiesWithProxy(id);
updateNode(id, node, connection);
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.userPassword.userId", "\"myUser\"");
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.userPassword.password", "\"myPassword\"");
//$NON-NLS-1$
testRepositoryValue(node, "connection.proxy.useProxy", Boolean.TRUE);
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.proxy.host", "\"host\"");
//$NON-NLS-1$
testRepositoryValue(node, "connection.proxy.port", 1234);
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.proxy.userPassword.userId", "\"proxyUser\"");
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.proxy.userPassword.password", "\"proxyPassword\"");
} finally {
IRepositoryViewObject object = ProxyRepositoryFactory.getInstance().getLastVersion(id);
if (object != null) {
ProxyRepositoryFactory.getInstance().deleteObjectPhysical(object);
}
}
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class ProcessErrorUtilTest method testGetAllErrorMess.
/**
* Test method for
* {@link org.talend.designer.runprocess.ui.ProcessComposite#getAllErrorMess(org.talend.designer.runprocess.IProcessMessage)}
* .
*/
@Test
public void testGetAllErrorMess() {
Property property1 = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property1.setId("property1");
//$NON-NLS-1$
property1.setVersion("0.1");
//$NON-NLS-1$
property1.setLabel("ParentJob");
Process process = new Process(property1);
IComponent tOracleSPComponent = ComponentsFactoryProvider.getInstance().get("tOracleSP", ComponentCategory.CATEGORY_4_DI.getName());
Node tOracleSP_1 = new Node(tOracleSPComponent, process);
process.addNodeContainer(new NodeContainer(tOracleSP_1));
RunProcessContext context = new RunProcessContext(process);
String errorMessage1 = "Exception in component tOracleSP_1 (ParentJob)\njava.sql.SQLException: ORA-20000: Failed to execute one or more sql statements";
ProcessMessage message1 = new ProcessMessage(MsgType.STD_ERR, errorMessage1);
HashMap<String, IProcessMessage> errorMessMap = ProcessErrorUtil.getAllErrorMess(message1, context);
Assert.assertEquals(errorMessMap.get(tOracleSP_1.getUniqueName()).getContent(), errorMessage1);
String errorMessage2 = "Exception in component tOracleSP_1 (ChildJob)\njava.sql.SQLException: ORA-20000: Failed to execute one or more sql statements";
ProcessMessage message2 = new ProcessMessage(MsgType.STD_ERR, errorMessage2);
HashMap<String, IProcessMessage> errorMessMap2 = ProcessErrorUtil.getAllErrorMess(message2, context);
Assert.assertNull(errorMessMap2.get(tOracleSP_1.getUniqueName()));
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class JavaProcessorUtilitiesTest method testComputeLibrariesPathWithMissingJars.
@Test
public void testComputeLibrariesPathWithMissingJars() {
boolean headless = CommonsPlugin.isHeadless();
try {
// don't popup dialog to block ui
CommonsPlugin.setHeadless(true);
IComponent tLibraryLoadComponent = ComponentsFactoryProvider.getInstance().get("tLibraryLoad", ComponentCategory.CATEGORY_4_DI.getName());
Property property = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property.setId("property");
//$NON-NLS-1$
property.setVersion("0.1");
//$NON-NLS-1$
property.setLabel("test");
Process process = new Process(property);
Node tLibraryLoad_1 = new Node(tLibraryLoadComponent, process);
process.addNodeContainer(new NodeContainer(tLibraryLoad_1));
tLibraryLoad_1.getElementParameter("LIBRARY").setValue("computeLibrariesPath.jar");
Set<ModuleNeeded> neededLibraries = CorePlugin.getDefault().getDesignerCoreService().getNeededLibrariesForProcess(process, false);
ProcessorException exception = null;
try {
JavaProcessorUtilities.computeLibrariesPath(neededLibraries, process, new HashSet<ModuleNeeded>());
} catch (ProcessorException e) {
exception = e;
}
if (exception != null) {
Assert.assertTrue(exception.getMessage().contains("computeLibrariesPath.jar"));
} else {
fail("computeLibrariesPath failed for process test{tLibraryLoad},computeLibrariesPath.jar not found but no exception");
}
} finally {
CommonsPlugin.setHeadless(headless);
}
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class JavaProcessorUtilitiesTest method testComputeLibrariesPath.
@Test
public void testComputeLibrariesPath() {
boolean headless = CommonsPlugin.isHeadless();
try {
CommonsPlugin.setHeadless(true);
IComponent tFixedFlowComponent = ComponentsFactoryProvider.getInstance().get("tFixedFlowInput", ComponentCategory.CATEGORY_4_DI.getName());
IComponent tLogRowComponent = ComponentsFactoryProvider.getInstance().get("tLogRow", ComponentCategory.CATEGORY_4_DI.getName());
Property property = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property.setId("property");
//$NON-NLS-1$
property.setVersion("0.1");
//$NON-NLS-1$
property.setLabel("test");
Process process = new Process(property);
Node tFixedFlowInput_1 = new Node(tFixedFlowComponent, process);
createMetadataColumns(tFixedFlowInput_1.getMetadataList().get(0), 1);
Node tLogRow_1 = new Node(tLogRowComponent, process);
createMetadataColumns(tLogRow_1.getMetadataList().get(0), 1);
process.addNodeContainer(new NodeContainer(tFixedFlowInput_1));
process.addNodeContainer(new NodeContainer(tLogRow_1));
new Connection(tFixedFlowInput_1, tLogRow_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tFixedFlowInput_1", "row1", "row1", false);
Set<ModuleNeeded> neededLibraries = CorePlugin.getDefault().getDesignerCoreService().getNeededLibrariesForProcess(process, false);
try {
JavaProcessorUtilities.computeLibrariesPath(neededLibraries, process, new HashSet<ModuleNeeded>());
} catch (ProcessorException e) {
fail("computeLibrariesPath failed for process test{tFixedFlowInput->tLogRow}");
}
} finally {
CommonsPlugin.setHeadless(headless);
}
}
Aggregations