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.
-
#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.
-
#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.
-
#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, 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, steps: nil, scenario_name: nil, scenario_state: nil, new_scenario_state: nil) ⇒ Expectation
Returns a new instance of Expectation.
1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 |
# File 'lib/mockserver/models.rb', line 1669 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, 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 @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 @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 @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.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def after_actions @after_actions end |
#before_actions ⇒ Object
Returns the value of attribute before_actions.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def before_actions @before_actions end |
#binary_response ⇒ Object
Returns the value of attribute binary_response.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def binary_response @binary_response end |
#chaos ⇒ Object
Returns the value of attribute chaos.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def chaos @chaos end |
#dns_response ⇒ Object
Returns the value of attribute dns_response.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def dns_response @dns_response end |
#grpc_bidi_response ⇒ Object
Returns the value of attribute grpc_bidi_response.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def grpc_bidi_response @grpc_bidi_response end |
#grpc_stream_response ⇒ Object
Returns the value of attribute grpc_stream_response.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def grpc_stream_response @grpc_stream_response end |
#http_error ⇒ Object
Returns the value of attribute http_error.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_error @http_error end |
#http_forward ⇒ Object
Returns the value of attribute http_forward.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_forward @http_forward end |
#http_forward_class_callback ⇒ Object
Returns the value of attribute http_forward_class_callback.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_forward_class_callback @http_forward_class_callback end |
#http_forward_object_callback ⇒ Object
Returns the value of attribute http_forward_object_callback.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_forward_object_callback @http_forward_object_callback end |
#http_forward_template ⇒ Object
Returns the value of attribute http_forward_template.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_forward_template @http_forward_template end |
#http_override_forwarded_request ⇒ Object
Returns the value of attribute http_override_forwarded_request.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_override_forwarded_request @http_override_forwarded_request end |
#http_request ⇒ Object
Returns the value of attribute http_request.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_request @http_request end |
#http_response ⇒ Object
Returns the value of attribute http_response.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_response @http_response end |
#http_response_class_callback ⇒ Object
Returns the value of attribute http_response_class_callback.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_response_class_callback @http_response_class_callback end |
#http_response_object_callback ⇒ Object
Returns the value of attribute http_response_object_callback.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_response_object_callback @http_response_object_callback end |
#http_response_template ⇒ Object
Returns the value of attribute http_response_template.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_response_template @http_response_template end |
#http_responses ⇒ Object
Returns the value of attribute http_responses.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_responses @http_responses end |
#http_sse_response ⇒ Object
Returns the value of attribute http_sse_response.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_sse_response @http_sse_response end |
#http_websocket_response ⇒ Object
Returns the value of attribute http_websocket_response.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def http_websocket_response @http_websocket_response end |
#id ⇒ Object
Returns the value of attribute id.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def id @id end |
#new_scenario_state ⇒ Object
Returns the value of attribute new_scenario_state.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def new_scenario_state @new_scenario_state end |
#percentage ⇒ Object
Returns the value of attribute percentage.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def percentage @percentage end |
#priority ⇒ Object
Returns the value of attribute priority.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def priority @priority end |
#response_mode ⇒ Object
Returns the value of attribute response_mode.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def response_mode @response_mode end |
#scenario_name ⇒ Object
Returns the value of attribute scenario_name.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def scenario_name @scenario_name end |
#scenario_state ⇒ Object
Returns the value of attribute scenario_state.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def scenario_state @scenario_state end |
#steps ⇒ Object
Returns the value of attribute steps.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def steps @steps end |
#time_to_live ⇒ Object
Returns the value of attribute time_to_live.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def time_to_live @time_to_live end |
#times ⇒ Object
Returns the value of attribute times.
1656 1657 1658 |
# File 'lib/mockserver/models.rb', line 1656 def times @times end |
Class Method Details
.from_hash(data) ⇒ Object
1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 |
# File 'lib/mockserver/models.rb', line 1764 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'], 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
1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 |
# File 'lib/mockserver/models.rb', line 1714 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, '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 |