use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.
the class NodeTest method testGetNodeConnectorsShowIf2FlowConnectorWithName.
@Test
public void testGetNodeConnectorsShowIf2FlowConnectorWithName() {
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("FILTER");
listConnector.add(connector1);
connector1.setShowIf("SHOW_FLOW_CONNECTOR == 'true'");
NodeConnector connector2 = new NodeConnector(node);
connector2.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
connector2.setName("REJECT");
connector2.setShowIf("SHOW_FLOW_CONNECTOR == 'true'");
listConnector.add(connector2);
node.setListConnector(listConnector);
// create a test param with default value 'false'
IElementParameter param = addShowIfParam(node);
Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 0);
// make connector show if to 'true'
param.setValue(true);
Assert.assertTrue(node.getConnectorFromName("FILTER") == connector1);
Assert.assertTrue(node.getConnectorFromName("REJECT") == connector2);
Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 2);
// set CurLinkNbInput/Output should not affact other connector with same type but different name
connector1.setCurLinkNbInput(10);
connector1.setCurLinkNbOutput(100);
Assert.assertEquals(connector1.getCurLinkNbInput(), 10);
Assert.assertEquals(connector1.getCurLinkNbOutput(), 100);
Assert.assertEquals(connector2.getCurLinkNbInput(), 0);
Assert.assertEquals(connector2.getCurLinkNbOutput(), 0);
}
Aggregations