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());
}
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);
}
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);
}
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());
}
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);
}
Aggregations