Search in sources :

Example 1 with AutomatedTestResults

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

the class AutomatedTestView method handleSelectionChanged.

public void handleSelectionChanged(IStructuredSelection selection) {
    String output = "";
    if (selection.size() == 1 && selection.getFirstElement() instanceof WorkflowElement) {
        selectedItem = (WorkflowElement) selection.getFirstElement();
        if (selectedItem instanceof AutomatedTestCase) {
            AutomatedTestCase testCase = (AutomatedTestCase) selectedItem;
            output = readFile(testCase.getOutputFile()).replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
            if (testCase.isPostman() && testCase.getItemName() != null)
                output = readFile(testCase.getItemOutputFile()).replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
        } else if (selectedItem instanceof AutomatedTestResults) {
            AutomatedTestResults expectedResults = (AutomatedTestResults) selectedItem;
            output = "Results:\n-----------\n" + readFile(expectedResults.getActualResults());
        } else if (selectedItem instanceof LegacyExpectedResults) {
            LegacyExpectedResults expectedResult = (LegacyExpectedResults) selectedItem;
            output = "Results:\n-----------\n" + readFile(expectedResult.getActualResultFile());
        }
    } else {
        selectedItem = null;
    }
    outputText.setText(output);
}
Also used : LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) AutomatedTestResults(com.centurylink.mdw.plugin.designer.model.AutomatedTestResults)

Example 2 with AutomatedTestResults

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

the class AutomatedTestContentProvider method getChildren.

public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof AutomatedTestSuite) {
        AutomatedTestSuite testSuite = (AutomatedTestSuite) parentElement;
        List<WorkflowPackage> packages = new ArrayList<WorkflowPackage>();
        List<WorkflowElement> legacyTests = new ArrayList<WorkflowElement>();
        for (AutomatedTestCase testCase : testSuite.getTestCases()) {
            if (testCase.isLegacy()) {
                legacyTests.add(testCase);
            } else {
                WorkflowPackage pkg = testCase.getPackage();
                if (!packages.contains(pkg))
                    packages.add(pkg);
            }
        }
        Folder folder = null;
        if (!legacyTests.isEmpty()) {
            folder = new Folder("Legacy Tests");
            folder.setChildren(legacyTests);
            for (WorkflowElement legacyTest : legacyTests) legacyTest.setArchivedFolder(folder);
        }
        Object[] children = new Object[packages.size() + (folder == null ? 0 : 1)];
        for (int i = 0; i < packages.size(); i++) children[i] = packages.get(i);
        if (folder != null)
            children[children.length - 1] = folder;
        return children;
    } else if (parentElement instanceof WorkflowPackage) {
        WorkflowPackage pkg = (WorkflowPackage) parentElement;
        @SuppressWarnings("unchecked") AutomatedTestSuite suite = ((List<AutomatedTestSuite>) treeViewer.getInput()).get(0);
        List<AutomatedTestCase> selectedCases = new ArrayList<AutomatedTestCase>();
        List<String> testCasesStringList;
        try {
            testCasesStringList = pkg.getTestCaseStringList();
            for (AutomatedTestCase testCase : suite.getTestCases()) {
                String path = testCase.getPath();
                if (testCase.isPostman())
                    path = testCase.getItemPath();
                if (testCasesStringList.contains(path))
                    selectedCases.add(testCase);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return selectedCases.toArray();
    } else if (parentElement instanceof Folder) {
        return ((Folder) parentElement).getChildren().toArray();
    } else if (parentElement instanceof AutomatedTestCase) {
        AutomatedTestCase testCase = (AutomatedTestCase) parentElement;
        if (testCase.isLegacy()) {
            return testCase.getLegacyExpectedResults().toArray(new LegacyExpectedResults[0]);
        } else {
            AutomatedTestResults results = testCase.getExpectedResults();
            return results == null ? EMPTY_ARRAY : new Object[] { results };
        }
    } else {
        return EMPTY_ARRAY;
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) Folder(com.centurylink.mdw.plugin.designer.model.Folder) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite) AutomatedTestResults(com.centurylink.mdw.plugin.designer.model.AutomatedTestResults) LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) ArrayList(java.util.ArrayList) List(java.util.List) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 3 with AutomatedTestResults

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

the class AutomatedTestView method refreshOutputFromSelection.

private void refreshOutputFromSelection() {
    display.asyncExec(new Runnable() {

        public void run() {
            String output = "";
            if (selectedItem instanceof AutomatedTestCase) {
                AutomatedTestCase testCase = (AutomatedTestCase) selectedItem;
                output = readFile(testCase.getOutputFile()).replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
                if (testCase.isPostman() && testCase.getItemName() != null)
                    output = readFile(testCase.getItemOutputFile()).replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
            } else if (selectedItem instanceof AutomatedTestResults) {
                AutomatedTestResults expectedResults = (AutomatedTestResults) selectedItem;
                output = "Results:\n--------\n" + readFile(expectedResults.getActualResults());
            } else if (selectedItem instanceof LegacyExpectedResults) {
                LegacyExpectedResults expectedResult = (LegacyExpectedResults) selectedItem;
                output = "Results:\n--------\n" + readFile(expectedResult.getActualResultFile());
            }
            if (!outputText.getText().equals(output)) {
                outputText.setText(output);
                outputText.setSelection(outputText.getText().length());
            }
        }
    });
}
Also used : LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) AutomatedTestResults(com.centurylink.mdw.plugin.designer.model.AutomatedTestResults)

Example 4 with AutomatedTestResults

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

the class ProcessExplorerActionGroup method createCompareResultsAction.

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

        @SuppressWarnings("restriction")
        @Override
        public void run() {
            if (compareResultsApplies(getSelection())) {
                WorkflowProject project = ((WorkflowElement) getSelection().getFirstElement()).getProject();
                try {
                    project.getProjectFolder(project.getTestResultsPath(AutomatedTestCase.FUNCTION_TEST)).refreshLocal(IResource.DEPTH_INFINITE, null);
                    Object[] items = new Object[2];
                    if (getSelection().getFirstElement() instanceof AutomatedTestResults) {
                        AutomatedTestResults expectedResults = (AutomatedTestResults) getSelection().getFirstElement();
                        if (project.isFilePersist()) {
                            items[0] = project.getProjectFile(expectedResults.getVcsAssetPath());
                        } else {
                            expectedResults.openTempFile(new NullProgressMonitor());
                            items[0] = expectedResults.getTempFile(expectedResults.getTempFolder());
                        }
                        String actualResultsPath = expectedResults.getPackage().getName() + "/" + expectedResults.getName();
                        items[1] = project.getProjectFile(project.getTestResultsPath(AutomatedTestCase.FUNCTION_TEST) + "/" + actualResultsPath);
                    } else if (getSelection().getFirstElement() instanceof LegacyExpectedResults) {
                        LegacyExpectedResults expectedResult = (LegacyExpectedResults) getSelection().getFirstElement();
                        items[0] = expectedResult.getExpectedResult();
                        items[1] = expectedResult.getActualResult();
                    }
                    if (items[1] == null || !((IFile) items[1]).exists()) {
                        MessageDialog.openWarning(view.getSite().getShell(), "No Results", "Unable to locate results file: " + ((IFile) items[1]).getLocation().toString());
                        return;
                    }
                    StructuredSelection compareSelection = new StructuredSelection(items);
                    ResultsCompareAction compareAction = new ResultsCompareAction(compareSelection);
                    compareAction.run(compareSelection);
                } catch (Exception ex) {
                    PluginMessages.uiError(ex, "Compare Test Results", project);
                }
            }
        }
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "compare.results");
    action.setText("Compare Results");
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/compare.gif");
    action.setImageDescriptor(imageDesc);
    return action;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) 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) IFile(org.eclipse.core.resources.IFile) IAction(org.eclipse.jface.action.IAction) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestResults(com.centurylink.mdw.plugin.designer.model.AutomatedTestResults) PartInitException(org.eclipse.ui.PartInitException) ConnectException(java.net.ConnectException) NamingException(javax.naming.NamingException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 5 with AutomatedTestResults

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

the class ProcessExplorerActionGroup method createOpenInstanceAction.

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

        @Override
        public void run() {
            if (openInstanceApplies(getSelection())) {
                WorkflowProject project = ((WorkflowElement) getSelection().getFirstElement()).getProject();
                try {
                    Long procInstId = null;
                    if (getSelection().getFirstElement() instanceof AutomatedTestResults) {
                        AutomatedTestResults expectedResults = (AutomatedTestResults) getSelection().getFirstElement();
                        procInstId = expectedResults.getActualProcessInstanceId();
                    } else if (getSelection().getFirstElement() instanceof LegacyExpectedResults) {
                        LegacyExpectedResults expectedResult = (LegacyExpectedResults) getSelection().getFirstElement();
                        java.io.File resultsFile = expectedResult.getActualResultFile();
                        TestFile testFile = new TestFile(null, resultsFile.getPath());
                        testFile.load();
                        TestFileLine line1 = testFile.getLines().get(0);
                        procInstId = new Long(line1.getWord(3));
                    }
                    if (procInstId == null) {
                        MessageDialog.openWarning(view.getSite().getShell(), "No Results", "Unable to locate results file.");
                        return;
                    }
                    ProcessInstanceVO procInst = project.getDataAccess().getProcessInstance(procInstId);
                    Long processId = procInst.getProcessId();
                    ProcessVO procVO = project.getProcess(processId).getProcessVO();
                    if (procVO == null)
                        PluginMessages.uiError("Unable to locate process: " + processId, OPEN_PROCESS_INSTANCE, project);
                    WorkflowProcess instance = new WorkflowProcess(project, procVO);
                    instance.setProcessInstance(procInst);
                    actionHandler.open(instance);
                } catch (Exception ex) {
                    PluginMessages.uiError(ex, OPEN_PROCESS_INSTANCE, project);
                }
            }
        }
    };
    action.setText(OPEN_PROCESS_INSTANCE);
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + OPEN_PROCESS_INSTANCE);
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor(ICON_PROCESS_GIF);
    action.setImageDescriptor(imageDesc);
    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) TestFileLine(com.centurylink.mdw.designer.testing.TestFileLine) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestResults(com.centurylink.mdw.plugin.designer.model.AutomatedTestResults) PartInitException(org.eclipse.ui.PartInitException) ConnectException(java.net.ConnectException) NamingException(javax.naming.NamingException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) TestFile(com.centurylink.mdw.designer.testing.TestFile) LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) 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) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Aggregations

AutomatedTestResults (com.centurylink.mdw.plugin.designer.model.AutomatedTestResults)7 LegacyExpectedResults (com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults)7 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)6 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)4 IFile (org.eclipse.core.resources.IFile)4 Action (org.eclipse.jface.action.Action)4 IAction (org.eclipse.jface.action.IAction)4 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)4 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)3 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)2 TestFile (com.centurylink.mdw.designer.testing.TestFile)2 TestFileLine (com.centurylink.mdw.designer.testing.TestFileLine)2 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)2 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)2 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)2 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)2 IOException (java.io.IOException)2 ConnectException (java.net.ConnectException)2 RemoteException (java.rmi.RemoteException)2 NamingException (javax.naming.NamingException)2