use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class AutomatedTestLaunchShortcut method launch.
public void launch(ISelection sel, String mode) {
StructuredSelection selection = (StructuredSelection) sel;
Object firstElement = selection.getFirstElement();
WorkflowProject project = null;
try {
if (firstElement instanceof WorkflowElement) {
WorkflowElement element = (WorkflowElement) firstElement;
project = element.getProject();
boolean prevEnablement = disableBuildBeforeLaunch();
if (selection.size() > 1 || element instanceof AutomatedTestCase) {
List<AutomatedTestCase> testCases = new ArrayList<>();
for (Object obj : selection.toArray()) testCases.add((AutomatedTestCase) obj);
performLaunch(testCases, mode);
} else {
performLaunch(element, mode);
}
setBuildBeforeLaunch(prevEnablement);
} else {
ResourceWrapper resourceWrapper = new ResourceWrapper(firstElement);
IFile firstFile = resourceWrapper.getFile();
if (firstFile != null) {
project = WorkflowProjectManager.getInstance().getWorkflowProject(firstFile.getProject());
// test case file(s)
List<AutomatedTestCase> testCases = new ArrayList<>();
Object[] objArr = selection.toArray();
if (objArr.length == 1) {
WorkflowPackage pkg = project.getPackage((IFolder) firstFile.getParent());
testCases.add((AutomatedTestCase) pkg.getAsset(firstFile));
} else {
for (Object obj : objArr) {
IFile file = (IFile) obj;
WorkflowPackage pkg = project.getPackage((IFolder) file.getParent());
testCases.add((AutomatedTestCase) pkg.getAsset(file));
}
}
performLaunch(testCases, mode);
} else {
IFolder folder = resourceWrapper.getFolder();
if (folder != null) {
project = WorkflowProjectManager.getInstance().getWorkflowProject(folder.getProject());
performLaunch(project.getPackage(folder), mode);
} else {
IProject proj = resourceWrapper.getProject();
project = WorkflowProjectManager.getInstance().getWorkflowProject(proj);
performLaunch(project, mode);
}
}
}
} catch (Exception ex) {
PluginMessages.uiError(ex, "Test Exec", project);
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class AutomatedTestLaunchShortcut method performLaunch.
/**
* All test cases must be in the same package or legacy suite.
*/
private void performLaunch(List<AutomatedTestCase> cases, String mode) throws CoreException, JSONException {
AutomatedTestCase firstCase = cases.get(0);
WorkflowProject workflowProject = firstCase.getProject();
WorkflowPackage workflowPackage = firstCase.getPackage();
boolean isLegacyLaunch = firstCase.isLegacy();
String testName;
if (isLegacyLaunch)
testName = workflowProject.getName() + LEGACY;
else
testName = workflowPackage.getName();
List<String> testCases = new ArrayList<>();
for (AutomatedTestCase testCase : cases) {
if (testCase.getItems() != null) {
testCases.addAll(workflowPackage.getTestCaseItems(testCase));
} else if (testCase.isPostman())
testCases.add(testCase.getItemPath());
else
testCases.add(testCase.getPath());
}
ILaunchConfigurationWorkingCopy workingCopy = createLaunchConfiguration(workflowProject, workflowPackage, isLegacyLaunch, testName, testCases, ILaunchManager.DEBUG_MODE.equals(mode));
ILaunchConfiguration config = findExistingLaunchConfiguration(workingCopy);
if (config == null) {
// no existing found - create a new one
config = workingCopy.doSave();
} else {
workingCopy = config.getWorkingCopy();
String prefix;
if (workingCopy.getAttribute(AutomatedTestLaunchConfiguration.IS_LOAD_TEST, false))
prefix = AutomatedTestCase.LOAD_TEST;
else
prefix = AutomatedTestCase.FUNCTION_TEST;
workingCopy.setAttribute(prefix + "_" + AutomatedTestLaunchConfiguration.TEST_CASES, testCases);
config = workingCopy.doSave();
}
IStructuredSelection selection = new StructuredSelection(config);
if (ILaunchManager.DEBUG_MODE.equals(mode)) {
DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), selection, DEBUG_GROUP_ID);
} else {
DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), selection, GROUP_ID);
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class CucumberLaunchShortcut method launch.
public void launch(ISelection sel, String mode) {
StructuredSelection selection = (StructuredSelection) sel;
Object firstElement = selection.getFirstElement();
ResourceWrapper resourceWrapper = new ResourceWrapper(firstElement);
try {
List<CucumberTest> tests = new ArrayList<>();
IFile file = resourceWrapper.getFile();
if (file != null) {
// launch gherkin feature test(s)
for (Object obj : selection.toArray()) {
ResourceWrapper fileWrapper = new ResourceWrapper(obj);
tests.add(new CucumberTest(fileWrapper.getOwningProject(), fileWrapper.getFile()));
}
performLaunch(tests, new ResourceWrapper(file.getParent()).getFolder());
} else {
// package folder
IFolder folder = resourceWrapper.getFolder();
if (folder != null) {
CucumberTest.findTests(folder, tests);
performLaunch(tests, folder);
} else {
IProject proj = resourceWrapper.getProject();
tests.addAll(CucumberTest.getTests(proj));
performLaunch(tests, null);
}
}
} catch (Exception ex) {
WorkflowProject proj = firstElement instanceof WorkflowElement ? ((WorkflowElement) firstElement).getProject() : null;
PluginMessages.uiError(ex, "Test Exec", proj);
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class ResourceWrapper method getOwningWorkflowProject.
public WorkflowProject getOwningWorkflowProject() throws JavaModelException {
WorkflowProject owningWorkflowProject = null;
IProject owningProject = getOwningProject();
if (owningProject != null)
owningWorkflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(owningProject);
return owningWorkflowProject;
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class MdwHubAction method populateMenu.
/**
* populates the plugin action menu (the mdwhub icon) with its items
*/
public void populateMenu(Menu menu) {
WorkflowProjectManager wfProjectMgr = WorkflowProjectManager.getInstance();
List<WorkflowProject> workflowProjects = wfProjectMgr.getWorkflowProjects();
if (workflowProjects.isEmpty()) {
MenuItem item = new MenuItem(menu, SWT.NONE);
item.setText("(No Projects)");
item.setImage(MdwPlugin.getImageDescriptor("icons/wait.gif").createImage());
item.setEnabled(false);
} else {
for (final WorkflowProject workflowProject : workflowProjects) {
if (workflowProject.checkRequiredVersion(5, 5)) {
String projName = workflowProject.isFrameworkProject() ? "MDWFramework" : workflowProject.getName();
// MDWWeb
MenuItem item = new MenuItem(menu, SWT.NONE);
final WebLaunchAction launchAction = WebLaunchActions.getLaunchAction(workflowProject, WebApp.MdwHub);
item.setText(projName + " - " + launchAction.getLabel());
item.setImage(launchAction.getIconImage());
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
mostRecentHubWorkflowProject = workflowProject;
launchAction.launch(workflowProject);
}
});
}
}
}
}
Aggregations