Search in sources :

Example 1 with TestResultsParser

use of com.centurylink.mdw.designer.testing.TestResultsParser 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 2 with TestResultsParser

use of com.centurylink.mdw.designer.testing.TestResultsParser in project mdw-designer by CenturyLinkCloud.

the class AutomatedTestSuite method readLegacyCases.

public boolean readLegacyCases() {
    testCases = new ArrayList<>();
    File oldTestCasesDir = getProject().getOldTestCasesDir();
    if (oldTestCasesDir.exists() && oldTestCasesDir.isDirectory()) {
        File[] caseDirs = oldTestCasesDir.listFiles(new FileFilter() {

            public boolean accept(File file) {
                if (!file.isDirectory())
                    return false;
                if (file.getName().equalsIgnoreCase("CVS") || file.getName().equals(".metadata"))
                    return false;
                for (String commandsFileName : TestCase.LEGACY_TEST_CASE_FILENAMES.values()) {
                    if (new File(file.toString() + "/" + commandsFileName).exists())
                        return true;
                }
                return false;
            }
        });
        List<TestCase> cases = new ArrayList<>();
        for (File caseDir : caseDirs) {
            AutomatedTestCase testCase = new AutomatedTestCase(getProject(), this, new TestCase("Legacy", caseDir));
            testCases.add(testCase);
            cases.add(testCase.getTestCase());
        }
        // update case statuses
        File suiteResults = getProject().getFunctionTestResultsFile();
        if (suiteResults != null && suiteResults.exists()) {
            try {
                TestResultsParser parser = new TestResultsParser(suiteResults, cases);
                if (suiteResults.getName().endsWith(".xml"))
                    parser.parseXml();
                else
                    parser.parseJson(getProject().getAssetDir());
            } catch (Exception ex) {
                PluginMessages.log(ex);
            }
        }
        return true;
    }
    return false;
}
Also used : TestCase(com.centurylink.mdw.designer.testing.TestCase) ArrayList(java.util.ArrayList) TestResultsParser(com.centurylink.mdw.designer.testing.TestResultsParser) FileFilter(java.io.FileFilter) File(java.io.File) IOException(java.io.IOException) JSONException(org.json.JSONException)

Aggregations

TestCase (com.centurylink.mdw.designer.testing.TestCase)2 TestResultsParser (com.centurylink.mdw.designer.testing.TestResultsParser)2 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 JSONException (org.json.JSONException)2 MdwSecurityException (com.centurylink.mdw.auth.MdwSecurityException)1 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)1 CodeTimer (com.centurylink.mdw.plugin.CodeTimer)1 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)1 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)1 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)1 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)1 FileFilter (java.io.FileFilter)1 MalformedURLException (java.net.MalformedURLException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1