Search in sources :

Example 6 with TestCase

use of com.twinsoft.convertigo.beans.core.TestCase in project convertigo by convertigo.

the class VariableTreeObject2 method propagateVariableRename.

private void propagateVariableRename(boolean isSameValue, boolean shouldUpdate, TreeObjectEvent treeObjectEvent, List<TestCase> list, String parentName) {
    try {
        /*
			 * get the testcases list
			 */
        if (list != null) {
            TestCase testCase;
            TestCaseVariable testCaseVar;
            /*
				 * locate testcase belonging to same sequence
				 */
            for (int i = 0; i < list.size(); i++) {
                if (((testCase = (TestCase) list.get(i)) != null) && (testCase.getParent().getName().equals(parentName))) {
                    /*
						 * get the testcase variables list
						 */
                    List<TestCaseVariable> varList = testCase.getAllVariables();
                    for (int v = 0; v < varList.size(); v++) {
                        if ((testCaseVar = (TestCaseVariable) varList.get(v)) != null) {
                            /*
								 * if variables have same name, then update the value
								 */
                            if (testCaseVar.getName().equalsIgnoreCase((String) treeObjectEvent.oldValue)) {
                                testCaseVar.setName((String) treeObjectEvent.newValue);
                                testCaseVar.hasChanged = true;
                                updateNameReference(isSameValue, shouldUpdate, testCaseVar, (String) treeObjectEvent.newValue);
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        ConvertigoPlugin.logException(e, "Unable to propagate variable " + (String) treeObjectEvent.oldValue + " renaming to testcase in '" + parentName + "'!");
    }
}
Also used : TestCase(com.twinsoft.convertigo.beans.core.TestCase) EngineException(com.twinsoft.convertigo.engine.EngineException) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable)

Example 7 with TestCase

use of com.twinsoft.convertigo.beans.core.TestCase in project convertigo by convertigo.

the class ServletRequester method initContext.

@Override
public void initContext(Context context) throws Exception {
    HttpServletRequest request = (HttpServletRequest) inputData;
    context.setRequest(request);
    super.initContext(context);
    context.subPath = subPath;
    boolean bConnectorGivenByUser = false;
    Engine.logContext.debug("(Servlet requester.initContext) Query string: " + request.getQueryString());
    // We transform the HTTP post data into XML data.
    Enumeration<?> parameterNames = request.getParameterNames();
    String parameterName, parameterValue;
    String[] parameterValues = null;
    while (parameterNames.hasMoreElements()) {
        parameterName = (String) parameterNames.nextElement();
        parameterValues = request.getParameterValues(parameterName);
        parameterValue = parameterValues[0];
        handleParameter(context, parameterName, parameterValue);
        if (parameterName.equals(Parameter.Connector.getName())) {
            bConnectorGivenByUser = true;
        }
    }
    TestCase tc = TestCase.getTestCase(request, context.projectName);
    if (tc != null) {
        for (TestCaseVariable var : tc.getVariables()) {
            parameterName = var.getName();
            if (request.getParameter(parameterName) == null) {
                Object value = var.getValueOrNull();
                if (value == null || (var.isMultiValued() && ((XMLVector<?>) value).isEmpty())) {
                    continue;
                }
                parameterValue = (String) (var.isMultiValued() ? ((XMLVector<?>) value).get(0) : value);
                handleParameter(context, parameterName, parameterValue);
                if (parameterName.equals(Parameter.Connector.getName())) {
                    bConnectorGivenByUser = true;
                }
            }
        }
    }
    if (!bConnectorGivenByUser) {
        if (context.project != null && context.project.getName().equals(context.projectName)) {
            String defaultConnectorName = context.project.getDefaultConnector().getName();
            if (!defaultConnectorName.equals(context.connectorName)) {
                context.connectorName = defaultConnectorName;
            }
        }
    }
    Engine.logContext.debug("Context initialized!");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) TestCase(com.twinsoft.convertigo.beans.core.TestCase) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable)

Example 8 with TestCase

use of com.twinsoft.convertigo.beans.core.TestCase in project convertigo by convertigo.

the class InternalRequester method initContext.

@Override
public void initContext(Context context) throws Exception {
    if (httpServletRequest != null) {
        context.setRequest(httpServletRequest);
    }
    super.initContext(context);
    Map<String, Object> request = GenericUtils.cast(inputData);
    // We transform the HTTP post data into XML data.
    Set<String> parameterNames = request.keySet();
    boolean bConnectorGivenByUser = false;
    for (String parameterName : parameterNames) {
        String parameterValue;
        // Handle only convertigo parameters
        if (parameterName.startsWith("__")) {
            Object parameterObjectValue = request.get(parameterName);
            parameterValue = getParameterValue(parameterObjectValue);
            handleParameter(context, parameterName, parameterValue);
            if (parameterName.equals(Parameter.Connector.getName())) {
                bConnectorGivenByUser = true;
            }
        }
    }
    TestCase tc = TestCase.getTestCase(request, context.projectName);
    if (tc != null) {
        for (TestCaseVariable var : tc.getVariables()) {
            String parameterName = var.getName();
            String parameterValue;
            // Handle only convertigo parameters
            if (!request.containsKey(parameterName) && parameterName.startsWith("__")) {
                Object parameterObjectValue = var.getValueOrNull();
                parameterValue = getParameterValue(parameterObjectValue);
                if (parameterValue != null) {
                    handleParameter(context, parameterName, parameterValue);
                    if (parameterName.equals(Parameter.Connector.getName())) {
                        bConnectorGivenByUser = true;
                    }
                }
            }
        }
    }
    if (!bConnectorGivenByUser) {
        if (context.project != null && context.project.getName().equals(context.projectName)) {
            String defaultConnectorName = context.project.getDefaultConnector().getName();
            if (!defaultConnectorName.equals(context.connectorName)) {
                context.connectorName = defaultConnectorName;
            }
        }
    }
    Engine.logContext.debug("Context initialized!");
}
Also used : TestCase(com.twinsoft.convertigo.beans.core.TestCase) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable)

Example 9 with TestCase

use of com.twinsoft.convertigo.beans.core.TestCase in project convertigo by convertigo.

the class TestCaseExecuteSelectedAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            if ((treeObject != null) && (treeObject instanceof TestCaseTreeObject)) {
                TestCase testCase = (TestCase) treeObject.getObject();
                ProjectTreeObject projectTreeObject = treeObject.getProjectTreeObject();
                RequestableObject requestable = (RequestableObject) testCase.getParent();
                if (requestable instanceof Transaction) {
                    TransactionTreeObject transactionTreeObject = (TransactionTreeObject) treeObject.getParent().getParent();
                    transactionTreeObject.getConnectorTreeObject().openConnectorEditor();
                    Transaction transaction = (Transaction) testCase.getParent();
                    Connector connector = (Connector) transaction.getParent();
                    ConnectorEditor connectorEditor = projectTreeObject.getConnectorEditor(connector);
                    if (connectorEditor != null) {
                        getActivePage().activate(connectorEditor);
                        connectorEditor.getDocument(transaction.getName(), testCase.getName(), false);
                    }
                }
                if (requestable instanceof Sequence) {
                    SequenceTreeObject sequenceTreeObject = (SequenceTreeObject) treeObject.getParent().getParent();
                    new SequenceExecuteSelectedAction().openEditors(explorerView, sequenceTreeObject);
                    Sequence sequence = (Sequence) testCase.getParent();
                    SequenceEditor sequenceEditor = projectTreeObject.getSequenceEditor(sequence);
                    if (sequenceEditor != null) {
                        getActivePage().activate(sequenceEditor);
                        sequenceEditor.getDocument(sequence.getName(), testCase.getName(), false);
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to execute the selected test case!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) Connector(com.twinsoft.convertigo.beans.core.Connector) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) Sequence(com.twinsoft.convertigo.beans.core.Sequence) SequenceEditor(com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditor) Cursor(org.eclipse.swt.graphics.Cursor) ConnectorEditor(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor) TestCaseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TestCaseTreeObject) Shell(org.eclipse.swt.widgets.Shell) Transaction(com.twinsoft.convertigo.beans.core.Transaction) TestCase(com.twinsoft.convertigo.beans.core.TestCase) TestCaseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TestCaseTreeObject) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) Display(org.eclipse.swt.widgets.Display)

Example 10 with TestCase

use of com.twinsoft.convertigo.beans.core.TestCase in project convertigo by convertigo.

the class TestCaseImportRequestableVariablesAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            Object databaseObject = treeObject.getObject();
            if ((databaseObject != null) && (databaseObject instanceof TestCase)) {
                TestCase testCase = (TestCase) databaseObject;
                testCase.importRequestableVariables((RequestableObject) testCase.getParent());
                if (testCase.hasChanged) {
                    explorerView.reloadTreeObject(treeObject);
                    StructuredSelection structuredSelection = new StructuredSelection(treeObject);
                    ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to add requestable variables to test case!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) TestCase(com.twinsoft.convertigo.beans.core.TestCase) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) Cursor(org.eclipse.swt.graphics.Cursor) Display(org.eclipse.swt.widgets.Display)

Aggregations

TestCase (com.twinsoft.convertigo.beans.core.TestCase)17 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)8 Sequence (com.twinsoft.convertigo.beans.core.Sequence)8 Transaction (com.twinsoft.convertigo.beans.core.Transaction)7 TestCaseVariable (com.twinsoft.convertigo.beans.variables.TestCaseVariable)7 Connector (com.twinsoft.convertigo.beans.core.Connector)6 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)6 EngineException (com.twinsoft.convertigo.engine.EngineException)6 Variable (com.twinsoft.convertigo.beans.core.Variable)5 WalkHelper (com.twinsoft.convertigo.engine.helpers.WalkHelper)5 XMLVector (com.twinsoft.convertigo.beans.common.XMLVector)4 Criteria (com.twinsoft.convertigo.beans.core.Criteria)4 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)4 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)4 Sheet (com.twinsoft.convertigo.beans.core.Sheet)4 Statement (com.twinsoft.convertigo.beans.core.Statement)4 TransactionWithVariables (com.twinsoft.convertigo.beans.core.TransactionWithVariables)4 HTTPStatement (com.twinsoft.convertigo.beans.statements.HTTPStatement)4 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)4 ExtractionRule (com.twinsoft.convertigo.beans.core.ExtractionRule)3