Search in sources :

Example 1 with AutomatedTestCase

use of com.centurylink.mdw.plugin.designer.model.AutomatedTestCase in project mdw-designer by CenturyLinkCloud.

the class WorkflowElementActionHandler method open.

public boolean open(WorkflowElement element) {
    if (element instanceof WorkflowProcess) {
        WorkflowProcess processVersion = (WorkflowProcess) element;
        try {
            ProcessEditor processEditor = (ProcessEditor) getPage().openEditor(processVersion, "mdw.editors.process");
            showPropertiesView();
            processEditor.setFocus();
        } catch (PartInitException ex) {
            PluginMessages.uiError(getShell(), ex, "Open Process", processVersion.getProject());
        }
    } else if (element instanceof AutomatedTestCase && ((AutomatedTestCase) element).isLegacy()) {
        // open the old way instead of as workflow asset
        AutomatedTestCase testCase = (AutomatedTestCase) element;
        IFile file = testCase.getCommandsFile();
        IWorkbenchPage activePage = MdwPlugin.getActivePage();
        try {
            IDE.openEditor(activePage, file, true);
        } catch (PartInitException ex) {
            PluginMessages.uiError(ex, "Open Test Case", testCase.getProject());
        }
    } else if (element instanceof WorkflowAsset) {
        WorkflowAsset asset = (WorkflowAsset) element;
        asset.openFile(new NullProgressMonitor());
    } else if (element instanceof LegacyExpectedResults) {
        LegacyExpectedResults expectedResult = (LegacyExpectedResults) element;
        IFile file = expectedResult.getExpectedResult();
        IWorkbenchPage activePage = MdwPlugin.getActivePage();
        try {
            IDE.openEditor(activePage, file, true);
        } catch (PartInitException ex) {
            PluginMessages.uiError(ex, "Open Expected Result", expectedResult.getProject());
        }
    } else if (element instanceof com.centurylink.mdw.plugin.designer.model.File) {
        com.centurylink.mdw.plugin.designer.model.File file = (com.centurylink.mdw.plugin.designer.model.File) element;
        IFile workspaceFile = file.getWorkspaceFile();
        IWorkbenchPage activePage = MdwPlugin.getActivePage();
        try {
            IDE.openEditor(activePage, workspaceFile, true);
        } catch (PartInitException ex) {
            PluginMessages.uiError(ex, "Open File", file.getProject());
        }
    } else if (element instanceof ExternalEvent) {
        ExternalEvent event = (ExternalEvent) element;
        if (event.getProject().checkRequiredVersion(6, 0)) {
            IFile file = event.getProject().getAssetFolder().getFolder(event.getPackage().getName().replace('.', '/')).getFile(event.getName() + EVT_HANDLER_FILE_EXTENSION);
            IWorkbenchPage activePage = MdwPlugin.getActivePage();
            try {
                IDE.openEditor(activePage, file, true);
            } catch (PartInitException ex) {
                PluginMessages.uiError(ex, "Open File", event.getProject());
            }
        }
    } else {
        return false;
    }
    return true;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) PartInitException(org.eclipse.ui.PartInitException) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) IFile(org.eclipse.core.resources.IFile) File(java.io.File) JarFile(com.centurylink.mdw.plugin.designer.model.JarFile) ProcessEditor(com.centurylink.mdw.plugin.designer.editors.ProcessEditor)

Example 2 with AutomatedTestCase

use of com.centurylink.mdw.plugin.designer.model.AutomatedTestCase in project mdw-designer by CenturyLinkCloud.

the class WorkflowElementActionHandler method refresh.

public void refresh(WorkflowElement element) {
    if (element instanceof WorkflowProject) {
        final WorkflowProject workflowProject = (WorkflowProject) element;
        workflowProject.clear();
        workflowProject.fireElementChangeEvent(workflowProject, ChangeType.SETTINGS_CHANGE, null);
        BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

            public void run() {
                if (!workflowProject.isFilePersist())
                    syncOpenEditors(workflowProject);
            }
        });
    } else if (element instanceof AutomatedTestSuite) {
        AutomatedTestSuite testSuite = (AutomatedTestSuite) element;
        testSuite.readLegacyCases();
        testSuite.fireElementChangeEvent(testSuite, ChangeType.SETTINGS_CHANGE, null);
    } else if (element instanceof AutomatedTestCase) {
        AutomatedTestCase testCase = (AutomatedTestCase) element;
        testCase.setTestCase(testCase.getTestCase());
        testCase.fireElementChangeEvent(testCase, ChangeType.SETTINGS_CHANGE, null);
    }
}
Also used : WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)

Example 3 with AutomatedTestCase

use of com.centurylink.mdw.plugin.designer.model.AutomatedTestCase in project mdw-designer by CenturyLinkCloud.

the class ProcessExplorerActionGroup method createDebugAction.

private IAction createDebugAction() {
    IAction action = new Action() {

        @Override
        public void run() {
            if (!debugApplies(getSelection()))
                return;
            view.setFocus();
            Object element = getSelection().getFirstElement();
            if (element instanceof AutomatedTestSuite || element instanceof AutomatedTestCase)
                actionHandler.debugTest(getSelection());
            else
                actionHandler.debug((WorkflowElement) element);
        }
    };
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/debug.gif");
    action.setImageDescriptor(imageDesc);
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "debug");
    action.setText("Debug...");
    return action;
}
Also used : WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) IAction(org.eclipse.jface.action.IAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 4 with AutomatedTestCase

use of com.centurylink.mdw.plugin.designer.model.AutomatedTestCase in project mdw-designer by CenturyLinkCloud.

the class ProcessExplorerActionGroup method createRunFromStartPageAction.

private IAction createRunFromStartPageAction() {
    IAction action = new Action() {

        @Override
        public void run() {
            if (!runFromPageApplies(getSelection()))
                return;
            view.setFocus();
            Object element = getSelection().getFirstElement();
            if (element instanceof AutomatedTestSuite || element instanceof AutomatedTestCase)
                actionHandler.test(getSelection());
            else if (element instanceof File && ((File) element).getParent() instanceof AutomatedTestCase && TestCase.LEGACY_TEST_CASE_FILENAMES.values().contains(((File) element).getName()))
                actionHandler.test(getSelection());
            else
                actionHandler.runFromPage((WorkflowElement) element);
        }
    };
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor(ICON_RUN_GIF);
    action.setImageDescriptor(imageDesc);
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "run.start.page");
    action.setText("Run Start Page...");
    return action;
}
Also used : WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) IAction(org.eclipse.jface.action.IAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) IFile(org.eclipse.core.resources.IFile) TestFile(com.centurylink.mdw.designer.testing.TestFile) File(com.centurylink.mdw.plugin.designer.model.File) JarFile(com.centurylink.mdw.plugin.designer.model.JarFile) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)

Example 5 with AutomatedTestCase

use of com.centurylink.mdw.plugin.designer.model.AutomatedTestCase in project mdw-designer by CenturyLinkCloud.

the class AutomatedTestLaunchShortcut method createLaunchConfiguration.

protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(WorkflowElement element, boolean debug) throws CoreException, JSONException {
    String testName = null;
    List<String> testCases = new ArrayList<>();
    WorkflowProject workflowProject = element.getProject();
    WorkflowPackage workflowPackage = null;
    boolean isLegacyLaunch = false;
    if (element instanceof WorkflowProject) {
        testName = workflowProject.getName();
        testCases = workflowProject.getTestCaseStringList();
    } else if (element instanceof WorkflowPackage) {
        workflowPackage = (WorkflowPackage) element;
        testName = workflowPackage.getName();
        testCases = workflowPackage.getTestCaseStringList();
    } else if (element instanceof AutomatedTestCase) {
        AutomatedTestCase testCase = (AutomatedTestCase) element;
        if (testCase.isLegacy()) {
            testName = workflowProject.getName() + LEGACY;
            isLegacyLaunch = true;
        } else {
            workflowPackage = testCase.getPackage();
            testName = workflowPackage.getName();
        }
        testCases = new ArrayList<>();
        if (testCase.isPostman() && testCase.getItems() != null && workflowPackage != null) {
            testCases.addAll(workflowPackage.getTestCaseItems(testCase));
        } else
            testCases.add(testCase.getPath());
    } else if (element instanceof AutomatedTestSuite) {
        testName = workflowProject.getName() + LEGACY;
        isLegacyLaunch = true;
        testCases = ((AutomatedTestSuite) element).getTestCaseStringList();
    }
    return createLaunchConfiguration(workflowProject, workflowPackage, isLegacyLaunch, testName, testCases, debug);
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ArrayList(java.util.ArrayList) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)

Aggregations

AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)27 AutomatedTestSuite (com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)14 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)11 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)11 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)10 ArrayList (java.util.ArrayList)10 LegacyExpectedResults (com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults)8 JSONException (org.json.JSONException)7 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)6 File (java.io.File)6 IFile (org.eclipse.core.resources.IFile)6 PartInitException (org.eclipse.ui.PartInitException)6 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)4 JarFile (com.centurylink.mdw.plugin.designer.model.JarFile)4 IOException (java.io.IOException)4 CoreException (org.eclipse.core.runtime.CoreException)4 AutomatedTestResults (com.centurylink.mdw.plugin.designer.model.AutomatedTestResults)3 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)3 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)3 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)2