use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class SandboxedRowGeneratorRuntimeTest method testBasic.
@Test
public void testBasic() throws Exception {
final RowGeneratorProperties props = createComponentProperties();
props.schemaFlow.schema.setValue(SampleSchemas.recordSimple());
props.nbRows.setValue(95L);
props.nbPartitions.setValue(10);
RuntimeInfo ri = def.getRuntimeInfo(ExecutionEngine.BEAM, props, ConnectorTopology.OUTGOING);
try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
RuntimableRuntime<RowGeneratorProperties> runtime = (RuntimableRuntime<RowGeneratorProperties>) si.getInstance();
runtime.initialize(null, props);
}
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class MarketoCustomObjectsSchemasProperties method beforeFormPresentCustomObjects.
public void beforeFormPresentCustomObjects() throws IOException {
List<NamedThing> customObjectsNames;
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(RUNTIME_SOURCEORSINK_CLASS, USE_CURRENT_JVM_PROPS)) {
MarketoSourceOrSinkRuntime sos = (MarketoSourceOrSinkRuntime) sandboxedInstance.getInstance();
sos.initialize(null, this);
customObjectsNames = sos.getSchemaNames(null);
}
selectedCustomObjectsNames.setPossibleValues(customObjectsNames);
getForm(FORM_CUSTOMOBJECTS).setAllowBack(true);
getForm(FORM_CUSTOMOBJECTS).setAllowFinish(true);
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class GoogleDriveConnectionProperties method validateTestConnection.
public ValidationResult validateTestConnection() throws Exception {
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, true)) {
GoogleDriveProvideRuntime sos = (GoogleDriveProvideRuntime) sandboxedInstance.getInstance();
sos.initialize(null, this);
try {
ValidationResultMutable vr = new ValidationResultMutable(sos.validateConnection(this));
if (Result.OK.equals(vr.getStatus())) {
getForm(FORM_WIZARD).setAllowFinish(true);
} else {
getForm(FORM_WIZARD).setAllowFinish(false);
}
return vr;
} catch (Exception e) {
LOG.error("[validateTestConnection] {}.", e.getMessage());
return new ValidationResultMutable(Result.ERROR, e.getMessage());
}
}
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class JDBCTableSelectionModule method beforeTablename.
public ValidationResult beforeTablename() throws IOException {
JdbcRuntimeInfo jdbcRuntimeInfo = new JdbcRuntimeInfo(connection, "org.talend.components.jdbc.runtime.JDBCSource");
try (SandboxedInstance sandboxI = RuntimeUtil.createRuntimeClass(jdbcRuntimeInfo, connection.getClass().getClassLoader())) {
SourceOrSink ss = (SourceOrSink) sandboxI.getInstance();
ss.initialize(null, (ComponentProperties) connection);
List<NamedThing> tablenames = ss.getSchemaNames(null);
tablename.setPossibleNamedThingValues(tablenames);
} catch (ComponentException ex) {
return ex.getValidationResult();
}
return ValidationResult.OK;
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class MarkLogicConnectionPropertiesTest method testValidateConnection.
@Test
public void testValidateConnection() {
testConnectionProperties.init();
SandboxedInstance sandbox = Mockito.mock(SandboxedInstance.class);
PowerMockito.mockStatic(SandboxInstanceFactory.class);
PowerMockito.when(SandboxInstanceFactory.createSandboxedInstance(Mockito.any(RuntimeInfo.class), Mockito.any(ClassLoader.class), Mockito.eq(false))).thenReturn(sandbox);
DatastoreRuntime<MarkLogicConnectionProperties> datastore = Mockito.mock(DatastoreRuntime.class);
Mockito.when(sandbox.getInstance()).thenReturn(datastore);
Mockito.when(datastore.doHealthChecks(null)).thenReturn(Collections.singletonList(new ValidationResult(Result.ERROR)));
ValidationResult vr = testConnectionProperties.validateTestConnection();
assertEquals(Result.ERROR, vr.getStatus());
assertFalse(testConnectionProperties.getForm(MarkLogicConnectionProperties.WIZARD).isAllowFinish());
Mockito.when(datastore.doHealthChecks(null)).thenReturn(Collections.singletonList(new ValidationResult(Result.OK)));
vr = testConnectionProperties.validateTestConnection();
assertEquals(Result.OK, vr.getStatus());
Assert.assertTrue(testConnectionProperties.getForm(MarkLogicConnectionProperties.WIZARD).isAllowFinish());
}
Aggregations