use of com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite in project mdw-designer by CenturyLinkCloud.
the class AutomatedTestView method handleRerunSelection.
public void handleRerunSelection() {
if (selectedItem != null) {
if (selectedItem instanceof AutomatedTestSuite) {
handleRerun();
} else if (selectedItem instanceof WorkflowPackage) {
WorkflowPackage pkg = (WorkflowPackage) selectedItem;
List<AutomatedTestCase> cases = new ArrayList<AutomatedTestCase>();
List<String> testCasesStringList;
try {
testCasesStringList = pkg.getTestCaseStringList();
for (AutomatedTestCase testCase : testSuite.getTestCases()) {
String path = testCase.getPath();
if (testCase.isPostman())
path = testCase.getItemPath();
if (testCasesStringList.contains(path))
cases.add(testCase);
}
} catch (JSONException e) {
e.printStackTrace();
}
runTestCases(cases);
} else if (selectedItem instanceof AutomatedTestCase) {
AutomatedTestCase testCase = (AutomatedTestCase) selectedItem;
runTestCase(testCase);
}
}
}
use of com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerContentProvider method getChildren.
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof WorkflowProject) {
final WorkflowProject workflowProject = (WorkflowProject) parentElement;
if (!workflowProject.isLoaded()) {
try {
IRunnableWithProgress loader = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
ProgressMonitor progressMonitor = new SwtProgressMonitor(monitor);
progressMonitor.start("Loading " + workflowProject.getLabel());
progressMonitor.progress(5);
try {
workflowProject.initialize(progressMonitor);
if (workflowProject.getDataAccess() != null) {
workflowProject.getTopLevelUserVisiblePackages(progressMonitor);
workflowProject.getArchivedUserVisiblePackagesFolder(progressMonitor);
progressMonitor.done();
}
} catch (Exception ex) {
throw new InvocationTargetException(ex);
}
}
};
ProgressMonitorDialog progMonDlg = new MdwProgressMonitorDialog(MdwPlugin.getShell());
progMonDlg.run(true, false, loader);
} catch (InvocationTargetException itx) {
if (itx.getCause() instanceof DataUnavailableException) {
PluginMessages.log(itx);
MessageDialog.openWarning(MdwPlugin.getShell(), LOAD_WF_PROJECT, itx.getCause().getMessage());
} else if (itx.getCause() instanceof DataAccessOfflineException) {
PluginMessages.log(itx);
MessageDialog.openError(MdwPlugin.getShell(), LOAD_WF_PROJECT, itx.getCause().getMessage());
return new WorkflowPackage[0];
} else {
PluginMessages.uiError(itx, LOAD_WF_PROJECT, workflowProject);
return new WorkflowPackage[0];
}
} catch (Exception ex) {
PluginMessages.uiError(ex, LOAD_WF_PROJECT, workflowProject);
return new WorkflowPackage[0];
}
}
if (workflowProject.getDataAccess() == null)
return new WorkflowPackage[0];
List<WorkflowPackage> topLevelPackages = workflowProject.getTopLevelUserVisiblePackages();
Folder archivedPackageFolder = workflowProject.getArchivedUserVisiblePackagesFolder();
int size = topLevelPackages.size();
boolean showArchived = isShowArchivedItems(workflowProject);
if (showArchived)
size++;
AutomatedTestSuite testSuite = workflowProject.getLegacyTestSuite();
if (testSuite != null && !testSuite.isEmpty())
size++;
Object[] objects = new Object[size];
for (int i = 0; i < topLevelPackages.size(); i++) objects[i] = topLevelPackages.get(i);
int cur = topLevelPackages.size();
if (showArchived) {
objects[cur] = archivedPackageFolder;
cur++;
}
if (testSuite != null && !testSuite.isEmpty())
objects[cur] = testSuite;
return objects;
} else if (parentElement instanceof WorkflowPackage) {
WorkflowPackage packageVersion = (WorkflowPackage) parentElement;
if (packageVersion.isArchived() && packageVersion.hasDescendantPackageVersions()) {
return packageVersion.getDescendantPackageVersions().toArray(new WorkflowPackage[0]);
} else {
List<WorkflowElement> elements = new ArrayList<>();
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_PROCESSES_IN_PEX))
elements.addAll(packageVersion.getProcesses());
if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_WORKFLOW_ASSETS_IN_PEX))
elements.addAll(packageVersion.getAssets());
if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_EVENT_HANDLERS_IN_PEX))
elements.addAll(packageVersion.getExternalEvents());
if (prefsStore.getBoolean(PreferenceConstants.PREFS_SHOW_ACTIVITY_IMPLEMENTORS_IN_PEX))
elements.addAll(packageVersion.getActivityImpls());
if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_TASK_TEMPLATES_IN_PEX))
elements.addAll(packageVersion.getTaskTemplates());
elements.addAll(packageVersion.getChildFolders());
if (isSortPackageContentsAtoZ()) {
Collections.sort(elements, new Comparator<WorkflowElement>() {
public int compare(WorkflowElement e1, WorkflowElement e2) {
return e1.getLabel().compareToIgnoreCase(e2.getLabel());
}
});
}
return elements.toArray(new Object[0]);
}
} else if (parentElement instanceof WorkflowProcess) {
WorkflowProcess processVersion = (WorkflowProcess) parentElement;
if (processVersion.hasDescendantProcessVersions()) {
return processVersion.getDescendantProcessVersions().toArray(new WorkflowProcess[0]);
} else {
return emptyARRAY;
}
} else if (parentElement instanceof Folder) {
Folder folder = (Folder) parentElement;
return folder.getChildren().toArray(new WorkflowElement[0]);
} else if (parentElement instanceof AutomatedTestSuite) {
AutomatedTestSuite testSuite = (AutomatedTestSuite) parentElement;
return testSuite.getTestCases().toArray(new AutomatedTestCase[0]);
} else if (parentElement instanceof AutomatedTestCase) {
AutomatedTestCase testCase = (AutomatedTestCase) parentElement;
if (!testCase.isLegacy())
return emptyARRAY;
List<LegacyExpectedResults> expectedResults = testCase.getLegacyExpectedResults();
List<File> files = testCase.getFiles();
Object[] objects = new Object[expectedResults.size() + files.size()];
for (int i = 0; i < expectedResults.size(); i++) objects[i] = expectedResults.get(i);
for (int i = expectedResults.size(); i < objects.length; i++) objects[i] = files.get(i - expectedResults.size());
return objects;
} else {
return emptyARRAY;
}
}
use of com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite in project mdw-designer by CenturyLinkCloud.
the class WorkflowProject method refreshLegacyTestSuite.
public void refreshLegacyTestSuite() {
legacyTestSuite = null;
AutomatedTestSuite testSuite = getLegacyTestSuite();
testSuite.fireElementChangeEvent(testSuite, ChangeType.SETTINGS_CHANGE, null);
try {
getOldTestCasesFolder().getParent().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException ex) {
PluginMessages.log(ex);
}
}
use of com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite in project mdw-designer by CenturyLinkCloud.
the class WorkflowProject method findLegacyTests.
public AutomatedTestSuite findLegacyTests() {
AutomatedTestSuite testSuite = new AutomatedTestSuite(this);
if (testSuite.readLegacyCases()) {
for (AutomatedTestCase testCase : testSuite.getTestCases()) {
testCase.addElementChangeListener(this);
for (LegacyExpectedResults expectedResult : testCase.getLegacyExpectedResults()) expectedResult.addElementChangeListener(this);
for (com.centurylink.mdw.plugin.designer.model.File file : testCase.getFiles()) file.addElementChangeListener(this);
}
}
testSuite.setLabel("Legacy Tests");
testSuite.setIcon("folder.gif");
return testSuite;
}
use of com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite in project mdw-designer by CenturyLinkCloud.
the class AutomatedTestLaunchConfiguration method launch.
public void launch(ILaunchConfiguration launchConfig, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(launchConfig.getAttribute(WORKFLOW_PROJECT, ""));
boolean isLoadTest = launchConfig.getAttribute(IS_LOAD_TEST, false);
String attrPrefix = isLoadTest ? AutomatedTestCase.LOAD_TEST : AutomatedTestCase.FUNCTION_TEST;
String resultsPath = launchConfig.getAttribute(attrPrefix + "_" + RESULTS_PATH, "");
if (resultsPath.isEmpty())
resultsPath = WorkflowProject.DEFAULT_TEST_RESULTS_PATH;
workflowProject.setTestResultsPath(attrPrefix, resultsPath);
int threadCount = launchConfig.getAttribute(attrPrefix + "_" + THREAD_COUNT, 5);
int runCount = launchConfig.getAttribute(attrPrefix + "_" + RUN_COUNT, 100);
int threadInterval = launchConfig.getAttribute(attrPrefix + "_" + THREAD_INTERVAL, 2);
int runInterval = launchConfig.getAttribute(attrPrefix + "_" + RUN_INTERVAL, 2);
boolean verbose = launchConfig.getAttribute(attrPrefix + "_" + VERBOSE, true);
boolean stubbing = launchConfig.getAttribute(attrPrefix + "_" + STUBBING, false);
boolean singleServer = launchConfig.getAttribute(attrPrefix + "_" + SINGLE_SERVER, true);
boolean createReplace = launchConfig.getAttribute(attrPrefix + "_" + CREATE_REPLACE_RESULTS, false);
boolean postmanTestsExists = false;
HashMap<String, Boolean> testCaseOrder = null;
testSuite = new AutomatedTestSuite(workflowProject);
testSuite.setLoadTest(isLoadTest);
testSuite.setThreadCount(threadCount);
testSuite.setRunCount(runCount);
if (isLoadTest)
testSuite.setThreadInterval(runInterval);
else
testSuite.setThreadInterval(threadInterval);
testSuite.setVerbose(verbose);
testSuite.setStubbing(stubbing);
testSuite.setSingleServer(singleServer);
testSuite.setCreateReplaceResults(createReplace);
List<AutomatedTestCase> testCases = new ArrayList<>();
List<String> testCasesStr = launchConfig.getAttribute(attrPrefix + "_" + TEST_CASES, new ArrayList<String>());
for (String testCaseStr : testCasesStr) {
AutomatedTestCase autoTestCase;
if (testCaseStr.startsWith("Legacy/"))
autoTestCase = workflowProject.getLegacyTestSuite().getTestCase(testCaseStr);
else if (testCaseStr.indexOf("postman") > -1) {
String[] pathArray = testCaseStr.split("/");
String method = pathArray[2];
AutomatedTestCase cloneTestCase = (AutomatedTestCase) workflowProject.getAsset(pathArray[0] + "/" + pathArray[1]);
autoTestCase = new AutomatedTestCase(cloneTestCase);
autoTestCase.setId(cloneTestCase.getId());
try {
StringBuilder itemName = new StringBuilder(pathArray[3]);
for (int i = 4; i < pathArray.length; i++) itemName = itemName.append("/" + pathArray[i]);
autoTestCase.setItemName(itemName.toString());
autoTestCase.setMethod(method);
autoTestCase.getTestCase().resetItems();
autoTestCase.getTestCase().addItem(cloneTestCase.getItem(itemName.toString(), method));
postmanTestsExists = true;
} catch (Exception e) {
PluginMessages.log(e);
}
} else
autoTestCase = (AutomatedTestCase) workflowProject.getAsset(testCaseStr);
autoTestCase.setTestSuite(testSuite);
if (!autoTestCase.getResultsDir().exists())
autoTestCase.getResultsDir().mkdirs();
testCases.add(autoTestCase);
}
testSuite.setTestCases(testCases);
if (postmanTestsExists) {
testCaseOrder = new HashMap<>();
List<AutomatedTestCase> cases = new ArrayList<>();
for (AutomatedTestCase testCase : testSuite.getTestCases()) {
if (!testCase.isPostman())
cases.add(testCase);
else {
if (testCaseOrder.get(testCase.getName()) == null) {
List<AutomatedTestCase> postmanCases = testSuite.getPostmanTestCasesByName(testCase.getName());
testCaseOrder.put(testCase.getName(), true);
AutomatedTestCase postmanCase = testSuite.getPostmanTestCaseByMethod(postmanCases, "GET");
if (postmanCase != null)
cases.add(postmanCase);
postmanCase = testSuite.getPostmanTestCaseByMethod(postmanCases, "DELETE");
if (postmanCase != null)
cases.add(postmanCase);
postmanCase = testSuite.getPostmanTestCaseByMethod(postmanCases, "POST");
if (postmanCase != null)
cases.add(postmanCase);
postmanCase = testSuite.getPostmanTestCaseByMethod(postmanCases, "PUT");
if (postmanCase != null)
cases.add(postmanCase);
}
}
}
testSuite.setTestCases(cases);
}
if (isLoadTest) {
Map<String, String> testCaseCounts = launchConfig.getAttribute(attrPrefix + "_" + TESTCASE_COUNTS_MAP, new HashMap<String, String>());
for (Map.Entry<String, String> entry : testCaseCounts.entrySet()) {
int count = Integer.parseInt(entry.getValue());
testSuite.getTestCase(entry.getKey()).setRunCount(count);
}
}
if (!testSuite.getResultsDir().exists())
testSuite.getResultsDir().mkdirs();
testSuite.setDebug(ILaunchManager.DEBUG_MODE.equals(mode));
showResultsView();
}
Aggregations