use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class AutomatedTestLaunchShortcut method createLaunchConfiguration.
protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(WorkflowElement element, boolean debug) throws CoreException, JSONException {
String testName = null;
List<String> testCases = new ArrayList<>();
WorkflowProject workflowProject = element.getProject();
WorkflowPackage workflowPackage = null;
boolean isLegacyLaunch = false;
if (element instanceof WorkflowProject) {
testName = workflowProject.getName();
testCases = workflowProject.getTestCaseStringList();
} else if (element instanceof WorkflowPackage) {
workflowPackage = (WorkflowPackage) element;
testName = workflowPackage.getName();
testCases = workflowPackage.getTestCaseStringList();
} else if (element instanceof AutomatedTestCase) {
AutomatedTestCase testCase = (AutomatedTestCase) element;
if (testCase.isLegacy()) {
testName = workflowProject.getName() + LEGACY;
isLegacyLaunch = true;
} else {
workflowPackage = testCase.getPackage();
testName = workflowPackage.getName();
}
testCases = new ArrayList<>();
if (testCase.isPostman() && testCase.getItems() != null && workflowPackage != null) {
testCases.addAll(workflowPackage.getTestCaseItems(testCase));
} else
testCases.add(testCase.getPath());
} else if (element instanceof AutomatedTestSuite) {
testName = workflowProject.getName() + LEGACY;
isLegacyLaunch = true;
testCases = ((AutomatedTestSuite) element).getTestCaseStringList();
}
return createLaunchConfiguration(workflowProject, workflowPackage, isLegacyLaunch, testName, testCases, debug);
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class AutomatedTestLaunchShortcut method launch.
public void launch(IEditorPart editor, String mode) {
if (editor.getEditorInput() instanceof IFileEditorInput) {
IFileEditorInput fileEditorInput = (IFileEditorInput) editor.getEditorInput();
IFile file = fileEditorInput.getFile();
WorkflowProject project = WorkflowProjectManager.getInstance().getWorkflowProject(file.getProject());
WorkflowPackage pkg = project.getPackage((IFolder) file.getParent());
try {
performLaunch(pkg.getAsset(file), mode);
} catch (CoreException | JSONException ex) {
PluginMessages.uiError(ex, "Test Exec", project);
}
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage 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.designer.model.WorkflowPackage 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.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class Exporter method exportPackages.
public String exportPackages(List<WorkflowPackage> packages, boolean exportJson, boolean includeTaskTemplates, ProgressMonitor progressMonitor) throws DataAccessException, ActionCancelledException, JSONException, XmlException {
String export = null;
progressMonitor.progress(10);
int schemaVersion = designerDataAccess.getDatabaseSchemaVersion();
List<PackageVO> pkgVos = new ArrayList<>();
for (WorkflowPackage pv : packages) pkgVos.add(pv.getPackageVO());
export = designerDataAccess.exportPackages(pkgVos, schemaVersion, exportJson, includeTaskTemplates, progressMonitor);
for (WorkflowPackage pv : packages) pv.setExported(true);
return export;
}
Aggregations