1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.panels.mockoperation;
14
15 import java.util.Vector;
16
17 import com.eviware.soapui.impl.wsdl.WsdlOperation;
18 import com.eviware.soapui.impl.wsdl.mock.WsdlMockResponse;
19 import com.eviware.soapui.impl.wsdl.mock.WsdlMockResult;
20 import com.eviware.soapui.impl.wsdl.submit.AbstractWsdlMessageExchange;
21 import com.eviware.soapui.model.ModelItem;
22 import com.eviware.soapui.model.iface.Attachment;
23 import com.eviware.soapui.support.types.StringToStringMap;
24
25 /***
26 * WsdlMessageExchange for a WsdlMockResult, required for validations
27 *
28 * @author ole.matzura
29 */
30
31 public class WsdlMockResultMessageExchange extends AbstractWsdlMessageExchange<ModelItem>
32 {
33 private final WsdlMockResult mockResult;
34 private WsdlMockResponse mockResponse;
35
36 public WsdlMockResultMessageExchange( WsdlMockResult mockResult, WsdlMockResponse mockResponse )
37 {
38 super( mockResponse );
39
40 this.mockResult = mockResult;
41 this.mockResponse = mockResponse;
42 }
43
44 public ModelItem getModelItem()
45 {
46 return mockResponse == null ? mockResult.getMockOperation() : mockResponse;
47 }
48
49 public Attachment[] getRequestAttachments()
50 {
51 return mockResult.getMockRequest().getRequestAttachments();
52 }
53
54 public String getRequestContent()
55 {
56 if( mockResult == null || mockResult.getMockRequest() == null )
57 return null;
58
59 return mockResult.getMockRequest().getRequestContent();
60 }
61
62 public StringToStringMap getRequestHeaders()
63 {
64 return mockResult == null ? null : mockResult.getMockRequest().getRequestHeaders();
65 }
66
67 public Attachment[] getResponseAttachments()
68 {
69 return mockResult == null || mockResponse == null ? new Attachment[0] : mockResult.getMockResponse()
70 .getAttachments();
71 }
72
73 public String getResponseContent()
74 {
75 return mockResult == null ? null : mockResult.getResponseContent();
76 }
77
78 public StringToStringMap getResponseHeaders()
79 {
80 return mockResult == null ? null : mockResult.getResponseHeaders();
81 }
82
83 public WsdlOperation getOperation()
84 {
85 if( mockResult.getMockOperation() != null )
86 return mockResult.getMockOperation().getOperation();
87
88 return mockResponse == null ? null : mockResponse.getMockOperation().getOperation();
89 }
90
91 public long getTimeTaken()
92 {
93 return mockResult == null ? -1 : mockResult.getTimeTaken();
94 }
95
96 public long getTimestamp()
97 {
98 return mockResult == null ? -1 : mockResult.getTimestamp();
99 }
100
101 public boolean isDiscarded()
102 {
103 return mockResponse == null;
104 }
105
106 public void discard()
107 {
108 mockResponse = null;
109 }
110
111 public Vector<?> getRequestWssResult()
112 {
113 return mockResult == null ? null : mockResult.getRequestWssResult();
114 }
115
116 public Vector<?> getResponseWssResult()
117 {
118 return null;
119 }
120
121 public int getResponseStatusCode()
122 {
123 return mockResult.getResponseStatus();
124 }
125
126 public String getResponseContentType()
127 {
128 return mockResult.getResponseContentType();
129 }
130 }