Search in sources :

Example 6 with AutomatedTestResults

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

the class AutomatedTestActionGroup method createCompareResultsAction.

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

        @SuppressWarnings("restriction")
        public void run() {
            if (compareResultsApplies(view.getSelectedItem())) {
                WorkflowProject project = ((WorkflowElement) view.getSelectedItem()).getProject();
                try {
                    project.getProjectFolder(project.getTestResultsPath(AutomatedTestCase.FUNCTION_TEST)).refreshLocal(IResource.DEPTH_INFINITE, null);
                    Object[] items = new Object[2];
                    if (view.getSelectedItem() instanceof AutomatedTestResults) {
                        AutomatedTestResults expectedResults = (AutomatedTestResults) view.getSelectedItem();
                        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 (view.getSelectedItem() instanceof LegacyExpectedResults) {
                        LegacyExpectedResults expectedResult = (LegacyExpectedResults) view.getSelectedItem();
                        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) IAction(org.eclipse.jface.action.IAction) 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) IOException(java.io.IOException) LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 7 with AutomatedTestResults

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

the class AutomatedTestActionGroup method createOpenProcessInstanceAction.

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

        public void run() {
            if (openProcessInstanceApplies(view.getSelectedItem())) {
                WorkflowProject project = ((WorkflowElement) view.getSelectedItem()).getProject();
                try {
                    Long procInstId = null;
                    if (view.getSelectedItem() instanceof AutomatedTestResults) {
                        AutomatedTestResults expectedResults = (AutomatedTestResults) view.getSelectedItem();
                        procInstId = expectedResults.getActualProcessInstanceId();
                    } else if (view.getSelectedItem() instanceof LegacyExpectedResults) {
                        LegacyExpectedResults expectedResult = (LegacyExpectedResults) view.getSelectedItem();
                        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.setId(MdwMenuManager.MDW_MENU_PREFIX + "open.process.instance");
    action.setText("Open Process Instance");
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/process.gif");
    action.setImageDescriptor(imageDesc);
    return action;
}
Also used : IAction(org.eclipse.jface.action.IAction) 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) IOException(java.io.IOException) 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(java.io.File) 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