Search in sources :

Example 6 with AutomatedTestSuite

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

the class AutomatedTestView method handleRerunSelection.

public void handleRerunSelection() {
    if (selectedItem != null) {
        if (selectedItem instanceof AutomatedTestSuite) {
            handleRerun();
        } else if (selectedItem instanceof WorkflowPackage) {
            WorkflowPackage pkg = (WorkflowPackage) selectedItem;
            List<AutomatedTestCase> cases = new ArrayList<AutomatedTestCase>();
            List<String> testCasesStringList;
            try {
                testCasesStringList = pkg.getTestCaseStringList();
                for (AutomatedTestCase testCase : testSuite.getTestCases()) {
                    String path = testCase.getPath();
                    if (testCase.isPostman())
                        path = testCase.getItemPath();
                    if (testCasesStringList.contains(path))
                        cases.add(testCase);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
            runTestCases(cases);
        } else if (selectedItem instanceof AutomatedTestCase) {
            AutomatedTestCase testCase = (AutomatedTestCase) selectedItem;
            runTestCase(testCase);
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) JSONException(org.json.JSONException) List(java.util.List) ArrayList(java.util.ArrayList) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)

Example 7 with AutomatedTestSuite

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

the class ProcessExplorerContentProvider method getChildren.

public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof WorkflowProject) {
        final WorkflowProject workflowProject = (WorkflowProject) parentElement;
        if (!workflowProject.isLoaded()) {
            try {
                IRunnableWithProgress loader = new IRunnableWithProgress() {

                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        ProgressMonitor progressMonitor = new SwtProgressMonitor(monitor);
                        progressMonitor.start("Loading " + workflowProject.getLabel());
                        progressMonitor.progress(5);
                        try {
                            workflowProject.initialize(progressMonitor);
                            if (workflowProject.getDataAccess() != null) {
                                workflowProject.getTopLevelUserVisiblePackages(progressMonitor);
                                workflowProject.getArchivedUserVisiblePackagesFolder(progressMonitor);
                                progressMonitor.done();
                            }
                        } catch (Exception ex) {
                            throw new InvocationTargetException(ex);
                        }
                    }
                };
                ProgressMonitorDialog progMonDlg = new MdwProgressMonitorDialog(MdwPlugin.getShell());
                progMonDlg.run(true, false, loader);
            } catch (InvocationTargetException itx) {
                if (itx.getCause() instanceof DataUnavailableException) {
                    PluginMessages.log(itx);
                    MessageDialog.openWarning(MdwPlugin.getShell(), LOAD_WF_PROJECT, itx.getCause().getMessage());
                } else if (itx.getCause() instanceof DataAccessOfflineException) {
                    PluginMessages.log(itx);
                    MessageDialog.openError(MdwPlugin.getShell(), LOAD_WF_PROJECT, itx.getCause().getMessage());
                    return new WorkflowPackage[0];
                } else {
                    PluginMessages.uiError(itx, LOAD_WF_PROJECT, workflowProject);
                    return new WorkflowPackage[0];
                }
            } catch (Exception ex) {
                PluginMessages.uiError(ex, LOAD_WF_PROJECT, workflowProject);
                return new WorkflowPackage[0];
            }
        }
        if (workflowProject.getDataAccess() == null)
            return new WorkflowPackage[0];
        List<WorkflowPackage> topLevelPackages = workflowProject.getTopLevelUserVisiblePackages();
        Folder archivedPackageFolder = workflowProject.getArchivedUserVisiblePackagesFolder();
        int size = topLevelPackages.size();
        boolean showArchived = isShowArchivedItems(workflowProject);
        if (showArchived)
            size++;
        AutomatedTestSuite testSuite = workflowProject.getLegacyTestSuite();
        if (testSuite != null && !testSuite.isEmpty())
            size++;
        Object[] objects = new Object[size];
        for (int i = 0; i < topLevelPackages.size(); i++) objects[i] = topLevelPackages.get(i);
        int cur = topLevelPackages.size();
        if (showArchived) {
            objects[cur] = archivedPackageFolder;
            cur++;
        }
        if (testSuite != null && !testSuite.isEmpty())
            objects[cur] = testSuite;
        return objects;
    } else if (parentElement instanceof WorkflowPackage) {
        WorkflowPackage packageVersion = (WorkflowPackage) parentElement;
        if (packageVersion.isArchived() && packageVersion.hasDescendantPackageVersions()) {
            return packageVersion.getDescendantPackageVersions().toArray(new WorkflowPackage[0]);
        } else {
            List<WorkflowElement> elements = new ArrayList<>();
            IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
            if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_PROCESSES_IN_PEX))
                elements.addAll(packageVersion.getProcesses());
            if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_WORKFLOW_ASSETS_IN_PEX))
                elements.addAll(packageVersion.getAssets());
            if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_EVENT_HANDLERS_IN_PEX))
                elements.addAll(packageVersion.getExternalEvents());
            if (prefsStore.getBoolean(PreferenceConstants.PREFS_SHOW_ACTIVITY_IMPLEMENTORS_IN_PEX))
                elements.addAll(packageVersion.getActivityImpls());
            if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_TASK_TEMPLATES_IN_PEX))
                elements.addAll(packageVersion.getTaskTemplates());
            elements.addAll(packageVersion.getChildFolders());
            if (isSortPackageContentsAtoZ()) {
                Collections.sort(elements, new Comparator<WorkflowElement>() {

                    public int compare(WorkflowElement e1, WorkflowElement e2) {
                        return e1.getLabel().compareToIgnoreCase(e2.getLabel());
                    }
                });
            }
            return elements.toArray(new Object[0]);
        }
    } else if (parentElement instanceof WorkflowProcess) {
        WorkflowProcess processVersion = (WorkflowProcess) parentElement;
        if (processVersion.hasDescendantProcessVersions()) {
            return processVersion.getDescendantProcessVersions().toArray(new WorkflowProcess[0]);
        } else {
            return emptyARRAY;
        }
    } else if (parentElement instanceof Folder) {
        Folder folder = (Folder) parentElement;
        return folder.getChildren().toArray(new WorkflowElement[0]);
    } else if (parentElement instanceof AutomatedTestSuite) {
        AutomatedTestSuite testSuite = (AutomatedTestSuite) parentElement;
        return testSuite.getTestCases().toArray(new AutomatedTestCase[0]);
    } else if (parentElement instanceof AutomatedTestCase) {
        AutomatedTestCase testCase = (AutomatedTestCase) parentElement;
        if (!testCase.isLegacy())
            return emptyARRAY;
        List<LegacyExpectedResults> expectedResults = testCase.getLegacyExpectedResults();
        List<File> files = testCase.getFiles();
        Object[] objects = new Object[expectedResults.size() + files.size()];
        for (int i = 0; i < expectedResults.size(); i++) objects[i] = expectedResults.get(i);
        for (int i = expectedResults.size(); i < objects.length; i++) objects[i] = files.get(i - expectedResults.size());
        return objects;
    } else {
        return emptyARRAY;
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) SwtProgressMonitor(com.centurylink.mdw.plugin.designer.SwtProgressMonitor) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) Folder(com.centurylink.mdw.plugin.designer.model.Folder) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Comparator(java.util.Comparator) ArrayList(java.util.ArrayList) List(java.util.List) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) InvocationTargetException(java.lang.reflect.InvocationTargetException) DataUnavailableException(com.centurylink.mdw.designer.DataUnavailableException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProgressMonitor(com.centurylink.mdw.common.utilities.timer.ProgressMonitor) SwtProgressMonitor(com.centurylink.mdw.plugin.designer.SwtProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DataUnavailableException(com.centurylink.mdw.designer.DataUnavailableException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 8 with AutomatedTestSuite

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

the class WorkflowProject method refreshLegacyTestSuite.

public void refreshLegacyTestSuite() {
    legacyTestSuite = null;
    AutomatedTestSuite testSuite = getLegacyTestSuite();
    testSuite.fireElementChangeEvent(testSuite, ChangeType.SETTINGS_CHANGE, null);
    try {
        getOldTestCasesFolder().getParent().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    } catch (CoreException ex) {
        PluginMessages.log(ex);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)

Example 9 with AutomatedTestSuite

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

the class WorkflowProject method findLegacyTests.

public AutomatedTestSuite findLegacyTests() {
    AutomatedTestSuite testSuite = new AutomatedTestSuite(this);
    if (testSuite.readLegacyCases()) {
        for (AutomatedTestCase testCase : testSuite.getTestCases()) {
            testCase.addElementChangeListener(this);
            for (LegacyExpectedResults expectedResult : testCase.getLegacyExpectedResults()) expectedResult.addElementChangeListener(this);
            for (com.centurylink.mdw.plugin.designer.model.File file : testCase.getFiles()) file.addElementChangeListener(this);
        }
    }
    testSuite.setLabel("Legacy Tests");
    testSuite.setIcon("folder.gif");
    return testSuite;
}
Also used : LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)

Example 10 with AutomatedTestSuite

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

the class AutomatedTestLaunchConfiguration method launch.

public void launch(ILaunchConfiguration launchConfig, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(launchConfig.getAttribute(WORKFLOW_PROJECT, ""));
    boolean isLoadTest = launchConfig.getAttribute(IS_LOAD_TEST, false);
    String attrPrefix = isLoadTest ? AutomatedTestCase.LOAD_TEST : AutomatedTestCase.FUNCTION_TEST;
    String resultsPath = launchConfig.getAttribute(attrPrefix + "_" + RESULTS_PATH, "");
    if (resultsPath.isEmpty())
        resultsPath = WorkflowProject.DEFAULT_TEST_RESULTS_PATH;
    workflowProject.setTestResultsPath(attrPrefix, resultsPath);
    int threadCount = launchConfig.getAttribute(attrPrefix + "_" + THREAD_COUNT, 5);
    int runCount = launchConfig.getAttribute(attrPrefix + "_" + RUN_COUNT, 100);
    int threadInterval = launchConfig.getAttribute(attrPrefix + "_" + THREAD_INTERVAL, 2);
    int runInterval = launchConfig.getAttribute(attrPrefix + "_" + RUN_INTERVAL, 2);
    boolean verbose = launchConfig.getAttribute(attrPrefix + "_" + VERBOSE, true);
    boolean stubbing = launchConfig.getAttribute(attrPrefix + "_" + STUBBING, false);
    boolean singleServer = launchConfig.getAttribute(attrPrefix + "_" + SINGLE_SERVER, true);
    boolean createReplace = launchConfig.getAttribute(attrPrefix + "_" + CREATE_REPLACE_RESULTS, false);
    boolean postmanTestsExists = false;
    HashMap<String, Boolean> testCaseOrder = null;
    testSuite = new AutomatedTestSuite(workflowProject);
    testSuite.setLoadTest(isLoadTest);
    testSuite.setThreadCount(threadCount);
    testSuite.setRunCount(runCount);
    if (isLoadTest)
        testSuite.setThreadInterval(runInterval);
    else
        testSuite.setThreadInterval(threadInterval);
    testSuite.setVerbose(verbose);
    testSuite.setStubbing(stubbing);
    testSuite.setSingleServer(singleServer);
    testSuite.setCreateReplaceResults(createReplace);
    List<AutomatedTestCase> testCases = new ArrayList<>();
    List<String> testCasesStr = launchConfig.getAttribute(attrPrefix + "_" + TEST_CASES, new ArrayList<String>());
    for (String testCaseStr : testCasesStr) {
        AutomatedTestCase autoTestCase;
        if (testCaseStr.startsWith("Legacy/"))
            autoTestCase = workflowProject.getLegacyTestSuite().getTestCase(testCaseStr);
        else if (testCaseStr.indexOf("postman") > -1) {
            String[] pathArray = testCaseStr.split("/");
            String method = pathArray[2];
            AutomatedTestCase cloneTestCase = (AutomatedTestCase) workflowProject.getAsset(pathArray[0] + "/" + pathArray[1]);
            autoTestCase = new AutomatedTestCase(cloneTestCase);
            autoTestCase.setId(cloneTestCase.getId());
            try {
                StringBuilder itemName = new StringBuilder(pathArray[3]);
                for (int i = 4; i < pathArray.length; i++) itemName = itemName.append("/" + pathArray[i]);
                autoTestCase.setItemName(itemName.toString());
                autoTestCase.setMethod(method);
                autoTestCase.getTestCase().resetItems();
                autoTestCase.getTestCase().addItem(cloneTestCase.getItem(itemName.toString(), method));
                postmanTestsExists = true;
            } catch (Exception e) {
                PluginMessages.log(e);
            }
        } else
            autoTestCase = (AutomatedTestCase) workflowProject.getAsset(testCaseStr);
        autoTestCase.setTestSuite(testSuite);
        if (!autoTestCase.getResultsDir().exists())
            autoTestCase.getResultsDir().mkdirs();
        testCases.add(autoTestCase);
    }
    testSuite.setTestCases(testCases);
    if (postmanTestsExists) {
        testCaseOrder = new HashMap<>();
        List<AutomatedTestCase> cases = new ArrayList<>();
        for (AutomatedTestCase testCase : testSuite.getTestCases()) {
            if (!testCase.isPostman())
                cases.add(testCase);
            else {
                if (testCaseOrder.get(testCase.getName()) == null) {
                    List<AutomatedTestCase> postmanCases = testSuite.getPostmanTestCasesByName(testCase.getName());
                    testCaseOrder.put(testCase.getName(), true);
                    AutomatedTestCase postmanCase = testSuite.getPostmanTestCaseByMethod(postmanCases, "GET");
                    if (postmanCase != null)
                        cases.add(postmanCase);
                    postmanCase = testSuite.getPostmanTestCaseByMethod(postmanCases, "DELETE");
                    if (postmanCase != null)
                        cases.add(postmanCase);
                    postmanCase = testSuite.getPostmanTestCaseByMethod(postmanCases, "POST");
                    if (postmanCase != null)
                        cases.add(postmanCase);
                    postmanCase = testSuite.getPostmanTestCaseByMethod(postmanCases, "PUT");
                    if (postmanCase != null)
                        cases.add(postmanCase);
                }
            }
        }
        testSuite.setTestCases(cases);
    }
    if (isLoadTest) {
        Map<String, String> testCaseCounts = launchConfig.getAttribute(attrPrefix + "_" + TESTCASE_COUNTS_MAP, new HashMap<String, String>());
        for (Map.Entry<String, String> entry : testCaseCounts.entrySet()) {
            int count = Integer.parseInt(entry.getValue());
            testSuite.getTestCase(entry.getKey()).setRunCount(count);
        }
    }
    if (!testSuite.getResultsDir().exists())
        testSuite.getResultsDir().mkdirs();
    testSuite.setDebug(ILaunchManager.DEBUG_MODE.equals(mode));
    showResultsView();
}
Also used : ArrayList(java.util.ArrayList) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

AutomatedTestSuite (com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)16 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)14 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)7 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)7 ArrayList (java.util.ArrayList)7 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)6 List (java.util.List)4 PartInitException (org.eclipse.ui.PartInitException)4 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)3 Folder (com.centurylink.mdw.plugin.designer.model.Folder)3 LegacyExpectedResults (com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults)3 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)3 Action (org.eclipse.jface.action.Action)3 IAction (org.eclipse.jface.action.IAction)3 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)3 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)3 TestFile (com.centurylink.mdw.designer.testing.TestFile)2 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)2 File (com.centurylink.mdw.plugin.designer.model.File)2 JarFile (com.centurylink.mdw.plugin.designer.model.JarFile)2