Class: MockServer::Expectation
- Inherits:
-
Object
- Object
- MockServer::Expectation
- Defined in:
- lib/mockserver/models.rb
Instance Attribute Summary collapse
-
#after_actions ⇒ Object
Returns the value of attribute after_actions.
-
#http_error ⇒ Object
Returns the value of attribute http_error.
-
#http_forward ⇒ Object
Returns the value of attribute http_forward.
-
#http_forward_class_callback ⇒ Object
Returns the value of attribute http_forward_class_callback.
-
#http_forward_object_callback ⇒ Object
Returns the value of attribute http_forward_object_callback.
-
#http_forward_template ⇒ Object
Returns the value of attribute http_forward_template.
-
#http_override_forwarded_request ⇒ Object
Returns the value of attribute http_override_forwarded_request.
-
#http_request ⇒ Object
Returns the value of attribute http_request.
-
#http_response ⇒ Object
Returns the value of attribute http_response.
-
#http_response_class_callback ⇒ Object
Returns the value of attribute http_response_class_callback.
-
#http_response_object_callback ⇒ Object
Returns the value of attribute http_response_object_callback.
-
#http_response_template ⇒ Object
Returns the value of attribute http_response_template.
-
#http_responses ⇒ Object
Returns the value of attribute http_responses.
-
#http_sse_response ⇒ Object
Returns the value of attribute http_sse_response.
-
#http_websocket_response ⇒ Object
Returns the value of attribute http_websocket_response.
-
#id ⇒ Object
Returns the value of attribute id.
-
#new_scenario_state ⇒ Object
Returns the value of attribute new_scenario_state.
-
#percentage ⇒ Object
Returns the value of attribute percentage.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#response_mode ⇒ Object
Returns the value of attribute response_mode.
-
#scenario_name ⇒ Object
Returns the value of attribute scenario_name.
-
#scenario_state ⇒ Object
Returns the value of attribute scenario_state.
-
#time_to_live ⇒ Object
Returns the value of attribute time_to_live.
-
#times ⇒ Object
Returns the value of attribute times.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id: nil, priority: nil, percentage: nil, http_request: nil, http_response: nil, http_response_template: nil, http_response_class_callback: nil, http_response_object_callback: nil, http_forward: nil, http_forward_template: nil, http_forward_class_callback: nil, http_forward_object_callback: nil, http_override_forwarded_request: nil, http_error: nil, times: nil, time_to_live: nil, http_sse_response: nil, http_websocket_response: nil, after_actions: nil, http_responses: nil, response_mode: nil, scenario_name: nil, scenario_state: nil, new_scenario_state: nil) ⇒ Expectation
constructor
A new instance of Expectation.
- #to_h ⇒ Object
Constructor Details
#initialize(id: nil, priority: nil, percentage: nil, http_request: nil, http_response: nil, http_response_template: nil, http_response_class_callback: nil, http_response_object_callback: nil, http_forward: nil, http_forward_template: nil, http_forward_class_callback: nil, http_forward_object_callback: nil, http_override_forwarded_request: nil, http_error: nil, times: nil, time_to_live: nil, http_sse_response: nil, http_websocket_response: nil, after_actions: nil, http_responses: nil, response_mode: nil, scenario_name: nil, scenario_state: nil, new_scenario_state: nil) ⇒ Expectation
Returns a new instance of Expectation.
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 |
# File 'lib/mockserver/models.rb', line 1191 def initialize(id: nil, priority: nil, percentage: nil, http_request: nil, http_response: nil, http_response_template: nil, http_response_class_callback: nil, http_response_object_callback: nil, http_forward: nil, http_forward_template: nil, http_forward_class_callback: nil, http_forward_object_callback: nil, http_override_forwarded_request: nil, http_error: nil, times: nil, time_to_live: nil, http_sse_response: nil, http_websocket_response: nil, after_actions: nil, http_responses: nil, response_mode: nil, scenario_name: nil, scenario_state: nil, new_scenario_state: nil) @id = id @priority = priority @percentage = percentage @http_request = http_request @http_response = http_response @http_response_template = http_response_template @http_response_class_callback = http_response_class_callback @http_response_object_callback = http_response_object_callback @http_forward = http_forward @http_forward_template = http_forward_template @http_forward_class_callback = http_forward_class_callback @http_forward_object_callback = http_forward_object_callback @http_override_forwarded_request = http_override_forwarded_request @http_error = http_error @times = times @time_to_live = time_to_live @http_sse_response = http_sse_response @http_websocket_response = http_websocket_response @after_actions = after_actions @http_responses = http_responses @response_mode = response_mode @scenario_name = scenario_name @scenario_state = scenario_state @new_scenario_state = new_scenario_state end |
Instance Attribute Details
#after_actions ⇒ Object
Returns the value of attribute after_actions.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def after_actions @after_actions end |
#http_error ⇒ Object
Returns the value of attribute http_error.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_error @http_error end |
#http_forward ⇒ Object
Returns the value of attribute http_forward.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_forward @http_forward end |
#http_forward_class_callback ⇒ Object
Returns the value of attribute http_forward_class_callback.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_forward_class_callback @http_forward_class_callback end |
#http_forward_object_callback ⇒ Object
Returns the value of attribute http_forward_object_callback.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_forward_object_callback @http_forward_object_callback end |
#http_forward_template ⇒ Object
Returns the value of attribute http_forward_template.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_forward_template @http_forward_template end |
#http_override_forwarded_request ⇒ Object
Returns the value of attribute http_override_forwarded_request.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_override_forwarded_request @http_override_forwarded_request end |
#http_request ⇒ Object
Returns the value of attribute http_request.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_request @http_request end |
#http_response ⇒ Object
Returns the value of attribute http_response.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_response @http_response end |
#http_response_class_callback ⇒ Object
Returns the value of attribute http_response_class_callback.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_response_class_callback @http_response_class_callback end |
#http_response_object_callback ⇒ Object
Returns the value of attribute http_response_object_callback.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_response_object_callback @http_response_object_callback end |
#http_response_template ⇒ Object
Returns the value of attribute http_response_template.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_response_template @http_response_template end |
#http_responses ⇒ Object
Returns the value of attribute http_responses.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_responses @http_responses end |
#http_sse_response ⇒ Object
Returns the value of attribute http_sse_response.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_sse_response @http_sse_response end |
#http_websocket_response ⇒ Object
Returns the value of attribute http_websocket_response.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def http_websocket_response @http_websocket_response end |
#id ⇒ Object
Returns the value of attribute id.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def id @id end |
#new_scenario_state ⇒ Object
Returns the value of attribute new_scenario_state.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def new_scenario_state @new_scenario_state end |
#percentage ⇒ Object
Returns the value of attribute percentage.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def percentage @percentage end |
#priority ⇒ Object
Returns the value of attribute priority.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def priority @priority end |
#response_mode ⇒ Object
Returns the value of attribute response_mode.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def response_mode @response_mode end |
#scenario_name ⇒ Object
Returns the value of attribute scenario_name.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def scenario_name @scenario_name end |
#scenario_state ⇒ Object
Returns the value of attribute scenario_state.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def scenario_state @scenario_state end |
#time_to_live ⇒ Object
Returns the value of attribute time_to_live.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def time_to_live @time_to_live end |
#times ⇒ Object
Returns the value of attribute times.
1181 1182 1183 |
# File 'lib/mockserver/models.rb', line 1181 def times @times end |
Class Method Details
.from_hash(data) ⇒ Object
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 |
# File 'lib/mockserver/models.rb', line 1262 def self.from_hash(data) return nil if data.nil? after_actions_data = data['afterActions'] after_actions = if after_actions_data.is_a?(Array) after_actions_data.map { |a| AfterAction.from_hash(a) } elsif after_actions_data AfterAction.from_hash(after_actions_data) end new( id: data['id'], priority: data['priority'], percentage: data['percentage'], http_request: HttpRequest.from_hash(data['httpRequest']), http_response: HttpResponse.from_hash(data['httpResponse']), http_response_template: HttpTemplate.from_hash(data['httpResponseTemplate']), http_response_class_callback: HttpClassCallback.from_hash(data['httpResponseClassCallback']), http_response_object_callback: HttpObjectCallback.from_hash(data['httpResponseObjectCallback']), http_forward: HttpForward.from_hash(data['httpForward']), http_forward_template: HttpTemplate.from_hash(data['httpForwardTemplate']), http_forward_class_callback: HttpClassCallback.from_hash(data['httpForwardClassCallback']), http_forward_object_callback: HttpObjectCallback.from_hash(data['httpForwardObjectCallback']), http_override_forwarded_request: HttpOverrideForwardedRequest.from_hash(data['httpOverrideForwardedRequest']), http_error: HttpError.from_hash(data['httpError']), http_sse_response: HttpSseResponse.from_hash(data['httpSseResponse']), http_websocket_response: HttpWebSocketResponse.from_hash(data['httpWebSocketResponse']), after_actions: after_actions, http_responses: data['httpResponses']&.map { |r| HttpResponse.from_hash(r) }, response_mode: data['responseMode'], times: Times.from_hash(data['times']), time_to_live: TimeToLive.from_hash(data['timeToLive']), scenario_name: data['scenarioName'], scenario_state: data['scenarioState'], new_scenario_state: data['newScenarioState'] ) end |
Instance Method Details
#to_h ⇒ Object
1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 |
# File 'lib/mockserver/models.rb', line 1226 def to_h after_actions_h = nil if @after_actions.is_a?(Array) after_actions_h = @after_actions.map(&:to_h) unless @after_actions.empty? elsif @after_actions after_actions_h = @after_actions.to_h end MockServer.strip_none({ 'id' => @id, 'priority' => @priority, 'percentage' => @percentage, 'httpRequest' => @http_request&.to_h, 'httpResponse' => @http_response&.to_h, 'httpResponseTemplate' => @http_response_template&.to_h, 'httpResponseClassCallback' => @http_response_class_callback&.to_h, 'httpResponseObjectCallback' => @http_response_object_callback&.to_h, 'httpForward' => @http_forward&.to_h, 'httpForwardTemplate' => @http_forward_template&.to_h, 'httpForwardClassCallback' => @http_forward_class_callback&.to_h, 'httpForwardObjectCallback' => @http_forward_object_callback&.to_h, 'httpOverrideForwardedRequest' => @http_override_forwarded_request&.to_h, 'httpError' => @http_error&.to_h, 'httpSseResponse' => @http_sse_response&.to_h, 'httpWebSocketResponse' => @http_websocket_response&.to_h, 'afterActions' => after_actions_h, 'httpResponses' => @http_responses&.map(&:to_h), 'responseMode' => @response_mode, 'times' => @times&.to_h, 'timeToLive' => @time_to_live&.to_h, 'scenarioName' => @scenario_name, 'scenarioState' => @scenario_state, 'newScenarioState' => @new_scenario_state }) end |