Search in sources :

Example 31 with WorkflowProject

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

the class AutomatedTestLaunchShortcut method launch.

public void launch(ISelection sel, String mode) {
    StructuredSelection selection = (StructuredSelection) sel;
    Object firstElement = selection.getFirstElement();
    WorkflowProject project = null;
    try {
        if (firstElement instanceof WorkflowElement) {
            WorkflowElement element = (WorkflowElement) firstElement;
            project = element.getProject();
            boolean prevEnablement = disableBuildBeforeLaunch();
            if (selection.size() > 1 || element instanceof AutomatedTestCase) {
                List<AutomatedTestCase> testCases = new ArrayList<>();
                for (Object obj : selection.toArray()) testCases.add((AutomatedTestCase) obj);
                performLaunch(testCases, mode);
            } else {
                performLaunch(element, mode);
            }
            setBuildBeforeLaunch(prevEnablement);
        } else {
            ResourceWrapper resourceWrapper = new ResourceWrapper(firstElement);
            IFile firstFile = resourceWrapper.getFile();
            if (firstFile != null) {
                project = WorkflowProjectManager.getInstance().getWorkflowProject(firstFile.getProject());
                // test case file(s)
                List<AutomatedTestCase> testCases = new ArrayList<>();
                Object[] objArr = selection.toArray();
                if (objArr.length == 1) {
                    WorkflowPackage pkg = project.getPackage((IFolder) firstFile.getParent());
                    testCases.add((AutomatedTestCase) pkg.getAsset(firstFile));
                } else {
                    for (Object obj : objArr) {
                        IFile file = (IFile) obj;
                        WorkflowPackage pkg = project.getPackage((IFolder) file.getParent());
                        testCases.add((AutomatedTestCase) pkg.getAsset(file));
                    }
                }
                performLaunch(testCases, mode);
            } else {
                IFolder folder = resourceWrapper.getFolder();
                if (folder != null) {
                    project = WorkflowProjectManager.getInstance().getWorkflowProject(folder.getProject());
                    performLaunch(project.getPackage(folder), mode);
                } else {
                    IProject proj = resourceWrapper.getProject();
                    project = WorkflowProjectManager.getInstance().getWorkflowProject(proj);
                    performLaunch(project, mode);
                }
            }
        }
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Test Exec", project);
    }
}
Also used : ResourceWrapper(com.centurylink.mdw.plugin.ResourceWrapper) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) IFile(org.eclipse.core.resources.IFile) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ArrayList(java.util.ArrayList) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) IFolder(org.eclipse.core.resources.IFolder)

Example 32 with WorkflowProject

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

the class AutomatedTestLaunchShortcut method performLaunch.

/**
 * All test cases must be in the same package or legacy suite.
 */
private void performLaunch(List<AutomatedTestCase> cases, String mode) throws CoreException, JSONException {
    AutomatedTestCase firstCase = cases.get(0);
    WorkflowProject workflowProject = firstCase.getProject();
    WorkflowPackage workflowPackage = firstCase.getPackage();
    boolean isLegacyLaunch = firstCase.isLegacy();
    String testName;
    if (isLegacyLaunch)
        testName = workflowProject.getName() + LEGACY;
    else
        testName = workflowPackage.getName();
    List<String> testCases = new ArrayList<>();
    for (AutomatedTestCase testCase : cases) {
        if (testCase.getItems() != null) {
            testCases.addAll(workflowPackage.getTestCaseItems(testCase));
        } else if (testCase.isPostman())
            testCases.add(testCase.getItemPath());
        else
            testCases.add(testCase.getPath());
    }
    ILaunchConfigurationWorkingCopy workingCopy = createLaunchConfiguration(workflowProject, workflowPackage, isLegacyLaunch, testName, testCases, ILaunchManager.DEBUG_MODE.equals(mode));
    ILaunchConfiguration config = findExistingLaunchConfiguration(workingCopy);
    if (config == null) {
        // no existing found - create a new one
        config = workingCopy.doSave();
    } else {
        workingCopy = config.getWorkingCopy();
        String prefix;
        if (workingCopy.getAttribute(AutomatedTestLaunchConfiguration.IS_LOAD_TEST, false))
            prefix = AutomatedTestCase.LOAD_TEST;
        else
            prefix = AutomatedTestCase.FUNCTION_TEST;
        workingCopy.setAttribute(prefix + "_" + AutomatedTestLaunchConfiguration.TEST_CASES, testCases);
        config = workingCopy.doSave();
    }
    IStructuredSelection selection = new StructuredSelection(config);
    if (ILaunchManager.DEBUG_MODE.equals(mode)) {
        DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), selection, DEBUG_GROUP_ID);
    } else {
        DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), selection, GROUP_ID);
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 33 with WorkflowProject

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

the class CucumberLaunchShortcut method launch.

public void launch(ISelection sel, String mode) {
    StructuredSelection selection = (StructuredSelection) sel;
    Object firstElement = selection.getFirstElement();
    ResourceWrapper resourceWrapper = new ResourceWrapper(firstElement);
    try {
        List<CucumberTest> tests = new ArrayList<>();
        IFile file = resourceWrapper.getFile();
        if (file != null) {
            // launch gherkin feature test(s)
            for (Object obj : selection.toArray()) {
                ResourceWrapper fileWrapper = new ResourceWrapper(obj);
                tests.add(new CucumberTest(fileWrapper.getOwningProject(), fileWrapper.getFile()));
            }
            performLaunch(tests, new ResourceWrapper(file.getParent()).getFolder());
        } else {
            // package folder
            IFolder folder = resourceWrapper.getFolder();
            if (folder != null) {
                CucumberTest.findTests(folder, tests);
                performLaunch(tests, folder);
            } else {
                IProject proj = resourceWrapper.getProject();
                tests.addAll(CucumberTest.getTests(proj));
                performLaunch(tests, null);
            }
        }
    } catch (Exception ex) {
        WorkflowProject proj = firstElement instanceof WorkflowElement ? ((WorkflowElement) firstElement).getProject() : null;
        PluginMessages.uiError(ex, "Test Exec", proj);
    }
}
Also used : ResourceWrapper(com.centurylink.mdw.plugin.ResourceWrapper) CucumberTest(com.centurylink.mdw.plugin.designer.model.CucumberTest) IFile(org.eclipse.core.resources.IFile) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ArrayList(java.util.ArrayList) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) IFolder(org.eclipse.core.resources.IFolder)

Example 34 with WorkflowProject

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

the class ResourceWrapper method getOwningWorkflowProject.

public WorkflowProject getOwningWorkflowProject() throws JavaModelException {
    WorkflowProject owningWorkflowProject = null;
    IProject owningProject = getOwningProject();
    if (owningProject != null)
        owningWorkflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(owningProject);
    return owningWorkflowProject;
}
Also used : WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IProject(org.eclipse.core.resources.IProject)

Example 35 with WorkflowProject

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

the class MdwHubAction method populateMenu.

/**
 * populates the plugin action menu (the mdwhub icon) with its items
 */
public void populateMenu(Menu menu) {
    WorkflowProjectManager wfProjectMgr = WorkflowProjectManager.getInstance();
    List<WorkflowProject> workflowProjects = wfProjectMgr.getWorkflowProjects();
    if (workflowProjects.isEmpty()) {
        MenuItem item = new MenuItem(menu, SWT.NONE);
        item.setText("(No Projects)");
        item.setImage(MdwPlugin.getImageDescriptor("icons/wait.gif").createImage());
        item.setEnabled(false);
    } else {
        for (final WorkflowProject workflowProject : workflowProjects) {
            if (workflowProject.checkRequiredVersion(5, 5)) {
                String projName = workflowProject.isFrameworkProject() ? "MDWFramework" : workflowProject.getName();
                // MDWWeb
                MenuItem item = new MenuItem(menu, SWT.NONE);
                final WebLaunchAction launchAction = WebLaunchActions.getLaunchAction(workflowProject, WebApp.MdwHub);
                item.setText(projName + " - " + launchAction.getLabel());
                item.setImage(launchAction.getIconImage());
                item.addSelectionListener(new SelectionAdapter() {

                    public void widgetSelected(SelectionEvent e) {
                        mostRecentHubWorkflowProject = workflowProject;
                        launchAction.launch(workflowProject);
                    }
                });
            }
        }
    }
}
Also used : WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) MenuItem(org.eclipse.swt.widgets.MenuItem) WorkflowProjectManager(com.centurylink.mdw.plugin.project.WorkflowProjectManager)

Aggregations

WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)128 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)31 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)25 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)22 ArrayList (java.util.ArrayList)22 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)21 CoreException (org.eclipse.core.runtime.CoreException)19 Action (org.eclipse.jface.action.Action)19 IAction (org.eclipse.jface.action.IAction)18 IProject (org.eclipse.core.resources.IProject)17 IFile (org.eclipse.core.resources.IFile)16 PartInitException (org.eclipse.ui.PartInitException)16 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)16 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)15 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)12 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)11 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)11 IOException (java.io.IOException)10 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)9