Search in sources :

Example 26 with AutomatedTestCase

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

the class WorkflowProject method findTopLevelPackages.

/**
 * Finds the list of top level packages (including the default if
 * supported), populated with the appropriate processes, etc.
 */
private void findTopLevelPackages(ProgressMonitor progressMonitor) {
    CodeTimer timer = new CodeTimer("findTopLevelPackages()");
    topLevelPackages = new ArrayList<>();
    topLevelUserVisiblePackages = new ArrayList<>();
    activityImpls.clear();
    for (PackageVO packageVO : getTopLevelPackageVOs(progressMonitor)) {
        WorkflowPackage topLevelPackage = new WorkflowPackage(this, packageVO);
        topLevelPackage.setProcesses(findProcesses(topLevelPackage));
        topLevelPackage.setExternalEvents(findExternalEvents(topLevelPackage));
        topLevelPackage.setActivityImpls(findActivityImplementors(topLevelPackage));
        topLevelPackage.setAssets(findWorkflowAssets(topLevelPackage));
        topLevelPackage.setTaskTemplates(findTaskTemplates(topLevelPackage));
        topLevelPackages.add(topLevelPackage);
        if (topLevelPackage.isVisible())
            topLevelUserVisiblePackages.add(topLevelPackage);
        // register as a listener so that i can pass on element change
        // events
        topLevelPackage.addElementChangeListener(this);
        for (WorkflowProcess process : topLevelPackage.getProcesses()) process.addElementChangeListener(this);
    }
    Collections.sort(topLevelPackages);
    Collections.sort(topLevelUserVisiblePackages);
    File resultsFile = getFunctionTestResultsFile();
    if (resultsFile.exists()) {
        // update test case statuses
        List<TestCase> testCases = new ArrayList<>();
        for (WorkflowPackage pkg : topLevelPackages) {
            for (WorkflowAsset asset : pkg.getAssets()) {
                if (asset instanceof AutomatedTestCase)
                    testCases.add(((AutomatedTestCase) asset).getTestCase());
            }
        }
        if (!testCases.isEmpty()) {
            try {
                TestResultsParser parser = new TestResultsParser(resultsFile, testCases);
                if (resultsFile.getName().endsWith(".xml"))
                    parser.parseXml();
                else
                    parser.parseJson(getAssetDir());
            } catch (Exception ex) {
                PluginMessages.uiError(ex, "Parse Test Results", this);
            }
        }
    }
    timer.stopAndLog();
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) JSONException(org.json.JSONException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) MdwSecurityException(com.centurylink.mdw.auth.MdwSecurityException) MalformedURLException(java.net.MalformedURLException) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) TestCase(com.centurylink.mdw.designer.testing.TestCase) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) TestResultsParser(com.centurylink.mdw.designer.testing.TestResultsParser) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 27 with AutomatedTestCase

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

the class DesignerProxy method renameWorkflowAsset.

public void renameWorkflowAsset(final WorkflowAsset asset, final String newName) {
    if (asset.getPackage().workflowAssetNameExists(newName)) {
        Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
        MessageDialog.openError(shell, RENAME_ERROR, "Name already exists: '" + newName + "'");
        return;
    }
    String progressMsg = "Renaming to '" + newName + "'";
    String errorMsg = "Rename Workflow Asset";
    if (!asset.isLoaded())
        asset.load();
    designerRunner = new DesignerRunner(progressMsg, errorMsg, asset.getProject()) {

        public void perform() throws DataAccessException, RemoteException {
            asset.setVersion(1);
            dataAccess.getDesignerDataModel().removeRuleSet(asset.getRuleSetVO(), false);
            dataAccess.getDesignerDataAccess().renameRuleSet(asset.getRuleSetVO(), newName);
            if (asset instanceof AutomatedTestCase) {
                if (project.isFilePersist())
                    ((AutomatedTestCase) asset).setTestCase(new TestCase(asset.getPackage().getName(), asset.getRawFile()));
                else
                    ((AutomatedTestCase) asset).setTestCase(new TestCase(asset.getPackage().getName(), asset.getRuleSetVO()));
            }
            // roughly the same as db time
            asset.setModifyDate(new Date());
            // hopefully
            cacheRefresh.fireRefresh(RuleSetVO.JAVA.equals(asset.getLanguage()));
            dataAccess.getDesignerDataModel().addRuleSet(asset.getRuleSetVO());
        }
    };
    designerRunner.run();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) TestCase(com.centurylink.mdw.designer.testing.TestCase) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) RemoteException(java.rmi.RemoteException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) Date(java.util.Date)

Aggregations

AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)27 AutomatedTestSuite (com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)14 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)11 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)11 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)10 ArrayList (java.util.ArrayList)10 LegacyExpectedResults (com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults)8 JSONException (org.json.JSONException)7 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)6 File (java.io.File)6 IFile (org.eclipse.core.resources.IFile)6 PartInitException (org.eclipse.ui.PartInitException)6 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)4 JarFile (com.centurylink.mdw.plugin.designer.model.JarFile)4 IOException (java.io.IOException)4 CoreException (org.eclipse.core.runtime.CoreException)4 AutomatedTestResults (com.centurylink.mdw.plugin.designer.model.AutomatedTestResults)3 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)3 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)3 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)2