use of org.talend.repository.generic.model.genericMetadata.GenericConnectionItem 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.repository.generic.model.genericMetadata.GenericConnectionItem in project tdi-studio-se by Talend.
the class GenericConnectionUtilTest method createTestItem.
private GenericConnectionItem createTestItem(String label, String serializedProps) {
GenericConnection connection = GenericMetadataFactory.eINSTANCE.createGenericConnection();
connection.setCompProperties(serializedProps);
Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
connectionProperty.setId("testId");
connectionProperty.setLabel(label);
connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
//$NON-NLS-1$
connectionProperty.setStatusCode("");
GenericConnectionItem connectionItem = GenericMetadataFactory.eINSTANCE.createGenericConnectionItem();
connectionItem.setProperty(connectionProperty);
connectionItem.setConnection(connection);
return connectionItem;
}
use of org.talend.repository.generic.model.genericMetadata.GenericConnectionItem in project tdi-studio-se by Talend.
the class GenericConnectionUtilTest method testSynNamePropertyWithItem.
@Test
public void testSynNamePropertyWithItem() {
//$NON-NLS-1$
String namePropertyValue = "test";
//$NON-NLS-1$
TestProperties props = (TestProperties) new TestProperties("test").init();
props.name.setValue(namePropertyValue);
String serializedProps = props.toSerialized();
GenericConnectionItem testItem = createTestItem(namePropertyValue, serializedProps);
GenericConnection testConn = (GenericConnection) testItem.getConnection();
boolean itemChanged = GenericConnectionUtil.synNamePropertyWithItem(testItem);
assertFalse(itemChanged);
ComponentProperties componentProperties = ComponentsUtils.getComponentPropertiesFromSerialized(serializedProps, testConn);
assertEquals(namePropertyValue, componentProperties.getValuedProperty(IGenericConstants.NAME_PROPERTY).getValue());
//$NON-NLS-1$
String newPropertyValue = "test1";
testItem.getProperty().setLabel(newPropertyValue);
itemChanged = GenericConnectionUtil.synNamePropertyWithItem(testItem);
assertTrue(itemChanged);
componentProperties = ComponentsUtils.getComponentPropertiesFromSerialized(testConn.getCompProperties(), testConn);
assertEquals(newPropertyValue, componentProperties.getValuedProperty(IGenericConstants.NAME_PROPERTY).getValue());
}
Aggregations