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;
}
}
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();
}
});
}
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;
}
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);
}
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;
}
Aggregations