testerhjnew 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +55 -0
  4. data/lib/tester.rb +56 -0
  5. data/lib/tester/api_helper.rb +261 -0
  6. data/lib/tester/configuration.rb +66 -0
  7. data/lib/tester/controllers/base_controller.rb +59 -0
  8. data/lib/tester/controllers/body_params_controller.rb +1270 -0
  9. data/lib/tester/controllers/echo_controller.rb +134 -0
  10. data/lib/tester/controllers/error_codes_controller.rb +179 -0
  11. data/lib/tester/controllers/form_params_controller.rb +1391 -0
  12. data/lib/tester/controllers/header_controller.rb +63 -0
  13. data/lib/tester/controllers/query_param_controller.rb +779 -0
  14. data/lib/tester/controllers/response_types_controller.rb +717 -0
  15. data/lib/tester/controllers/template_params_controller.rb +93 -0
  16. data/lib/tester/exceptions/api_exception.rb +18 -0
  17. data/lib/tester/exceptions/global_test_exception.rb +32 -0
  18. data/lib/tester/exceptions/local_test_exception.rb +30 -0
  19. data/lib/tester/exceptions/nested_model_exception.rb +37 -0
  20. data/lib/tester/http/faraday_client.rb +55 -0
  21. data/lib/tester/http/http_call_back.rb +22 -0
  22. data/lib/tester/http/http_client.rb +92 -0
  23. data/lib/tester/http/http_context.rb +18 -0
  24. data/lib/tester/http/http_method_enum.rb +11 -0
  25. data/lib/tester/http/http_request.rb +48 -0
  26. data/lib/tester/http/http_response.rb +21 -0
  27. data/lib/tester/models/additional_model_parameters.rb +70 -0
  28. data/lib/tester/models/base_model.rb +52 -0
  29. data/lib/tester/models/boss.rb +129 -0
  30. data/lib/tester/models/days.rb +30 -0
  31. data/lib/tester/models/delete_body.rb +52 -0
  32. data/lib/tester/models/echo_response.rb +88 -0
  33. data/lib/tester/models/employee.rb +155 -0
  34. data/lib/tester/models/job.rb +43 -0
  35. data/lib/tester/models/person.rb +113 -0
  36. data/lib/tester/models/query_parameter.rb +43 -0
  37. data/lib/tester/models/server_response.rb +61 -0
  38. data/lib/tester/models/suite_code.rb +21 -0
  39. data/lib/tester/models/test_nstring_encoding.rb +52 -0
  40. data/lib/tester/models/test_r_nstring_encoding.rb +52 -0
  41. data/lib/tester/models/test_rstring_encoding.rb +52 -0
  42. data/lib/tester/models/validate.rb +61 -0
  43. data/lib/tester/tester_client.rb +61 -0
  44. data/test/controllers/controller_test_base.rb +33 -0
  45. data/test/controllers/test_body_params_controller.rb +1210 -0
  46. data/test/controllers/test_echo_controller.rb +29 -0
  47. data/test/controllers/test_error_codes_controller.rb +47 -0
  48. data/test/controllers/test_form_params_controller.rb +1099 -0
  49. data/test/controllers/test_header_controller.rb +30 -0
  50. data/test/controllers/test_query_param_controller.rb +345 -0
  51. data/test/controllers/test_response_types_controller.rb +429 -0
  52. data/test/controllers/test_template_params_controller.rb +47 -0
  53. data/test/http_response_catcher.rb +16 -0
  54. data/test/test_helper.rb +91 -0
  55. metadata +178 -0
@@ -0,0 +1,21 @@
1
+ # This file was automatically generated for Stamplay by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module Tester
5
+ # Http response received.
6
+ class HttpResponse
7
+ attr_accessor :status_code, :headers, :raw_body
8
+
9
+ # The constructor
10
+ # @param [Integer] The status code returned by the server.
11
+ # @param [Hash] The headers sent by the server in the response.
12
+ # @param [String] The raw body of the response.
13
+ def initialize(status_code,
14
+ headers,
15
+ raw_body)
16
+ @status_code = status_code
17
+ @headers = headers
18
+ @raw_body = raw_body
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,70 @@
1
+ # This file was automatically generated for Stamplay by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module Tester
5
+ # AdditionalModelParameters Model.
6
+ class AdditionalModelParameters < BaseModel
7
+ # TODO: Write general description for this method
8
+ # @return [Job]
9
+ attr_accessor :job
10
+
11
+ # TODO: Write general description for this method
12
+ # @return [String]
13
+ attr_accessor :address
14
+
15
+ # TODO: Write general description for this method
16
+ # @return [String]
17
+ attr_accessor :field
18
+
19
+ # TODO: Write general description for this method
20
+ # @return [String]
21
+ attr_accessor :name
22
+
23
+ # A mapping from model property names to API property names.
24
+ def self.names
25
+ @_hash = {} if @_hash.nil?
26
+ @_hash['job'] = 'Job'
27
+ @_hash['address'] = 'address'
28
+ @_hash['field'] = 'field'
29
+ @_hash['name'] = 'name'
30
+ @_hash
31
+ end
32
+
33
+ def initialize(job = nil,
34
+ address = nil,
35
+ field = nil,
36
+ name = nil,
37
+ additional_properties = {})
38
+ @job = job
39
+ @address = address
40
+ @field = field
41
+ @name = name
42
+
43
+ # Add additional model properties to the instance.
44
+ additional_properties.each do |_name, value|
45
+ instance_variable_set("@#{_name}", value)
46
+ end
47
+ end
48
+
49
+ # Creates an instance of the object from a hash.
50
+ def self.from_hash(hash)
51
+ return nil unless hash
52
+
53
+ # Extract variables from the hash.
54
+ job = Job.from_hash(hash['Job']) if hash['Job']
55
+ address = hash['address']
56
+ field = hash['field']
57
+ name = hash['name']
58
+
59
+ # Clean out expected properties from Hash.
60
+ names.each_value { |k| hash.delete(k) }
61
+
62
+ # Create object from extracted values.
63
+ AdditionalModelParameters.new(job,
64
+ address,
65
+ field,
66
+ name,
67
+ hash)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,52 @@
1
+ # This file was automatically generated for Stamplay by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module Tester
5
+ # Base model.
6
+ class BaseModel
7
+ # Returns a Hash representation of the current object.
8
+ def to_hash
9
+ hash = {}
10
+ instance_variables.each do |name|
11
+ value = instance_variable_get(name)
12
+ name = name[1..-1]
13
+ key = self.class.names.key?(name) ? self.class.names[name] : name
14
+ if value.instance_of? Array
15
+ hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
16
+ elsif value.instance_of? Hash
17
+ hash[key] = {}
18
+ value.each do |k, v|
19
+ hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
20
+ end
21
+ else
22
+ hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
23
+ end
24
+ end
25
+ hash
26
+ end
27
+
28
+ # Returns a JSON representation of the curent object.
29
+ def to_json(options = {})
30
+ hash = to_hash
31
+ hash.to_json(options)
32
+ end
33
+
34
+ # Use to allow additional model properties.
35
+ def method_missing(method_sym, *arguments, &block)
36
+ method = method_sym.to_s
37
+ if method.end_with? '='
38
+ instance_variable_set(format('@%s', [method.chomp('=')]),
39
+ arguments.first)
40
+ elsif instance_variable_defined?("@#{method}") && arguments.empty?
41
+ instance_variable_get("@#{method}")
42
+ else
43
+ super
44
+ end
45
+ end
46
+
47
+ # Override for additional model properties.
48
+ def respond_to_missing?(method_sym, include_private = false)
49
+ instance_variable_defined?("@#{method_sym}") ? true : super
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,129 @@
1
+ # This file was automatically generated for Stamplay by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ require 'date'
5
+ require_relative 'employee'
6
+
7
+ module Tester
8
+ # Testing circular reference.
9
+ class Boss < Employee
10
+ # TODO: Write general description for this method
11
+ # @return [DateTime]
12
+ attr_accessor :promoted_at
13
+
14
+ # TODO: Write general description for this method
15
+ # @return [Employee]
16
+ attr_accessor :assistant
17
+
18
+ # A mapping from model property names to API property names.
19
+ def self.names
20
+ @_hash = {} if @_hash.nil?
21
+ @_hash['promoted_at'] = 'promotedAt'
22
+ @_hash['assistant'] = 'assistant'
23
+ @_hash = super().merge(@_hash)
24
+ @_hash
25
+ end
26
+
27
+ def initialize(address = nil,
28
+ age = nil,
29
+ birthday = nil,
30
+ birthtime = nil,
31
+ department = nil,
32
+ dependents = nil,
33
+ hired_at = nil,
34
+ joining_day = Days::MONDAY,
35
+ name = nil,
36
+ promoted_at = nil,
37
+ salary = nil,
38
+ uid = nil,
39
+ working_days = nil,
40
+ assistant = nil,
41
+ boss = nil,
42
+ person_type = nil,
43
+ additional_properties = {})
44
+ @promoted_at = promoted_at
45
+ @assistant = assistant
46
+ def promoted_at.to_s
47
+ to_time.utc.to_i.to_s
48
+ end
49
+
50
+ def promoted_at.to_json(_options = {})
51
+ to_time.utc.to_i.to_json
52
+ end
53
+
54
+ # Add additional model properties to the instance.
55
+ additional_properties.each do |_name, value|
56
+ instance_variable_set("@#{_name}", value)
57
+ end
58
+
59
+ # Call the constructor of the base class
60
+ super(address,
61
+ age,
62
+ birthday,
63
+ birthtime,
64
+ department,
65
+ dependents,
66
+ hired_at,
67
+ joining_day,
68
+ name,
69
+ salary,
70
+ uid,
71
+ working_days,
72
+ boss,
73
+ person_type)
74
+ end
75
+
76
+ # Creates an instance of the object from a hash.
77
+ def self.from_hash(hash)
78
+ return nil unless hash
79
+
80
+ # Extract variables from the hash.
81
+ address = hash['address']
82
+ age = hash['age']
83
+ birthday = hash['birthday']
84
+ birthtime = DateTime.rfc3339(hash['birthtime']) if hash['birthtime']
85
+ department = hash['department']
86
+ # Parameter is an array, so we need to iterate through it
87
+ dependents = nil
88
+ unless hash['dependents'].nil?
89
+ dependents = []
90
+ hash['dependents'].each do |structure|
91
+ dependents << (Person.from_hash(structure) if structure)
92
+ end
93
+ end
94
+ hired_at = DateTime.httpdate(hash['hiredAt']) if hash['hiredAt']
95
+ joining_day = hash['joiningDay'] ||= Days::MONDAY
96
+ name = hash['name']
97
+ promoted_at = Time.at(hash['promotedAt']).utc.to_datetime if
98
+ hash['promotedAt']
99
+ salary = hash['salary']
100
+ uid = hash['uid']
101
+ working_days = hash['workingDays']
102
+ assistant = Employee.from_hash(hash['assistant']) if hash['assistant']
103
+ boss = Person.from_hash(hash['boss']) if hash['boss']
104
+ person_type = hash['personType']
105
+
106
+ # Clean out expected properties from Hash.
107
+ names.each_value { |k| hash.delete(k) }
108
+
109
+ # Create object from extracted values.
110
+ Boss.new(address,
111
+ age,
112
+ birthday,
113
+ birthtime,
114
+ department,
115
+ dependents,
116
+ hired_at,
117
+ joining_day,
118
+ name,
119
+ promoted_at,
120
+ salary,
121
+ uid,
122
+ working_days,
123
+ assistant,
124
+ boss,
125
+ person_type,
126
+ hash)
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,30 @@
1
+ # This file was automatically generated for Stamplay by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module Tester
5
+ # A string enum representing days of the week
6
+ class Days
7
+ DAYS = [
8
+ # TODO: Write general description for SUNDAY
9
+ SUNDAY = 'Sunday'.freeze,
10
+
11
+ # TODO: Write general description for MONDAY
12
+ MONDAY = 'Monday'.freeze,
13
+
14
+ # TODO: Write general description for TUESDAY
15
+ TUESDAY = 'Tuesday'.freeze,
16
+
17
+ # TODO: Write general description for WEDNESDAY_
18
+ WEDNESDAY_ = 'Wednesday'.freeze,
19
+
20
+ # TODO: Write general description for THURSDAY
21
+ THURSDAY = 'Thursday'.freeze,
22
+
23
+ # TODO: Write general description for FRI_DAY
24
+ FRI_DAY = 'Friday'.freeze,
25
+
26
+ # TODO: Write general description for SATURDAY
27
+ SATURDAY = 'Saturday'.freeze
28
+ ].freeze
29
+ end
30
+ end
@@ -0,0 +1,52 @@
1
+ # This file was automatically generated for Stamplay by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module Tester
5
+ # DeleteBody Model.
6
+ class DeleteBody < BaseModel
7
+ # TODO: Write general description for this method
8
+ # @return [String]
9
+ attr_accessor :field
10
+
11
+ # TODO: Write general description for this method
12
+ # @return [String]
13
+ attr_accessor :name
14
+
15
+ # A mapping from model property names to API property names.
16
+ def self.names
17
+ @_hash = {} if @_hash.nil?
18
+ @_hash['field'] = 'field'
19
+ @_hash['name'] = 'name'
20
+ @_hash
21
+ end
22
+
23
+ def initialize(field = nil,
24
+ name = nil,
25
+ additional_properties = {})
26
+ @field = field
27
+ @name = name
28
+
29
+ # Add additional model properties to the instance.
30
+ additional_properties.each do |_name, value|
31
+ instance_variable_set("@#{_name}", value)
32
+ end
33
+ end
34
+
35
+ # Creates an instance of the object from a hash.
36
+ def self.from_hash(hash)
37
+ return nil unless hash
38
+
39
+ # Extract variables from the hash.
40
+ field = hash['field']
41
+ name = hash['name']
42
+
43
+ # Clean out expected properties from Hash.
44
+ names.each_value { |k| hash.delete(k) }
45
+
46
+ # Create object from extracted values.
47
+ DeleteBody.new(field,
48
+ name,
49
+ hash)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,88 @@
1
+ # This file was automatically generated for Stamplay by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
3
+
4
+ module Tester
5
+ # Raw http Request info
6
+ class EchoResponse < BaseModel
7
+ # TODO: Write general description for this method
8
+ # @return [Array<String, Object>]
9
+ attr_accessor :body
10
+
11
+ # TODO: Write general description for this method
12
+ # @return [Array<String, String>]
13
+ attr_accessor :headers
14
+
15
+ # TODO: Write general description for this method
16
+ # @return [String]
17
+ attr_accessor :method
18
+
19
+ # relativePath
20
+ # @return [String]
21
+ attr_accessor :path
22
+
23
+ # relativePath
24
+ # @return [Array<String, QueryParameter>]
25
+ attr_accessor :query
26
+
27
+ # relativePath
28
+ # @return [Integer]
29
+ attr_accessor :upload_count
30
+
31
+ # A mapping from model property names to API property names.
32
+ def self.names
33
+ @_hash = {} if @_hash.nil?
34
+ @_hash['body'] = 'body'
35
+ @_hash['headers'] = 'headers'
36
+ @_hash['method'] = 'method'
37
+ @_hash['path'] = 'path'
38
+ @_hash['query'] = 'query'
39
+ @_hash['upload_count'] = 'uploadCount'
40
+ @_hash
41
+ end
42
+
43
+ def initialize(body = nil,
44
+ headers = nil,
45
+ method = nil,
46
+ path = nil,
47
+ query = nil,
48
+ upload_count = nil,
49
+ additional_properties = {})
50
+ @body = body
51
+ @headers = headers
52
+ @method = method
53
+ @path = path
54
+ @query = query
55
+ @upload_count = upload_count
56
+
57
+ # Add additional model properties to the instance.
58
+ additional_properties.each do |_name, value|
59
+ instance_variable_set("@#{_name}", value)
60
+ end
61
+ end
62
+
63
+ # Creates an instance of the object from a hash.
64
+ def self.from_hash(hash)
65
+ return nil unless hash
66
+
67
+ # Extract variables from the hash.
68
+ body = hash['body']
69
+ headers = hash['headers']
70
+ method = hash['method']
71
+ path = hash['path']
72
+ query = QueryParameter.from_hash(hash['query']) if hash['query']
73
+ upload_count = hash['uploadCount']
74
+
75
+ # Clean out expected properties from Hash.
76
+ names.each_value { |k| hash.delete(k) }
77
+
78
+ # Create object from extracted values.
79
+ EchoResponse.new(body,
80
+ headers,
81
+ method,
82
+ path,
83
+ query,
84
+ upload_count,
85
+ hash)
86
+ end
87
+ end
88
+ end