Search in sources :

Example 16 with WorkflowPackage

use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage 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)

Example 17 with WorkflowPackage

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

the class AutomatedTestLaunchShortcut method launch.

public void launch(IEditorPart editor, String mode) {
    if (editor.getEditorInput() instanceof IFileEditorInput) {
        IFileEditorInput fileEditorInput = (IFileEditorInput) editor.getEditorInput();
        IFile file = fileEditorInput.getFile();
        WorkflowProject project = WorkflowProjectManager.getInstance().getWorkflowProject(file.getProject());
        WorkflowPackage pkg = project.getPackage((IFolder) file.getParent());
        try {
            performLaunch(pkg.getAsset(file), mode);
        } catch (CoreException | JSONException ex) {
            PluginMessages.uiError(ex, "Test Exec", project);
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) IFileEditorInput(org.eclipse.ui.IFileEditorInput) JSONException(org.json.JSONException) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject)

Example 18 with WorkflowPackage

use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage 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 19 with WorkflowPackage

use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage 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 20 with WorkflowPackage

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

the class Exporter method exportPackages.

public String exportPackages(List<WorkflowPackage> packages, boolean exportJson, boolean includeTaskTemplates, ProgressMonitor progressMonitor) throws DataAccessException, ActionCancelledException, JSONException, XmlException {
    String export = null;
    progressMonitor.progress(10);
    int schemaVersion = designerDataAccess.getDatabaseSchemaVersion();
    List<PackageVO> pkgVos = new ArrayList<>();
    for (WorkflowPackage pv : packages) pkgVos.add(pv.getPackageVO());
    export = designerDataAccess.exportPackages(pkgVos, schemaVersion, exportJson, includeTaskTemplates, progressMonitor);
    for (WorkflowPackage pv : packages) pv.setExported(true);
    return export;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ArrayList(java.util.ArrayList)

Aggregations

WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)85 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)31 ArrayList (java.util.ArrayList)27 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)25 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)21 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)17 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)11 GridData (org.eclipse.swt.layout.GridData)11 CoreException (org.eclipse.core.runtime.CoreException)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)8 List (java.util.List)8 Label (org.eclipse.swt.widgets.Label)8 JSONException (org.json.JSONException)8 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)7 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)7 Folder (com.centurylink.mdw.plugin.designer.model.Folder)7 IOException (java.io.IOException)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)7