Search in sources :

Example 31 with RuntimeContainer

use of org.talend.components.api.container.RuntimeContainer in project components by Talend.

the class SnowflakeReadersTestIT method testCloseExistingConnection.

@Test
public void testCloseExistingConnection() throws Throwable {
    SnowflakeConnectionProperties connProps = (SnowflakeConnectionProperties) getComponentService().getComponentProperties(TSnowflakeConnectionDefinition.COMPONENT_NAME);
    setupProps(connProps);
    final String currentComponentName = TSnowflakeConnectionDefinition.COMPONENT_NAME + "_1";
    RuntimeContainer connContainer = new DefaultComponentRuntimeContainerImpl() {

        @Override
        public String getCurrentComponentId() {
            return currentComponentName;
        }
    };
    SnowflakeSourceOrSink snowflakeSourceOrSink = new SnowflakeSourceOrSink();
    snowflakeSourceOrSink.initialize(connContainer, connProps);
    assertEquals(ValidationResult.Result.OK, snowflakeSourceOrSink.validate(connContainer).getStatus());
    TSnowflakeCloseProperties closeProps = (TSnowflakeCloseProperties) getComponentService().getComponentProperties(TSnowflakeCloseDefinition.COMPONENT_NAME);
    closeProps.referencedComponent.componentInstanceId.setValue(currentComponentName);
    SnowflakeCloseSourceOrSink snowflakeCloseSourceOrSink = new SnowflakeCloseSourceOrSink();
    snowflakeCloseSourceOrSink.initialize(connContainer, closeProps);
    assertEquals(ValidationResult.Result.OK, snowflakeCloseSourceOrSink.validate(connContainer).getStatus());
}
Also used : DefaultComponentRuntimeContainerImpl(org.talend.components.api.container.DefaultComponentRuntimeContainerImpl) SnowflakeSourceOrSink(org.talend.components.snowflake.runtime.SnowflakeSourceOrSink) SnowflakeCloseSourceOrSink(org.talend.components.snowflake.runtime.SnowflakeCloseSourceOrSink) TSnowflakeCloseProperties(org.talend.components.snowflake.tsnowflakeclose.TSnowflakeCloseProperties) SnowflakeConnectionProperties(org.talend.components.snowflake.SnowflakeConnectionProperties) Matchers.containsString(org.hamcrest.Matchers.containsString) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 32 with RuntimeContainer

use of org.talend.components.api.container.RuntimeContainer in project components by Talend.

the class SnowflakeReadersTestIT method testUseExistingConnection.

@Test
public void testUseExistingConnection() throws Throwable {
    SnowflakeConnectionProperties connProps = (SnowflakeConnectionProperties) getComponentService().getComponentProperties(TSnowflakeConnectionDefinition.COMPONENT_NAME);
    setupProps(connProps);
    final String currentComponentName = TSnowflakeConnectionDefinition.COMPONENT_NAME + "_1";
    RuntimeContainer connContainer = new DefaultComponentRuntimeContainerImpl() {

        @Override
        public String getCurrentComponentId() {
            return currentComponentName;
        }
    };
    SnowflakeSourceOrSink SnowflakeSourceOrSink = new SnowflakeSourceOrSink();
    SnowflakeSourceOrSink.initialize(connContainer, connProps);
    assertEquals(ValidationResult.Result.OK, SnowflakeSourceOrSink.validate(connContainer).getStatus());
    // Input component get connection from the tSnowflakeConnection
    TSnowflakeInputProperties inProps = (TSnowflakeInputProperties) getComponentService().getComponentProperties(TSnowflakeInputDefinition.COMPONENT_NAME);
    inProps.connection.referencedComponent.componentInstanceId.setValue(currentComponentName);
    SnowflakeSourceOrSink SnowflakeInputSourceOrSink = new SnowflakeSourceOrSink();
    SnowflakeInputSourceOrSink.initialize(connContainer, inProps);
    assertEquals(ValidationResult.Result.OK, SnowflakeInputSourceOrSink.validate(connContainer).getStatus());
}
Also used : DefaultComponentRuntimeContainerImpl(org.talend.components.api.container.DefaultComponentRuntimeContainerImpl) SnowflakeSourceOrSink(org.talend.components.snowflake.runtime.SnowflakeSourceOrSink) SnowflakeConnectionProperties(org.talend.components.snowflake.SnowflakeConnectionProperties) Matchers.containsString(org.hamcrest.Matchers.containsString) TSnowflakeInputProperties(org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 33 with RuntimeContainer

use of org.talend.components.api.container.RuntimeContainer in project components by Talend.

the class SnowflakeReadersTestIT method testSameConnectionForSeveralReaders.

@Test(expected = IOException.class)
public void testSameConnectionForSeveralReaders() throws Throwable {
    SnowflakeConnectionProperties connProps = (SnowflakeConnectionProperties) getComponentService().getComponentProperties(TSnowflakeConnectionDefinition.COMPONENT_NAME);
    setupProps(connProps);
    final String currentComponentName = TSnowflakeConnectionDefinition.COMPONENT_NAME + "_1";
    RuntimeContainer connContainer = new DefaultComponentRuntimeContainerImpl() {

        @Override
        public String getCurrentComponentId() {
            return currentComponentName;
        }
    };
    SnowflakeSourceOrSink SnowflakeSourceOrSink = new SnowflakeSourceOrSink();
    SnowflakeSourceOrSink.initialize(connContainer, connProps);
    assertEquals(ValidationResult.Result.OK, SnowflakeSourceOrSink.validate(connContainer).getStatus());
    TSnowflakeOutputProperties props = (TSnowflakeOutputProperties) getComponentService().getComponentProperties(TSnowflakeOutputDefinition.COMPONENT_NAME);
    setupProps(props.getConnectionProperties());
    setupTableWithStaticValues(props);
    props.connection.referencedComponent.componentInstanceId.setValue(currentComponentName);
    List<IndexedRecord> rows = readRows(props, connContainer);
    assertEquals(100, rows.size());
    // Read second time with the same properties but with new reader.
    rows = readRows(props, connContainer);
    assertEquals(100, rows.size());
    TSnowflakeCloseProperties closeProps = (TSnowflakeCloseProperties) getComponentService().getComponentProperties(TSnowflakeCloseDefinition.COMPONENT_NAME);
    closeProps.referencedComponent.componentInstanceId.setValue(currentComponentName);
    SnowflakeCloseSourceOrSink snowflakeCloseSourceOrSink = new SnowflakeCloseSourceOrSink();
    snowflakeCloseSourceOrSink.initialize(connContainer, closeProps);
    assertEquals(ValidationResult.Result.OK, snowflakeCloseSourceOrSink.validate(connContainer).getStatus());
    // After close, exception should be thrown by the reader, if we try to read with the same connection.
    rows = readRows(props, connContainer);
}
Also used : TSnowflakeOutputProperties(org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord) DefaultComponentRuntimeContainerImpl(org.talend.components.api.container.DefaultComponentRuntimeContainerImpl) SnowflakeSourceOrSink(org.talend.components.snowflake.runtime.SnowflakeSourceOrSink) SnowflakeCloseSourceOrSink(org.talend.components.snowflake.runtime.SnowflakeCloseSourceOrSink) TSnowflakeCloseProperties(org.talend.components.snowflake.tsnowflakeclose.TSnowflakeCloseProperties) SnowflakeConnectionProperties(org.talend.components.snowflake.SnowflakeConnectionProperties) Matchers.containsString(org.hamcrest.Matchers.containsString) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 34 with RuntimeContainer

use of org.talend.components.api.container.RuntimeContainer in project components by Talend.

the class SnowflakeRowSinkTest method testInitialize.

@Test
public void testInitialize() {
    RuntimeContainer container = Mockito.mock(RuntimeContainer.class);
    TSnowflakeRowProperties properties = new TSnowflakeRowProperties("rowProperties");
    Assert.assertNull(sink.getRowProperties());
    ValidationResult result = sink.initialize(container, properties);
    Assert.assertEquals(ValidationResult.OK, result);
    Assert.assertEquals(properties, sink.getRowProperties());
}
Also used : TSnowflakeRowProperties(org.talend.components.snowflake.tsnowflakerow.TSnowflakeRowProperties) ValidationResult(org.talend.daikon.properties.ValidationResult) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 35 with RuntimeContainer

use of org.talend.components.api.container.RuntimeContainer in project components by Talend.

the class SnowflakeCloseSourceOrSinkTest method testValidate.

@Test
public void testValidate() throws SQLException {
    RuntimeContainer container = Mockito.mock(RuntimeContainer.class);
    Connection connection = Mockito.mock(Connection.class);
    Mockito.doNothing().when(connection).close();
    Mockito.when(container.getComponentData(Mockito.anyString(), Mockito.anyString())).thenReturn(connection);
    Assert.assertEquals(ValidationResult.Result.OK, closeSourceOrSink.validate(container).getStatus());
}
Also used : Connection(java.sql.Connection) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Aggregations

RuntimeContainer (org.talend.components.api.container.RuntimeContainer)36 Test (org.junit.Test)34 DatabaseClient (com.marklogic.client.DatabaseClient)14 Schema (org.apache.avro.Schema)10 IndexedRecord (org.apache.avro.generic.IndexedRecord)10 DefaultComponentRuntimeContainerImpl (org.talend.components.api.container.DefaultComponentRuntimeContainerImpl)9 MarkLogicOutputProperties (org.talend.components.marklogic.tmarklogicoutput.MarkLogicOutputProperties)7 List (java.util.List)6 NetSuiteDatasetRuntime (org.talend.components.netsuite.NetSuiteDatasetRuntime)6 ValidationResult (org.talend.daikon.properties.ValidationResult)6 NetSuiteRuntimeImpl (org.talend.components.netsuite.v2016_2.NetSuiteRuntimeImpl)5 NetSuitePortType (com.netsuite.webservices.v2016_2.platform.NetSuitePortType)4 CustomFieldList (com.netsuite.webservices.v2016_2.platform.core.CustomFieldList)4 CustomRecordRef (com.netsuite.webservices.v2016_2.platform.core.CustomRecordRef)4 RecordRefList (com.netsuite.webservices.v2016_2.platform.core.RecordRefList)4 GetListRequest (com.netsuite.webservices.v2016_2.platform.messages.GetListRequest)4 ArrayList (java.util.ArrayList)4 Result (org.talend.components.api.component.runtime.Result)4 NetSuiteSink (org.talend.components.netsuite.NetSuiteSink)4 NetSuiteClientService (org.talend.components.netsuite.client.NetSuiteClientService)4