use of com.centurylink.mdw.designer.testing.GroovyTestCaseRun in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method prepareTestCase.
public TestCaseRun prepareTestCase(AutomatedTestCase testCase, int runNum, File resultDir, boolean createReplace, boolean verbose, PrintStream log, LogMessageMonitor monitor, boolean singleServer, boolean stubbing, boolean debug) throws RemoteException {
if ((testCase.isGroovy() || testCase.isGherkin()) && !MdwPlugin.workspaceHasGroovySupport()) {
String msg = "Please install Groovy support to execute test case: " + testCase.getName();
throw new IllegalStateException(msg);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd-HHmmssSSS");
try {
if (!testCase.isLegacy() && !testCase.getProject().isFilePersist()) {
// non-VCS asset-based -- load ruleSet content
testCase.load();
testCase.getRuleSetVO().setPackageName(testCase.getPackage().getName());
}
testCase.getTestCase().prepare();
Map<String, ProcessVO> procCache = new HashMap<>();
String masterRequestId = testCase.getMasterRequestId();
if (masterRequestId == null)
masterRequestId = project.getUser().getUsername() + "-" + sdf.format(new Date());
else if (!testCase.isGroovy() && !testCase.isGherkin() && masterRequestId.equals(TestDataFilter.AnyNumberToken))
masterRequestId = Long.toString(System.currentTimeMillis());
if (testCase.isGherkin() && masterRequestId.indexOf("${masterRequestId}") != -1)
masterRequestId = masterRequestId.replace("${masterRequestId}", project.getUser().getUsername() + "-" + sdf.format(new Date()));
testCase.setMasterRequestId(masterRequestId);
TestCaseRun run;
if (testCase.isGherkin()) {
run = new GherkinTestCaseLaunch(testCase.getTestCase(), runNum, masterRequestId, new DesignerDataAccess(dataAccess.getDesignerDataAccess()), monitor, procCache, testCase.isLoadTest(), true, testCase.getProject().isOldNamespaces(), project);
} else if (testCase.isGroovy()) {
if (debug) {
run = new AutoTestCaseRun(testCase, runNum, masterRequestId, new DesignerDataAccess(dataAccess.getDesignerDataAccess()), monitor, procCache, debug);
} else {
List<String> classpathList = null;
IJavaProject javaProject = project.getJavaProject();
if (javaProject != null && javaProject.exists()) {
classpathList = Arrays.asList(JavaRuntime.computeDefaultRuntimeClassPath(javaProject));
}
run = new GroovyTestCaseRun(testCase.getTestCase(), runNum, masterRequestId, new DesignerDataAccess(dataAccess.getDesignerDataAccess()), monitor, procCache, testCase.isLoadTest(), true, testCase.getProject().isOldNamespaces(), classpathList);
}
} else {
run = new TestCaseRun(testCase.getTestCase(), runNum, masterRequestId, new DesignerDataAccess(dataAccess.getDesignerDataAccess()), monitor, procCache, testCase.isLoadTest(), true, testCase.getProject().isOldNamespaces());
}
run.prepareTest(createReplace, resultDir, verbose, singleServer, stubbing, log);
return run;
} catch (Exception ex) {
throw new RemoteException(ex.getMessage(), ex);
}
}
Aggregations