use of com.centurylink.mdw.plugin.designer.model.AutomatedTestResults in project mdw-designer by CenturyLinkCloud.
the class AutomatedTestView method handleSelectionChanged.
public void handleSelectionChanged(IStructuredSelection selection) {
String output = "";
if (selection.size() == 1 && selection.getFirstElement() instanceof WorkflowElement) {
selectedItem = (WorkflowElement) selection.getFirstElement();
if (selectedItem instanceof AutomatedTestCase) {
AutomatedTestCase testCase = (AutomatedTestCase) selectedItem;
output = readFile(testCase.getOutputFile()).replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
if (testCase.isPostman() && testCase.getItemName() != null)
output = readFile(testCase.getItemOutputFile()).replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
} else if (selectedItem instanceof AutomatedTestResults) {
AutomatedTestResults expectedResults = (AutomatedTestResults) selectedItem;
output = "Results:\n-----------\n" + readFile(expectedResults.getActualResults());
} else if (selectedItem instanceof LegacyExpectedResults) {
LegacyExpectedResults expectedResult = (LegacyExpectedResults) selectedItem;
output = "Results:\n-----------\n" + readFile(expectedResult.getActualResultFile());
}
} else {
selectedItem = null;
}
outputText.setText(output);
}
use of com.centurylink.mdw.plugin.designer.model.AutomatedTestResults 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;
}
}
use of com.centurylink.mdw.plugin.designer.model.AutomatedTestResults in project mdw-designer by CenturyLinkCloud.
the class AutomatedTestView method refreshOutputFromSelection.
private void refreshOutputFromSelection() {
display.asyncExec(new Runnable() {
public void run() {
String output = "";
if (selectedItem instanceof AutomatedTestCase) {
AutomatedTestCase testCase = (AutomatedTestCase) selectedItem;
output = readFile(testCase.getOutputFile()).replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
if (testCase.isPostman() && testCase.getItemName() != null)
output = readFile(testCase.getItemOutputFile()).replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
} else if (selectedItem instanceof AutomatedTestResults) {
AutomatedTestResults expectedResults = (AutomatedTestResults) selectedItem;
output = "Results:\n--------\n" + readFile(expectedResults.getActualResults());
} else if (selectedItem instanceof LegacyExpectedResults) {
LegacyExpectedResults expectedResult = (LegacyExpectedResults) selectedItem;
output = "Results:\n--------\n" + readFile(expectedResult.getActualResultFile());
}
if (!outputText.getText().equals(output)) {
outputText.setText(output);
outputText.setSelection(outputText.getText().length());
}
}
});
}
use of com.centurylink.mdw.plugin.designer.model.AutomatedTestResults in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerActionGroup method createCompareResultsAction.
private IAction createCompareResultsAction() {
IAction action = new Action() {
@SuppressWarnings("restriction")
@Override
public void run() {
if (compareResultsApplies(getSelection())) {
WorkflowProject project = ((WorkflowElement) getSelection().getFirstElement()).getProject();
try {
project.getProjectFolder(project.getTestResultsPath(AutomatedTestCase.FUNCTION_TEST)).refreshLocal(IResource.DEPTH_INFINITE, null);
Object[] items = new Object[2];
if (getSelection().getFirstElement() instanceof AutomatedTestResults) {
AutomatedTestResults expectedResults = (AutomatedTestResults) getSelection().getFirstElement();
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 (getSelection().getFirstElement() instanceof LegacyExpectedResults) {
LegacyExpectedResults expectedResult = (LegacyExpectedResults) getSelection().getFirstElement();
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;
}
use of com.centurylink.mdw.plugin.designer.model.AutomatedTestResults in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerActionGroup method createOpenInstanceAction.
private IAction createOpenInstanceAction() {
IAction action = new Action() {
@Override
public void run() {
if (openInstanceApplies(getSelection())) {
WorkflowProject project = ((WorkflowElement) getSelection().getFirstElement()).getProject();
try {
Long procInstId = null;
if (getSelection().getFirstElement() instanceof AutomatedTestResults) {
AutomatedTestResults expectedResults = (AutomatedTestResults) getSelection().getFirstElement();
procInstId = expectedResults.getActualProcessInstanceId();
} else if (getSelection().getFirstElement() instanceof LegacyExpectedResults) {
LegacyExpectedResults expectedResult = (LegacyExpectedResults) getSelection().getFirstElement();
java.io.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.setText(OPEN_PROCESS_INSTANCE);
action.setId(MdwMenuManager.MDW_MENU_PREFIX + OPEN_PROCESS_INSTANCE);
ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor(ICON_PROCESS_GIF);
action.setImageDescriptor(imageDesc);
return action;
}
Aggregations