use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class JavaProcessUtilTest method testGetChildrenModules_noChildren.
@Test
public void testGetChildrenModules_noChildren() {
INode node = mock(INode.class);
IComponent component = mock(IComponent.class);
when(node.getComponent()).thenReturn(component);
when(component.getName()).thenReturn("tLogRow");
List<ModuleNeeded> childrenModules = JavaProcessUtil.getChildrenModules(node, Collections.emptySet(), false);
assertTrue(childrenModules.isEmpty());
}
use of org.talend.core.model.components.IComponent 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);
}
use of org.talend.core.model.components.IComponent 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.core.model.components.IComponent in project tesb-studio-se by Talend.
the class CamelEditorDropTargetListener method extractComponents.
/**
* Extracts the components which have the same palette type as process. Added by Marvin Wang on Feb 27, 2013.
*
* @param neededComponents
* @return
*/
protected List<IComponent> extractComponents(List<IComponent> neededComponents) {
if (neededComponents != null && neededComponents.size() > 0) {
Iterator<IComponent> componentsIterator = neededComponents.iterator();
while (componentsIterator.hasNext()) {
IComponent component = componentsIterator.next();
String compType = component.getPaletteType();
if (compType != null && !compType.equals(editor.getProcess().getComponentsType())) {
componentsIterator.remove();
}
}
}
return neededComponents;
}
use of org.talend.core.model.components.IComponent in project tesb-studio-se by Talend.
the class CamelComponentsHandler method filterComponents.
// private List<IComponent> camelComponents = new ArrayList<IComponent>();
@Override
public List<IComponent> filterComponents(List<IComponent> allComponents) {
List<IComponent> camelComponents = new ArrayList<IComponent>();
if (allComponents == null || allComponents.isEmpty()) {
return camelComponents;
}
final String categoryName = extractComponentsCategory().getName();
for (IComponent component : allComponents) {
if (categoryName.equals(component.getPaletteType())) {
camelComponents.add(component);
}
}
return camelComponents;
}
Aggregations