use of com.twinsoft.convertigo.beans.core.TestCase in project convertigo by convertigo.
the class ChangeToSingleValuedVariableAction method run.
@Override
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();
TreeParent treeParent = treeObject.getParent();
DatabaseObjectTreeObject parentTreeObject = null;
if (treeParent instanceof DatabaseObjectTreeObject)
parentTreeObject = (DatabaseObjectTreeObject) treeParent;
else
parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
if (parentTreeObject != null) {
Object databaseObject = treeObject.getObject();
if (databaseObject != null) {
Variable multi = (Variable) databaseObject;
Variable simple = null;
if (databaseObject instanceof TestCaseMultiValuedVariable)
simple = new TestCaseVariable();
if (databaseObject instanceof StepMultiValuedVariable)
simple = new StepVariable();
if (databaseObject instanceof RequestableMultiValuedVariable)
simple = new RequestableVariable();
if (databaseObject instanceof RequestableHttpMultiValuedVariable)
simple = new RequestableHttpVariable();
if (databaseObject instanceof HttpStatementMultiValuedVariable)
simple = new HttpStatementVariable();
if (simple != null) {
if (multi instanceof StepMultiValuedVariable) {
((StepVariable) simple).setSourceDefinition(((StepVariable) multi).getSourceDefinition());
}
if (multi instanceof RequestableVariable) {
((RequestableVariable) simple).setXmlTypeAffectation(((RequestableVariable) multi).getXmlTypeAffectation());
}
if (multi instanceof RequestableHttpVariable) {
// HttpName
((RequestableHttpVariable) simple).setHttpName(((RequestableHttpVariable) multi).getHttpName());
// HttpMethod
((RequestableHttpVariable) simple).setHttpMethod(((RequestableHttpVariable) multi).getHttpMethod());
}
XMLVector<Object> xmlv = GenericUtils.cast(multi.getValueOrNull());
Object value = (xmlv == null) ? null : (xmlv.isEmpty() ? "" : xmlv.get(0).toString());
simple.setValueOrNull(value);
simple.setVisibility(multi.getVisibility());
// Comment
simple.setComment(multi.getComment());
// Description
simple.setDescription(multi.getDescription());
// Required
simple.setRequired(multi.isRequired());
simple.bNew = true;
simple.hasChanged = true;
// Add new variable to parent
DatabaseObject parentDbo = multi.getParent();
parentDbo.add(simple);
// Set correct order
if (parentDbo instanceof TestCase)
((TestCase) parentDbo).insertAtOrder(simple, multi.priority);
if (parentDbo instanceof RequestableStep)
((RequestableStep) parentDbo).insertAtOrder(simple, multi.priority);
if (parentDbo instanceof Sequence)
((Sequence) parentDbo).insertAtOrder(simple, multi.priority);
if (parentDbo instanceof TransactionWithVariables)
((TransactionWithVariables) parentDbo).insertAtOrder(simple, multi.priority);
if (parentDbo instanceof HTTPStatement)
((HTTPStatement) parentDbo).insertAtOrder(simple, multi.priority);
// Add new variable in Tree
VariableTreeObject2 varTreeObject = new VariableTreeObject2(explorerView.viewer, simple);
treeParent.addChild(varTreeObject);
// Delete simple variable
multi.delete();
// Set correct name
simple.setName(multi.getName());
parentTreeObject.hasBeenModified(true);
explorerView.reloadTreeObject(parentTreeObject);
explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(simple));
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to change simple variable to multi valuated variable!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
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 + "'!");
}
}
use of com.twinsoft.convertigo.beans.core.TestCase in project convertigo by convertigo.
the class TestCaseExecuteSelectedAction method run2.
@Override
protected void run2() throws Exception {
try {
WrapDatabaseObject treeObject = (WrapDatabaseObject) studio.getFirstSelectedTreeObject();
if ((treeObject != null) && (treeObject.instanceOf(TestCase.class))) {
TestCase testCase = (TestCase) treeObject.getObject();
ProjectView projectTreeObject = treeObject.getProjectViewObject();
RequestableObject requestable = (RequestableObject) testCase.getParent();
if (requestable instanceof Transaction) {
TransactionView transactionTreeObject = (TransactionView) treeObject.getParent();
transactionTreeObject.getConnectorTreeObject().openConnectorEditor();
Transaction transaction = (Transaction) testCase.getParent();
Connector connector = (Connector) transaction.getParent();
ConnectorEditorWrap connectorEditor = projectTreeObject.getConnectorEditor(connector);
if (connectorEditor != null) {
// getActivePage().activate(connectorEditor);
connectorEditor.getDocument(transaction.getName(), testCase.getName(), false);
}
} else if (requestable instanceof Sequence) {
SequenceView sequenceTreeObject = (SequenceView) treeObject.getParent();
new SequenceExecuteSelectedAction(studio).openEditors(sequenceTreeObject);
Sequence sequence = (Sequence) testCase.getParent();
SequenceEditorWrap sequenceEditor = projectTreeObject.getSequenceEditor(sequence);
if (sequenceEditor != null) {
// getActivePage().activate(sequenceEditor);
sequenceEditor.getDocument(sequence.getName(), testCase.getName(), false);
}
}
}
} catch (Exception e) {
throw e;
}
}
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!");
}
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!");
}
Aggregations