use of com.centurylink.mdw.plugin.designer.model.CucumberTest in project mdw-designer by CenturyLinkCloud.
the class CucumberLaunchShortcut method performLaunch.
private void performLaunch(List<CucumberTest> tests, IFolder folder) throws CoreException {
IProject project = tests.get(0).getProject();
String launchName;
if (folder == null)
launchName = project.getName();
else
launchName = folder.getName();
List<String> testCases = new ArrayList<>();
for (CucumberTest test : tests) {
String testPath = test.getPath();
if (folder != null)
testPath = testPath.substring(folder.getProjectRelativePath().toString().length() + 1);
testCases.add(testPath);
}
ILaunchConfigurationWorkingCopy workingCopy = createLaunchConfiguration(project, folder, launchName, testCases);
ILaunchConfiguration config = null;
ILaunchConfigurationType configType = workingCopy.getType();
ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(configType);
for (ILaunchConfiguration launchConfig : configs) {
String projectAttr = launchConfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
String folderMatch = (folder == null) ? "" : folder.getProjectRelativePath().toString();
String folderAttr = launchConfig.getAttribute(CucumberLaunchConfiguration.FOLDER, "");
if (!project.getName().equals(projectAttr) || !folderMatch.equals(folderAttr))
continue;
config = launchConfig;
}
if (config == null) {
// no existing found - create a new one
config = workingCopy.doSave();
} else {
workingCopy = config.getWorkingCopy();
workingCopy.setAttribute(CucumberLaunchConfiguration.FEATURES, testCases);
config = workingCopy.doSave();
}
IStructuredSelection selection = new StructuredSelection(config);
DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), selection, GROUP_ID);
}
use of com.centurylink.mdw.plugin.designer.model.CucumberTest 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.designer.model.CucumberTest in project mdw-designer by CenturyLinkCloud.
the class CucumberLaunchTab method getAllTestCases.
/**
* @return all project test cases to be displayed (or empty array if none)
*/
@Override
protected String[] getAllTestCases() {
List<String> displayedCases = new ArrayList<>();
try {
if (project != null) {
List<CucumberTest> tests;
if (folder == null)
tests = CucumberTest.getTests(project);
else
tests = CucumberTest.getTests(folder);
for (CucumberTest test : tests) {
String testPath = test.getPath();
if (folder != null)
testPath = testPath.substring(folder.getProjectRelativePath().toString().length() + 1);
displayedCases.add(testPath);
}
}
} catch (CoreException ex) {
PluginMessages.log(ex);
}
return displayedCases.toArray(new String[0]);
}
Aggregations