Search in sources :

Example 16 with GenericConnectionItem

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);
        }
    }
}
Also used : FakePropertyImpl(org.talend.core.model.repository.FakePropertyImpl) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Process(org.talend.designer.core.ui.editor.process.Process) List(java.util.List) ArrayList(java.util.ArrayList) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem) Test(org.junit.Test)

Example 17 with GenericConnectionItem

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;
}
Also used : GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem) Property(org.talend.core.model.properties.Property)

Example 18 with GenericConnectionItem

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());
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem) Test(org.junit.Test)

Aggregations

GenericConnectionItem (org.talend.repository.generic.model.genericMetadata.GenericConnectionItem)18 GenericConnection (org.talend.repository.generic.model.genericMetadata.GenericConnection)9 ComponentProperties (org.talend.components.api.properties.ComponentProperties)5 ComponentWizard (org.talend.components.api.wizard.ComponentWizard)4 ConnectionItem (org.talend.core.model.properties.ConnectionItem)4 Property (org.talend.core.model.properties.Property)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 ArrayList (java.util.ArrayList)3 Path (org.eclipse.core.runtime.Path)3 ComponentService (org.talend.components.api.service.ComponentService)3 IOException (java.io.IOException)2 Properties (java.util.Properties)2 Test (org.junit.Test)2 IComponent (org.talend.core.model.components.IComponent)2 Connection (org.talend.core.model.metadata.builder.connection.Connection)2 Item (org.talend.core.model.properties.Item)2 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)2 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)2 HashSet (java.util.HashSet)1 List (java.util.List)1