Search in sources :

Example 11 with RuntimeContainer

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

the class MarkLogicSourceTest method testValidate.

@Test
public void testValidate() {
    MarkLogicInputProperties inputProperties = new MarkLogicInputProperties("inputProps");
    inputProperties.init();
    inputProperties.connection.referencedComponent.componentInstanceId.setValue("some value");
    RuntimeContainer mockedContainer = mock(RuntimeContainer.class);
    DatabaseClient client = mock(DatabaseClient.class);
    when(mockedContainer.getComponentData(inputProperties.connection.getReferencedComponentId(), "connection")).thenReturn(client);
    source.initialize(mockedContainer, inputProperties);
    ValidationResult result = source.validate(mockedContainer);
    assertEquals(ValidationResult.Result.OK, result.getStatus());
}
Also used : DatabaseClient(com.marklogic.client.DatabaseClient) ValidationResult(org.talend.daikon.properties.ValidationResult) MarkLogicInputProperties(org.talend.components.marklogic.tmarklogicinput.MarkLogicInputProperties) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 12 with RuntimeContainer

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

the class MarkLogicDataSourceTest method testValidate.

@Test
public void testValidate() {
    datasource.getMarkLogicConnectionProperties().referencedComponent.componentInstanceId.setValue("reference");
    DatabaseClient client = Mockito.mock(DatabaseClient.class);
    RuntimeContainer container = Mockito.mock(RuntimeContainer.class);
    Mockito.when(container.getComponentData("reference", MarkLogicConnection.CONNECTION)).thenReturn(client);
    Assert.assertEquals(Result.OK, datasource.validate(container).getStatus());
    Mockito.verify(container, Mockito.only()).getComponentData("reference", MarkLogicConnection.CONNECTION);
}
Also used : DatabaseClient(com.marklogic.client.DatabaseClient) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 13 with RuntimeContainer

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

the class MarkLogicDataSourceTest method testValidateFailed.

@Test
public void testValidateFailed() {
    datasource.getMarkLogicConnectionProperties().referencedComponent.componentInstanceId.setValue("reference");
    RuntimeContainer container = Mockito.mock(RuntimeContainer.class);
    Mockito.when(container.getComponentData("reference", MarkLogicConnection.CONNECTION)).thenReturn(null);
    Assert.assertEquals(Result.ERROR, datasource.validate(container).getStatus());
    Mockito.verify(container, Mockito.only()).getComponentData("reference", MarkLogicConnection.CONNECTION);
}
Also used : RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 14 with RuntimeContainer

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

the class MarkLogicDatastoreRuntimeTest method testDoHealthChecksFailed.

@Test
public void testDoHealthChecksFailed() {
    RuntimeContainer container = Mockito.mock(RuntimeContainer.class);
    Mockito.when(container.getComponentData("reference", MarkLogicConnection.CONNECTION)).thenReturn(null);
    List<ValidationResult> healthChecks = (List<ValidationResult>) datastoreRuntime.doHealthChecks(container);
    Assert.assertEquals(1, healthChecks.size());
    Assert.assertEquals(Result.ERROR, healthChecks.get(0).getStatus());
}
Also used : List(java.util.List) ValidationResult(org.talend.daikon.properties.ValidationResult) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 15 with RuntimeContainer

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

the class JDBCSchemaTestIT method testGetSchema.

@Test
public void testGetSchema() throws Exception {
    TJDBCInputDefinition definition = new TJDBCInputDefinition();
    TJDBCInputProperties properties = DBTestUtils.createCommonJDBCInputProperties(allSetting, definition);
    properties.main.schema.setValue(DBTestUtils.createTestSchema3(true, tablename));
    properties.tableSelection.tablename.setValue(tablename);
    properties.sql.setValue(DBTestUtils.getSQL(tablename));
    JDBCSource source = DBTestUtils.createCommonJDBCSource(properties);
    RuntimeContainer container = new DefaultComponentRuntimeContainerImpl() {

        @Override
        public String getCurrentComponentId() {
            return "tJDBCInput1";
        }
    };
    java.net.URL mappings_url = this.getClass().getResource("/mappings");
    mappings_url = DBTestUtils.correctURL(mappings_url);
    container.setComponentData(container.getCurrentComponentId(), ComponentConstants.MAPPING_URL_SUBFIX, mappings_url);
    Schema schema = source.getEndpointSchema(container, tablename);
    assertEquals(tablename, schema.getName().toUpperCase());
    List<Field> columns = schema.getFields();
    testMetadata(columns);
}
Also used : Field(org.apache.avro.Schema.Field) DefaultComponentRuntimeContainerImpl(org.talend.components.api.container.DefaultComponentRuntimeContainerImpl) Schema(org.apache.avro.Schema) TJDBCInputProperties(org.talend.components.jdbc.tjdbcinput.TJDBCInputProperties) JDBCSource(org.talend.components.jdbc.runtime.JDBCSource) TJDBCInputDefinition(org.talend.components.jdbc.tjdbcinput.TJDBCInputDefinition) 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