Search in sources :

Example 21 with ActionMeta

use of org.apache.hop.workflow.action.ActionMeta in project hop by apache.

the class WorkflowMetaTest method createAction.

private ActionMeta createAction(String name) {
    IAction action = mock(IAction.class);
    ActionMeta actionMeta = new ActionMeta(action);
    when(actionMeta.getName()).thenReturn(name);
    return actionMeta;
}
Also used : IAction(org.apache.hop.workflow.action.IAction) ActionMeta(org.apache.hop.workflow.action.ActionMeta)

Example 22 with ActionMeta

use of org.apache.hop.workflow.action.ActionMeta in project hop by apache.

the class WorkflowMetaTest method shouldUseCoordinatesOfItsTransformsAndNotesWhenCalculatingMinimumPoint.

@Test
public void shouldUseCoordinatesOfItsTransformsAndNotesWhenCalculatingMinimumPoint() {
    Point actionPoint = new Point(500, 500);
    Point notePadMetaPoint = new Point(400, 400);
    ActionMeta actionMeta = mock(ActionMeta.class);
    when(actionMeta.getLocation()).thenReturn(actionPoint);
    NotePadMeta notePadMeta = mock(NotePadMeta.class);
    when(notePadMeta.getLocation()).thenReturn(notePadMetaPoint);
    // empty Workflow return 0 coordinate point
    Point point = workflowMeta.getMinimum();
    assertEquals(0, point.x);
    assertEquals(0, point.y);
    // when Workflow contains a single transform or note, then workflowMeta should return
    // coordinates of it, subtracting borders
    workflowMeta.addAction(0, actionMeta);
    Point actualTransformPoint = workflowMeta.getMinimum();
    assertEquals(actionPoint.x - WorkflowMeta.BORDER_INDENT, actualTransformPoint.x);
    assertEquals(actionPoint.y - WorkflowMeta.BORDER_INDENT, actualTransformPoint.y);
    // when Workflow contains transform or notes, then workflowMeta should return minimal
    // coordinates of them, subtracting borders
    workflowMeta.addNote(notePadMeta);
    Point transformPoint = workflowMeta.getMinimum();
    assertEquals(notePadMetaPoint.x - WorkflowMeta.BORDER_INDENT, transformPoint.x);
    assertEquals(notePadMetaPoint.y - WorkflowMeta.BORDER_INDENT, transformPoint.y);
}
Also used : ActionMeta(org.apache.hop.workflow.action.ActionMeta) Point(org.apache.hop.core.gui.Point) NotePadMeta(org.apache.hop.core.NotePadMeta) Test(org.junit.Test)

Example 23 with ActionMeta

use of org.apache.hop.workflow.action.ActionMeta in project hop by apache.

the class WorkflowMetaTest method testPath.

private boolean testPath(String branch) {
    ActionDummy je1 = new ActionDummy();
    je1.setName("je1");
    ActionDummy je2 = new ActionDummy();
    je2.setName("je2");
    WorkflowHopMeta hop = new WorkflowHopMeta(new ActionMeta(je1), new ActionMeta(je2));
    workflowMeta.addWorkflowHop(hop);
    ActionDummy je3 = new ActionDummy();
    je3.setName("je3");
    hop = new WorkflowHopMeta(new ActionMeta(je1), new ActionMeta(je3));
    workflowMeta.addWorkflowHop(hop);
    ActionDummy je4 = new ActionDummy();
    je4.setName("je4");
    hop = new WorkflowHopMeta(new ActionMeta(je3), new ActionMeta(je4));
    workflowMeta.addWorkflowHop(hop);
    if (branch.equals("je1-je4")) {
        return workflowMeta.isPathExist(je1, je4);
    } else if (branch.equals("je2-je4")) {
        return workflowMeta.isPathExist(je2, je4);
    } else {
        return false;
    }
}
Also used : ActionDummy(org.apache.hop.workflow.actions.dummy.ActionDummy) ActionMeta(org.apache.hop.workflow.action.ActionMeta)

Example 24 with ActionMeta

use of org.apache.hop.workflow.action.ActionMeta in project hop by apache.

the class WorkflowMetaTest method testAddRemoveJobEntryCopySetUnsetParent.

@Test
public void testAddRemoveJobEntryCopySetUnsetParent() throws Exception {
    ActionMeta actionCopy = mock(ActionMeta.class);
    workflowMeta.addAction(actionCopy);
    workflowMeta.removeAction(0);
    verify(actionCopy, times(1)).setParentWorkflowMeta(workflowMeta);
    verify(actionCopy, times(1)).setParentWorkflowMeta(null);
}
Also used : ActionMeta(org.apache.hop.workflow.action.ActionMeta) Test(org.junit.Test)

Example 25 with ActionMeta

use of org.apache.hop.workflow.action.ActionMeta in project hop by apache.

the class WorkflowActionColumnsExistTest method setUp.

@Before
public void setUp() {
    IWorkflowEngine<WorkflowMeta> parentWorkflow = new LocalWorkflowEngine(new WorkflowMeta());
    action = spy(new ActionColumnsExist(""));
    parentWorkflow.getWorkflowMeta().addAction(new ActionMeta(action));
    parentWorkflow.setStopped(false);
    action.setParentWorkflow(parentWorkflow);
    parentWorkflow.setLogLevel(LogLevel.NOTHING);
    DatabaseMeta dbMeta = mock(DatabaseMeta.class);
    action.setDatabase(dbMeta);
    db = spy(new Database(action, action, dbMeta));
    action.setParentWorkflow(parentWorkflow);
    action.setTablename(TABLENAME);
    action.setArguments(COLUMNS);
    action.setSchemaname(SCHEMANAME);
}
Also used : ActionMeta(org.apache.hop.workflow.action.ActionMeta) Database(org.apache.hop.core.database.Database) LocalWorkflowEngine(org.apache.hop.workflow.engines.local.LocalWorkflowEngine) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta)

Aggregations

ActionMeta (org.apache.hop.workflow.action.ActionMeta)92 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)34 Point (org.apache.hop.core.gui.Point)28 HopException (org.apache.hop.core.exception.HopException)23 WorkflowMeta (org.apache.hop.workflow.WorkflowMeta)21 IAction (org.apache.hop.workflow.action.IAction)12 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)11 GuiContextAction (org.apache.hop.core.action.GuiContextAction)9 NotePadMeta (org.apache.hop.core.NotePadMeta)8 Test (org.junit.Test)7 WorkflowHopMeta (org.apache.hop.workflow.WorkflowHopMeta)6 IVariables (org.apache.hop.core.variables.IVariables)5 IHopMetadataProvider (org.apache.hop.metadata.api.IHopMetadataProvider)5 EnterSelectionDialog (org.apache.hop.ui.core.dialog.EnterSelectionDialog)5 HopGui (org.apache.hop.ui.hopgui.HopGui)5 LocalWorkflowEngine (org.apache.hop.workflow.engines.local.LocalWorkflowEngine)5 ArrayList (java.util.ArrayList)4 ExtensionPoint (org.apache.hop.core.extension.ExtensionPoint)4 IExtensionPoint (org.apache.hop.core.extension.IExtensionPoint)4 HashMap (java.util.HashMap)3