use of org.talend.core.model.repository.FakePropertyImpl in project tdi-studio-se by Talend.
the class RepositoryChangeMetadataCommandTest method testComponentSchemaUpdated.
@Test
public void testComponentSchemaUpdated() {
IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceInput", "DI");
Node node = new Node(component, new Process(new FakePropertyImpl()));
IMetadataTable table = node.getMetadataList().get(0);
IMetadataColumn column = new MetadataColumn();
column.setLabel("C1");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
column = new MetadataColumn();
column.setLabel("C2");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
column = new MetadataColumn();
column.setLabel("C3");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
IMetadataTable newTable = table.clone(true);
newTable.getListColumns().remove(0);
IElementParameter schemaParam = null;
for (IElementParameter param : node.getElementParameters()) {
if (EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType())) {
schemaParam = param;
break;
}
}
assertNotNull(schemaParam);
//$NON-NLS-1$
String fullParamName = SCHEMA_PARAM_NAME + ":REPOSITORY_SCHEMA_TYPE";
//$NON-NLS-1$ //$NON-NLS-2$
String propValue = "testconnid" + " - " + newTable.getTableName();
RepositoryChangeMetadataCommand changeMetadataCommand = new RepositoryChangeMetadataCommand(node, fullParamName, propValue, newTable, null, null);
changeMetadataCommand.execute();
newTable = node.getMetadataList().get(0);
String avroSchemaStr = ((SchemaProperties) node.getComponentProperties().getProperties("module.main")).schema.getStringValue();
assertNotNull(avroSchemaStr);
Schema avroSchema = new Schema.Parser().parse(avroSchemaStr);
assertEquals(2, avroSchema.getFields().size());
//$NON-NLS-1$
assertNull(avroSchema.getField("C1"));
assertEquals(avroSchemaStr, schemaParam.getValue().toString());
}
use of org.talend.core.model.repository.FakePropertyImpl in project tdi-studio-se by Talend.
the class ChangeMetadataCommandTest method testComponentSchemaUpdated.
@Test
public void testComponentSchemaUpdated() {
IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceInput", "DI");
Node node = new Node(component, new Process(new FakePropertyImpl()));
IMetadataTable table = node.getMetadataList().get(0);
IMetadataColumn column = new MetadataColumn();
column.setLabel("C1");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
column = new MetadataColumn();
column.setLabel("C2");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
column = new MetadataColumn();
column.setLabel("C3");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
IMetadataTable newTable = table.clone(true);
newTable.getListColumns().remove(0);
IElementParameter schemaParam = null;
for (IElementParameter param : node.getElementParameters()) {
if (EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType())) {
schemaParam = param;
break;
}
}
assertNotNull(schemaParam);
ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand(node, schemaParam, null, null, null, table, newTable);
changeMetadataCommand.execute();
String avroSchemaStr = ((SchemaProperties) node.getComponentProperties().getProperties("module.main")).schema.getStringValue();
assertNotNull(avroSchemaStr);
Schema avroSchema = new Schema.Parser().parse(avroSchemaStr);
assertEquals(2, avroSchema.getFields().size());
//$NON-NLS-1$
assertNull(avroSchema.getField("C1"));
assertEquals(avroSchemaStr, schemaParam.getValue().toString());
}
use of org.talend.core.model.repository.FakePropertyImpl 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.repository.FakePropertyImpl 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.repository.FakePropertyImpl 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);
}
}
}
Aggregations