Search in sources :

Example 1 with GherkinTestCaseLaunch

use of com.centurylink.mdw.plugin.launch.GherkinTestCaseLaunch 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);
    }
}
Also used : HashMap(java.util.HashMap) GherkinTestCaseLaunch(com.centurylink.mdw.plugin.launch.GherkinTestCaseLaunch) GroovyTestCaseRun(com.centurylink.mdw.designer.testing.GroovyTestCaseRun) Date(java.util.Date) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) IJavaProject(org.eclipse.jdt.core.IJavaProject) AutoTestCaseRun(com.centurylink.mdw.plugin.launch.AutoTestCaseRun) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ArrayList(java.util.ArrayList) List(java.util.List) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) DesignerDataAccess(com.centurylink.mdw.designer.DesignerDataAccess) TestCaseRun(com.centurylink.mdw.designer.testing.TestCaseRun) AutoTestCaseRun(com.centurylink.mdw.plugin.launch.AutoTestCaseRun) GroovyTestCaseRun(com.centurylink.mdw.designer.testing.GroovyTestCaseRun) RemoteException(java.rmi.RemoteException) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)1 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 TranslationException (com.centurylink.mdw.common.exception.TranslationException)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1 DesignerDataAccess (com.centurylink.mdw.designer.DesignerDataAccess)1 GroovyTestCaseRun (com.centurylink.mdw.designer.testing.GroovyTestCaseRun)1 TestCaseRun (com.centurylink.mdw.designer.testing.TestCaseRun)1 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)1 ProcessList (com.centurylink.mdw.model.value.process.ProcessList)1 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)1 AutoTestCaseRun (com.centurylink.mdw.plugin.launch.AutoTestCaseRun)1 GherkinTestCaseLaunch (com.centurylink.mdw.plugin.launch.GherkinTestCaseLaunch)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1