Search in sources :

Example 1 with LocalWorkflowEngine

use of org.apache.hop.workflow.engines.local.LocalWorkflowEngine in project hop by apache.

the class WorkflowActionEvalTableContentTest method setUp.

@Before
public void setUp() throws Exception {
    MockDriver.registerInstance();
    IWorkflowEngine<WorkflowMeta> workflow = new LocalWorkflowEngine(new WorkflowMeta());
    action = new ActionEvalTableContent();
    workflow.getWorkflowMeta().addAction(new ActionMeta(action));
    action.setParentWorkflow(workflow);
    workflow.setStopped(false);
    DatabaseMeta dbMeta = new DatabaseMeta();
    dbMeta.setDatabaseType("mock-db");
    action.setDatabase(dbMeta);
    action.setVariable(Const.HOP_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_WORKFLOW_ACTIONS, "N");
}
Also used : ActionMeta(org.apache.hop.workflow.action.ActionMeta) LocalWorkflowEngine(org.apache.hop.workflow.engines.local.LocalWorkflowEngine) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta) BaseDatabaseMeta(org.apache.hop.core.database.BaseDatabaseMeta) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta)

Example 2 with LocalWorkflowEngine

use of org.apache.hop.workflow.engines.local.LocalWorkflowEngine in project hop by apache.

the class WorkflowActionFilesExistTest method setUp.

@Before
public void setUp() throws Exception {
    workflow = new LocalWorkflowEngine(new WorkflowMeta());
    action = new ActionFilesExist();
    workflow.getWorkflowMeta().addAction(new ActionMeta(action));
    action.setParentWorkflow(workflow);
    WorkflowMeta mockWorkflowMeta = mock(WorkflowMeta.class);
    action.setParentWorkflowMeta(mockWorkflowMeta);
    workflow.setStopped(false);
    existingFile1 = TestUtils.createRamFile(getClass().getSimpleName() + "/existingFile1.ext", action);
    existingFile2 = TestUtils.createRamFile(getClass().getSimpleName() + "/existingFile2.ext", action);
}
Also used : ActionMeta(org.apache.hop.workflow.action.ActionMeta) LocalWorkflowEngine(org.apache.hop.workflow.engines.local.LocalWorkflowEngine) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta) Before(org.junit.Before)

Example 3 with LocalWorkflowEngine

use of org.apache.hop.workflow.engines.local.LocalWorkflowEngine in project hop by apache.

the class ScriptValueAddFunctions_SetVariableScopeTest method createWorkflow.

private Workflow createWorkflow() {
    Workflow workflow = new LocalWorkflowEngine();
    workflow = spy(workflow);
    return workflow;
}
Also used : Workflow(org.apache.hop.workflow.Workflow) LocalWorkflowEngine(org.apache.hop.workflow.engines.local.LocalWorkflowEngine)

Example 4 with LocalWorkflowEngine

use of org.apache.hop.workflow.engines.local.LocalWorkflowEngine in project hop by apache.

the class ActionHttp_PDI208_Test method testHttpResultDefaultRows.

@Test
public void testHttpResultDefaultRows() throws IOException {
    File localFileForUpload = getInputFile("existingFile1", ".tmp");
    File tempFileForDownload = File.createTempFile("downloadedFile1", ".tmp");
    localFileForUpload.deleteOnExit();
    tempFileForDownload.deleteOnExit();
    Object[] r = new Object[] { HTTP_SERVER_BASEURL + "/uploadFile", localFileForUpload.getCanonicalPath(), tempFileForDownload.getCanonicalPath() };
    RowMeta rowMetaDefault = new RowMeta();
    rowMetaDefault.addValueMeta(new ValueMetaString("URL"));
    rowMetaDefault.addValueMeta(new ValueMetaString("UPLOAD"));
    rowMetaDefault.addValueMeta(new ValueMetaString("DESTINATION"));
    List<RowMetaAndData> rows = new ArrayList<>();
    rows.add(new RowMetaAndData(rowMetaDefault, r));
    Result previousResult = new Result();
    previousResult.setRows(rows);
    ActionHttp http = new ActionHttp();
    http.setParentWorkflow(new LocalWorkflowEngine());
    http.setRunForEveryRow(true);
    http.setAddFilenameToResult(false);
    http.execute(previousResult, 0);
    assertTrue(FileUtils.contentEquals(localFileForUpload, tempFileForDownload));
}
Also used : ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) RowMetaAndData(org.apache.hop.core.RowMetaAndData) RowMeta(org.apache.hop.core.row.RowMeta) ArrayList(java.util.ArrayList) LocalWorkflowEngine(org.apache.hop.workflow.engines.local.LocalWorkflowEngine) File(java.io.File) Result(org.apache.hop.core.Result) Test(org.junit.Test)

Example 5 with LocalWorkflowEngine

use of org.apache.hop.workflow.engines.local.LocalWorkflowEngine in project hop by apache.

the class ActionHttp_PDI208_Test method testHttpResultCustomRows.

@Test
public void testHttpResultCustomRows() throws IOException {
    File localFileForUpload = getInputFile("existingFile2", ".tmp");
    File tempFileForDownload = File.createTempFile("downloadedFile2", ".tmp");
    localFileForUpload.deleteOnExit();
    tempFileForDownload.deleteOnExit();
    Object[] r = new Object[] { HTTP_SERVER_BASEURL + "/uploadFile", localFileForUpload.getCanonicalPath(), tempFileForDownload.getCanonicalPath() };
    RowMeta rowMetaDefault = new RowMeta();
    rowMetaDefault.addValueMeta(new ValueMetaString("MyURL"));
    rowMetaDefault.addValueMeta(new ValueMetaString("MyUpload"));
    rowMetaDefault.addValueMeta(new ValueMetaString("MyDestination"));
    List<RowMetaAndData> rows = new ArrayList<>();
    rows.add(new RowMetaAndData(rowMetaDefault, r));
    Result previousResult = new Result();
    previousResult.setRows(rows);
    ActionHttp http = new ActionHttp();
    http.setParentWorkflow(new LocalWorkflowEngine());
    http.setRunForEveryRow(true);
    http.setAddFilenameToResult(false);
    http.setUrlFieldname("MyURL");
    http.setUploadFieldname("MyUpload");
    http.setDestinationFieldname("MyDestination");
    http.execute(previousResult, 0);
    assertTrue(FileUtils.contentEquals(localFileForUpload, tempFileForDownload));
}
Also used : ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) RowMetaAndData(org.apache.hop.core.RowMetaAndData) RowMeta(org.apache.hop.core.row.RowMeta) ArrayList(java.util.ArrayList) LocalWorkflowEngine(org.apache.hop.workflow.engines.local.LocalWorkflowEngine) File(java.io.File) Result(org.apache.hop.core.Result) Test(org.junit.Test)

Aggregations

LocalWorkflowEngine (org.apache.hop.workflow.engines.local.LocalWorkflowEngine)12 WorkflowMeta (org.apache.hop.workflow.WorkflowMeta)7 ActionMeta (org.apache.hop.workflow.action.ActionMeta)5 File (java.io.File)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 Result (org.apache.hop.core.Result)2 RowMetaAndData (org.apache.hop.core.RowMetaAndData)2 DatabaseMeta (org.apache.hop.core.database.DatabaseMeta)2 HopException (org.apache.hop.core.exception.HopException)2 RowMeta (org.apache.hop.core.row.RowMeta)2 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)2 IVariables (org.apache.hop.core.variables.IVariables)2 Before (org.junit.Before)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 FileAttribute (java.nio.file.attribute.FileAttribute)1 BaseDatabaseMeta (org.apache.hop.core.database.BaseDatabaseMeta)1