1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.teststeps.actions;
14
15 import com.eviware.soapui.impl.WsdlInterfaceFactory;
16 import com.eviware.soapui.impl.wsdl.WsdlInterface;
17 import com.eviware.soapui.impl.wsdl.WsdlOperation;
18 import com.eviware.soapui.impl.wsdl.WsdlProject;
19 import com.eviware.soapui.impl.wsdl.teststeps.WsdlAsyncResponseTestStep;
20 import com.eviware.soapui.model.support.ModelSupport;
21 import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
22 import com.eviware.x.form.XFormDialog;
23 import com.eviware.x.form.XFormField;
24 import com.eviware.x.form.XFormFieldListener;
25 import com.eviware.x.form.support.ADialogBuilder;
26 import com.eviware.x.form.support.AField;
27 import com.eviware.x.form.support.AForm;
28 import com.eviware.x.form.support.AField.AFieldType;
29
30 public class SetAsyncResponseMockOperationAction extends AbstractSoapUIAction<WsdlAsyncResponseTestStep>
31 {
32 private XFormDialog dialog;
33 private WsdlAsyncResponseTestStep testStep;
34
35 public SetAsyncResponseMockOperationAction()
36 {
37 super("Set MockOperation", "Sets the operation to mock");
38 }
39
40 public void perform(WsdlAsyncResponseTestStep target, Object param)
41 {
42 this.testStep = target;
43
44 if (dialog == null)
45 {
46 dialog = ADialogBuilder.buildDialog(Form.class);
47 dialog.getFormField(Form.INTERFACE).addFormFieldListener(new XFormFieldListener()
48 {
49 public void valueChanged(XFormField sourceField, String newValue, String oldValue)
50 {
51 WsdlProject project = testStep.getTestCase().getTestSuite().getProject();
52 dialog.setOptions(Form.OPERATION, ModelSupport.getNames(project
53 .getInterfaceByName(newValue).getOperationList()));
54 }
55 });
56 }
57
58 WsdlProject project = target.getTestCase().getTestSuite().getProject();
59 dialog.setOptions(Form.INTERFACE, ModelSupport.getNames(project.getInterfaceList(),
60 new ModelSupport.InterfaceTypeFilter( WsdlInterfaceFactory.WSDL_TYPE )));
61 dialog.setValue(Form.INTERFACE, target.getInterface().getName());
62
63 dialog.setOptions(Form.OPERATION, ModelSupport.getNames(project.getInterfaceByName(
64 target.getInterface().getName()).getOperationList()));
65 dialog.setValue(Form.OPERATION, target.getOperation().getName());
66
67 if (dialog.show())
68 {
69 String ifaceName = dialog.getValue(Form.INTERFACE);
70 String operationName = dialog.getValue(Form.OPERATION);
71
72 WsdlInterface iface = (WsdlInterface) project.getInterfaceByName(ifaceName);
73 WsdlOperation operation = iface.getOperationByName( operationName );
74 target.setOperation(operation.getName());
75 }
76 }
77
78 @AForm(description = "Specify Interface/Operation for AsyncResponse", name = "Set Mock Operation")
79 protected interface Form
80 {
81 @AField(name = "Interface", description = "The interface to mock", type = AFieldType.ENUMERATION)
82 public final static String INTERFACE = "Interface";
83
84 @AField(name = "Operation", description = "The operation to mock", type = AFieldType.ENUMERATION)
85 public final static String OPERATION = "Operation";
86 }
87 }