Search in sources :

Example 11 with AutomatedTestSuite

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

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

the class AutomatedTestView method prepForRun.

public void prepForRun() {
    locked = true;
    display = getSite().getShell().getDisplay();
    actionGroup.enableRerunAction(false);
    actionGroup.enableStopAction(true);
    masterRequestRunMap = new ConcurrentHashMap<>();
    for (AutomatedTestCase testCase : testSuite.getTestCases()) {
        testCase.setStatus(TestCase.STATUS_NOT_RUN);
        testSuite.getProject().fireTestCaseStatusChange(testCase, testCase.getStatus());
    }
    testSuite.setRunning(true);
    List<AutomatedTestSuite> rootElements = new ArrayList<>();
    rootElements.add(testSuite);
    treeViewer.setInput(rootElements);
    treeViewer.expandToLevel(3);
    BusyIndicator.showWhile(display, new Runnable() {

        public void run() {
            // can take a long time if the project has not been loaded
            designerProxy = testSuite.getProject().getDesignerProxy();
        }
    });
}
Also used : ArrayList(java.util.ArrayList) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)

Example 13 with AutomatedTestSuite

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

the class ProcessExplorerActionGroup method createRunAction.

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

        @Override
        public void run() {
            if (!runApplies(getSelection()))
                return;
            try {
                WorkflowElement element = (WorkflowElement) getSelection().getFirstElement();
                WorkflowProject project = element.getProject();
                restServer = ((RestfulServer) project.getDesignerDataAccess().getCurrentServer());
                restServer.getAppSummary();
                refreshRolePermissions(project);
                if (!isAuthorized(element)) {
                    MessageDialog.openError(getViewSite().getShell(), RUN_ACTION, "You are not authorized to run " + element.getName());
                    return;
                }
                view.setFocus();
                if (element instanceof AutomatedTestSuite || element instanceof AutomatedTestCase)
                    actionHandler.test(getSelection());
                else
                    actionHandler.run((WorkflowElement) element);
            } catch (ConnectException ex) {
                PluginMessages.log(ex);
                MessageDialog.openError(MdwPlugin.getShell(), RUN_ACTION, "Server appears to be offline: " + restServer.getServerUrl());
            } catch (Exception ex) {
                PluginMessages.log(ex);
                MessageDialog.openError(MdwPlugin.getShell(), RUN_ACTION, ex.getMessage());
            }
        }
    };
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor(ICON_RUN_GIF);
    action.setImageDescriptor(imageDesc);
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "run");
    action.setText("Run...");
    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) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite) PartInitException(org.eclipse.ui.PartInitException) ConnectException(java.net.ConnectException) NamingException(javax.naming.NamingException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) ConnectException(java.net.ConnectException)

Example 14 with AutomatedTestSuite

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

the class ProcessExplorerActionGroup method renameApplies.

public boolean renameApplies(IStructuredSelection selection) {
    if (selection.size() != 1)
        return false;
    Object element = selection.getFirstElement();
    if (!(element instanceof WorkflowElement) || ((WorkflowElement) element).isArchived())
        return false;
    WorkflowElement workflowElement = (WorkflowElement) element;
    if (element instanceof Folder || element instanceof AutomatedTestSuite)
        return false;
    if (element instanceof AutomatedTestCase)
        return !((AutomatedTestCase) element).isLegacy();
    if (element instanceof File || element instanceof LegacyExpectedResults)
        return false;
    return workflowElement.isUserAuthorized(UserRoleVO.ASSET_DESIGN);
}
Also used : LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) Folder(com.centurylink.mdw.plugin.designer.model.Folder) 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) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)

Example 15 with AutomatedTestSuite

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

the class ProcessExplorerActionGroup method runApplies.

// top-level run action
public boolean runApplies(IStructuredSelection selection) {
    if (selection.size() > 1) {
        Boolean legacy = null;
        WorkflowPackage testPkg = null;
        for (Object o : selection.toArray()) {
            if (!(o instanceof AutomatedTestCase))
                return false;
            // make sure they're all in the same package or legacy suite
            AutomatedTestCase testCase = (AutomatedTestCase) o;
            if (legacy == null)
                legacy = testCase.isLegacy();
            if (legacy.booleanValue() != testCase.isLegacy())
                return false;
            if (!testCase.isLegacy()) {
                if (testPkg == null)
                    testPkg = testCase.getPackage();
                if (!testPkg.equals(testCase.getPackage()))
                    return false;
            }
        }
        WorkflowProject workflowProject = ((AutomatedTestCase) selection.getFirstElement()).getProject();
        if (!workflowProject.isRemote())
            return true;
        return workflowProject.isUserAuthorizedInAnyGroup(UserRoleVO.PROCESS_EXECUTION);
    }
    if (selection.size() != 1 || !(selection.getFirstElement() instanceof WorkflowElement))
        return false;
    WorkflowElement workflowElement = (WorkflowElement) selection.getFirstElement();
    if (workflowElement instanceof Report)
        return true;
    if (workflowElement instanceof Page)
        return true;
    if (workflowElement instanceof Template && ((Template) workflowElement).getLanguage().equals(RuleSetVO.VELOCITY))
        return true;
    if (workflowElement instanceof WorkflowProcess || workflowElement instanceof ExternalEvent) {
        if (!workflowElement.getProject().isRemote())
            return true;
        return workflowElement.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION);
    }
    if (workflowElement instanceof AutomatedTestSuite || workflowElement instanceof AutomatedTestCase) {
        if (workflowElement.getProject() == null)
            return false;
        if (workflowElement.getProject().isRemote()) {
            if (!workflowElement.getProject().isUserAuthorizedInAnyGroup(UserRoleVO.PROCESS_EXECUTION))
                return false;
            WorkflowPackage pkg = workflowElement.getPackage();
            if (pkg != null && !pkg.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION))
                return false;
        }
        try {
            AutomatedTestView testView = (AutomatedTestView) MdwPlugin.getActivePage().showView("mdw.views.launch.automatedTest");
            return !testView.isLocked();
        } catch (PartInitException ex) {
            PluginMessages.uiError(ex, "Menu", workflowElement.getProject());
        }
    }
    return false;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) Report(com.centurylink.mdw.plugin.designer.model.Report) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) Page(com.centurylink.mdw.plugin.designer.model.Page) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite) Template(com.centurylink.mdw.plugin.designer.model.Template) TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) PartInitException(org.eclipse.ui.PartInitException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

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