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.
-
#before_actions ⇒ Object
Returns the value of attribute before_actions.
-
#binary_response ⇒ Object
Returns the value of attribute binary_response.
-
#chaos ⇒ Object
Returns the value of attribute chaos.
-
#cross_protocol_scenarios ⇒ Object
Returns the value of attribute cross_protocol_scenarios.
-
#dns_response ⇒ Object
Returns the value of attribute dns_response.
-
#grpc_bidi_response ⇒ Object
Returns the value of attribute grpc_bidi_response.
-
#grpc_stream_response ⇒ Object
Returns the value of attribute grpc_stream_response.
-
#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.
-
#response_weights ⇒ Object
Returns the value of attribute response_weights.
-
#scenario_name ⇒ Object
Returns the value of attribute scenario_name.
-
#scenario_state ⇒ Object
Returns the value of attribute scenario_state.
-
#steps ⇒ Object
Returns the value of attribute steps.
-
#switch_after ⇒ Object
Returns the value of attribute switch_after.
-
#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, chaos: nil, http_sse_response: nil, http_websocket_response: nil, grpc_stream_response: nil, grpc_bidi_response: nil, binary_response: nil, dns_response: nil, before_actions: nil, after_actions: nil, http_responses: nil, response_mode: nil, response_weights: nil, switch_after: nil, cross_protocol_scenarios: nil, steps: 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, chaos: nil, http_sse_response: nil, http_websocket_response: nil, grpc_stream_response: nil, grpc_bidi_response: nil, binary_response: nil, dns_response: nil, before_actions: nil, after_actions: nil, http_responses: nil, response_mode: nil, response_weights: nil, switch_after: nil, cross_protocol_scenarios: nil, steps: nil, scenario_name: nil, scenario_state: nil, new_scenario_state: nil) ⇒ Expectation
Returns a new instance of Expectation.
1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 |
# File 'lib/mockserver/models.rb', line 1902 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, chaos: nil, http_sse_response: nil, http_websocket_response: nil, grpc_stream_response: nil, grpc_bidi_response: nil, binary_response: nil, dns_response: nil, before_actions: nil, after_actions: nil, http_responses: nil, response_mode: nil, response_weights: nil, switch_after: nil, cross_protocol_scenarios: nil, steps: 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 # Route the two class-callback fields through their setters so a bare # class-name String passed to the constructor is coerced to an # HttpClassCallback (matching the setter / fluent-builder behaviour). self.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 self.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 @chaos = chaos @http_sse_response = http_sse_response @http_websocket_response = http_websocket_response @grpc_stream_response = grpc_stream_response @grpc_bidi_response = grpc_bidi_response @binary_response = binary_response @dns_response = dns_response @before_actions = before_actions @after_actions = after_actions @http_responses = http_responses @response_mode = response_mode @response_weights = response_weights @switch_after = switch_after @cross_protocol_scenarios = cross_protocol_scenarios @steps = steps @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.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def after_actions @after_actions end |
#before_actions ⇒ Object
Returns the value of attribute before_actions.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def before_actions @before_actions end |
#binary_response ⇒ Object
Returns the value of attribute binary_response.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def binary_response @binary_response end |
#chaos ⇒ Object
Returns the value of attribute chaos.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def chaos @chaos end |
#cross_protocol_scenarios ⇒ Object
Returns the value of attribute cross_protocol_scenarios.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def cross_protocol_scenarios @cross_protocol_scenarios end |
#dns_response ⇒ Object
Returns the value of attribute dns_response.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def dns_response @dns_response end |
#grpc_bidi_response ⇒ Object
Returns the value of attribute grpc_bidi_response.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def grpc_bidi_response @grpc_bidi_response end |
#grpc_stream_response ⇒ Object
Returns the value of attribute grpc_stream_response.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def grpc_stream_response @grpc_stream_response end |
#http_error ⇒ Object
Returns the value of attribute http_error.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_error @http_error end |
#http_forward ⇒ Object
Returns the value of attribute http_forward.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_forward @http_forward end |
#http_forward_class_callback ⇒ Object
Returns the value of attribute http_forward_class_callback.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_forward_class_callback @http_forward_class_callback end |
#http_forward_object_callback ⇒ Object
Returns the value of attribute http_forward_object_callback.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_forward_object_callback @http_forward_object_callback end |
#http_forward_template ⇒ Object
Returns the value of attribute http_forward_template.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_forward_template @http_forward_template end |
#http_override_forwarded_request ⇒ Object
Returns the value of attribute http_override_forwarded_request.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_override_forwarded_request @http_override_forwarded_request end |
#http_request ⇒ Object
Returns the value of attribute http_request.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_request @http_request end |
#http_response ⇒ Object
Returns the value of attribute http_response.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_response @http_response end |
#http_response_class_callback ⇒ Object
Returns the value of attribute http_response_class_callback.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_response_class_callback @http_response_class_callback end |
#http_response_object_callback ⇒ Object
Returns the value of attribute http_response_object_callback.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_response_object_callback @http_response_object_callback end |
#http_response_template ⇒ Object
Returns the value of attribute http_response_template.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_response_template @http_response_template end |
#http_responses ⇒ Object
Returns the value of attribute http_responses.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_responses @http_responses end |
#http_sse_response ⇒ Object
Returns the value of attribute http_sse_response.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_sse_response @http_sse_response end |
#http_websocket_response ⇒ Object
Returns the value of attribute http_websocket_response.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def http_websocket_response @http_websocket_response end |
#id ⇒ Object
Returns the value of attribute id.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def id @id end |
#new_scenario_state ⇒ Object
Returns the value of attribute new_scenario_state.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def new_scenario_state @new_scenario_state end |
#percentage ⇒ Object
Returns the value of attribute percentage.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def percentage @percentage end |
#priority ⇒ Object
Returns the value of attribute priority.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def priority @priority end |
#response_mode ⇒ Object
Returns the value of attribute response_mode.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def response_mode @response_mode end |
#response_weights ⇒ Object
Returns the value of attribute response_weights.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def response_weights @response_weights end |
#scenario_name ⇒ Object
Returns the value of attribute scenario_name.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def scenario_name @scenario_name end |
#scenario_state ⇒ Object
Returns the value of attribute scenario_state.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def scenario_state @scenario_state end |
#steps ⇒ Object
Returns the value of attribute steps.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def steps @steps end |
#switch_after ⇒ Object
Returns the value of attribute switch_after.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def switch_after @switch_after end |
#time_to_live ⇒ Object
Returns the value of attribute time_to_live.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def time_to_live @time_to_live end |
#times ⇒ Object
Returns the value of attribute times.
1888 1889 1890 |
# File 'lib/mockserver/models.rb', line 1888 def times @times end |
Class Method Details
.from_hash(data) ⇒ Object
2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 |
# File 'lib/mockserver/models.rb', line 2023 def self.from_hash(data) return nil if data.nil? before_actions_data = data['beforeActions'] before_actions = if before_actions_data.is_a?(Array) before_actions_data.map { |a| AfterAction.from_hash(a) } elsif before_actions_data [AfterAction.from_hash(before_actions_data)] end 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']), grpc_stream_response: GrpcStreamResponse.from_hash(data['grpcStreamResponse']), grpc_bidi_response: GrpcBidiResponse.from_hash(data['grpcBidiResponse']), binary_response: BinaryResponse.from_hash(data['binaryResponse']), dns_response: DnsResponse.from_hash(data['dnsResponse']), before_actions: before_actions, after_actions: after_actions, http_responses: data['httpResponses']&.map { |r| HttpResponse.from_hash(r) }, response_mode: data['responseMode'], response_weights: data['responseWeights'], switch_after: data['switchAfter'], cross_protocol_scenarios: data['crossProtocolScenarios']&.map { |c| CrossProtocolScenario.from_hash(c) }, steps: data['steps']&.map { |s| ExpectationStep.from_hash(s) }, times: Times.from_hash(data['times']), time_to_live: TimeToLive.from_hash(data['timeToLive']), chaos: HttpChaosProfile.from_hash(data['chaos']), scenario_name: data['scenarioName'], scenario_state: data['scenarioState'], new_scenario_state: data['newScenarioState'] ) end |
Instance Method Details
#to_h ⇒ Object
1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 |
# File 'lib/mockserver/models.rb', line 1970 def to_h before_actions_h = nil if @before_actions.is_a?(Array) before_actions_h = @before_actions.map(&:to_h) unless @before_actions.empty? elsif @before_actions before_actions_h = @before_actions.to_h end 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, 'grpcStreamResponse' => @grpc_stream_response&.to_h, 'grpcBidiResponse' => @grpc_bidi_response&.to_h, 'binaryResponse' => @binary_response&.to_h, 'dnsResponse' => @dns_response&.to_h, 'beforeActions' => before_actions_h, 'afterActions' => after_actions_h, 'httpResponses' => @http_responses&.map(&:to_h), 'responseMode' => @response_mode, 'responseWeights' => @response_weights, 'switchAfter' => @switch_after, 'crossProtocolScenarios' => @cross_protocol_scenarios&.map(&:to_h), 'steps' => @steps&.map(&:to_h), 'times' => @times&.to_h, 'timeToLive' => @time_to_live&.to_h, 'chaos' => @chaos&.to_h, 'scenarioName' => @scenario_name, 'scenarioState' => @scenario_state, 'newScenarioState' => @new_scenario_state }) end |