use of org.talend.core.model.repository.FakePropertyImpl in project tdi-studio-se by Talend.
the class RepositoryUpdateTest method testRepositoryUpdate.
@SuppressWarnings("unchecked")
@Test
public void testRepositoryUpdate() throws PersistenceException {
//$NON-NLS-1$
String id = "testId";
try {
//$NON-NLS-1$ //$NON-NLS-2$
IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceInput", "DI");
Process process = new Process(new FakePropertyImpl());
Node node = new Node(component, process);
((List<INode>) process.getGraphicalNodes()).add(node);
GenericConnectionItem connectionItem = createBasicConnection(id);
setupPropertiesWithoutProxy(id);
prepareTableForTest(id);
// get updatedItem
IRepositoryViewObject object = ProxyRepositoryFactory.getInstance().getLastVersion(id);
connectionItem = (GenericConnectionItem) object.getProperty().getItem();
Assert.assertEquals(1, SchemaUtils.getMetadataTables(connectionItem.getConnection(), SubContainer.class).size());
updateNode(id, node, (GenericConnection) connectionItem.getConnection());
setupPropertiesWithProxy(id);
prepareTableForTest(id);
launchRepositoryUpdateOnNode(id, process, node);
//$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\"");
setupPropertiesWithoutProxy(id);
prepareTableForTest(id);
launchRepositoryUpdateOnNode(id, process, node);
//$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", "\"\"");
setupPropertiesWithProxyEmptyVars(id);
prepareTableForTest(id);
launchRepositoryUpdateOnNode(id, process, node);
//$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", "\"\"");
//$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", "\"\"");
} finally {
IRepositoryViewObject object = ProxyRepositoryFactory.getInstance().getLastVersion(id);
if (object != null) {
ProxyRepositoryFactory.getInstance().deleteObjectPhysical(object);
}
}
}
use of org.talend.core.model.repository.FakePropertyImpl in project tdi-studio-se by Talend.
the class ChangeMetadataCommandTest method testComponentSchemaPropagated.
/**
* Test disabled since for now the propagation is done by the component itself.<br>
* A new test need to be created with a custom component setting
*/
@Test
@Ignore
public void testComponentSchemaPropagated() {
Node simpleInputNode = NodeTestCreator.createSimpleInputNode(process);
//$NON-NLS-1$
TestProperties inputProps = (TestProperties) new TestProperties("testInput").init();
simpleInputNode.setComponentProperties(inputProps);
simpleInputNode.getMetadataList().clear();
IMetadataTable table = createSimpleMetadata(inputProps.schema);
table.setTableName(simpleInputNode.getUniqueName());
table.setLabel(simpleInputNode.getUniqueName());
//$NON-NLS-1$
table.setAttachedConnector("FLOW");
simpleInputNode.getMetadataList().add(table);
List<Object> args = new ArrayList<>();
args.add(simpleInputNode.getUniqueName());
//$NON-NLS-1$
args.add("connectionName");
// set null, the command should take the schema from the component directly
args.add(null);
//$NON-NLS-1$
ConnectionCreateCommand ccc = new ConnectionCreateCommand(simpleInputNode, "FLOW", args);
ConnectionCreateCommand.setCreatingConnection(true);
IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceOutput", "DI");
Node node = new Node(component, new Process(new FakePropertyImpl()));
ccc.setTarget(node);
ccc.execute();
IElementParameter schemaParam = null;
for (IElementParameter param : node.getElementParameters()) {
if (EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType()) && param.getContext().equals("MAIN")) {
schemaParam = param;
break;
}
}
assertNotNull(schemaParam);
table = node.getMetadataList().get(0);
String avroSchemaStr = inputProps.schema.schema.getStringValue();
assertNotNull(avroSchemaStr);
Schema avroSchema = new Schema.Parser().parse(avroSchemaStr);
assertEquals(3, avroSchema.getFields().size());
//$NON-NLS-1$
assertNotNull(avroSchema.getField("C1"));
//$NON-NLS-1$
assertNotNull(avroSchema.getField("C2"));
//$NON-NLS-1$
assertNotNull(avroSchema.getField("C3"));
assertEquals(avroSchema.getFields().toString(), ((Schema) schemaParam.getValue()).getFields().toString());
}
use of org.talend.core.model.repository.FakePropertyImpl in project tdi-studio-se by Talend.
the class ComponentsUtilsTest method createSFTestNode.
private INode createSFTestNode() {
//$NON-NLS-1$ //$NON-NLS-2$
IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceConnection", "DI");
INode node = new Node(component, new Process(new FakePropertyImpl()));
return node;
}
Aggregations