Subversion Repositories SmartDukaan

Rev

Rev 30 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
30 ashish 1
#
2
# Licensed to the Apache Software Foundation (ASF) under one
3
# or more contributor license agreements. See the NOTICE file
4
# distributed with this work for additional information
5
# regarding copyright ownership. The ASF licenses this file
6
# to you under the Apache License, Version 2.0 (the
7
# "License"); you may not use this file except in compliance
8
# with the License. You may obtain a copy of the License at
9
#
10
#   http://www.apache.org/licenses/LICENSE-2.0
11
#
12
# Unless required by applicable law or agreed to in writing,
13
# software distributed under the License is distributed on an
14
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
# KIND, either express or implied. See the License for the
16
# specific language governing permissions and limitations
17
# under the License.
18
#
19
 
20
require 'thrift'
21
 
22
module Fixtures
23
  module Structs
24
    class OneBool
25
      include Thrift::Struct
26
      attr_accessor :bool
27
      FIELDS = {
28
        1 => {:type => Thrift::Types::BOOL, :name => 'bool'}
29
      }
30
 
31
      def validate
32
      end
33
    end
34
 
35
    class OneByte
36
      include Thrift::Struct
37
      attr_accessor :byte
38
      FIELDS = {
39
        1 => {:type => Thrift::Types::BYTE, :name => 'byte'}
40
      }
41
 
42
      def validate
43
      end
44
    end
45
 
46
    class OneI16
47
      include Thrift::Struct
48
      attr_accessor :i16
49
      FIELDS = {
50
        1 => {:type => Thrift::Types::I16, :name => 'i16'}
51
      }
52
 
53
      def validate
54
      end
55
    end
56
 
57
    class OneI32
58
      include Thrift::Struct
59
      attr_accessor :i32
60
      FIELDS = {
61
        1 => {:type => Thrift::Types::I32, :name => 'i32'}
62
      }
63
 
64
      def validate
65
      end
66
    end
67
 
68
    class OneI64
69
      include Thrift::Struct
70
      attr_accessor :i64
71
      FIELDS = {
72
        1 => {:type => Thrift::Types::I64, :name => 'i64'}
73
      }
74
 
75
      def validate
76
      end
77
    end
78
 
79
    class OneDouble
80
      include Thrift::Struct
81
      attr_accessor :double
82
      FIELDS = {
83
        1 => {:type => Thrift::Types::DOUBLE, :name => 'double'}
84
      }
85
 
86
      def validate
87
      end
88
    end
89
 
90
    class OneString
91
      include Thrift::Struct
92
      attr_accessor :string
93
      FIELDS = {
94
        1 => {:type => Thrift::Types::STRING, :name => 'string'}
95
      }
96
 
97
      def validate
98
      end
99
    end
100
 
101
    class OneMap
102
      include Thrift::Struct
103
      attr_accessor :map
104
      FIELDS = {
105
        1 => {:type => Thrift::Types::MAP, :name => 'map', :key => {:type => Thrift::Types::STRING}, :value => {:type => Thrift::Types::STRING}}
106
      }
107
 
108
      def validate
109
      end
110
    end
111
 
112
    class NestedMap
113
      include Thrift::Struct
114
      attr_accessor :map
115
      FIELDS = {
116
 
117
      }
118
 
119
      def validate
120
      end
121
    end
122
 
123
    class OneList
124
      include Thrift::Struct
125
      attr_accessor :list
126
      FIELDS = {
127
        1 => {:type => Thrift::Types::LIST, :name => 'list', :element => {:type => Thrift::Types::STRING}}
128
      }
129
 
130
      def validate
131
      end
132
    end
133
 
134
    class NestedList
135
      include Thrift::Struct
136
      attr_accessor :list
137
      FIELDS = {
138
 
139
      }
140
 
141
      def validate
142
      end
143
    end
144
 
145
    class OneSet
146
      include Thrift::Struct
147
      attr_accessor :set
148
      FIELDS = {
149
        1 => {:type => Thrift::Types::SET, :name => 'set', :element => {:type => Thrift::Types::STRING}}
150
      }
151
 
152
      def validate
153
      end
154
    end
155
 
156
    class NestedSet
157
      include Thrift::Struct
158
      attr_accessor :set
159
      FIELDS = {
160
        1 => {:type => Thrift::Types::SET, :name => 'set', :element => {:type => Thrift::Types::SET, :element => { :type => Thrift::Types::STRING } }}
161
      }
162
 
163
      def validate
164
      end
165
    end
166
 
167
    # struct OneOfEach {
168
    #   1: bool im_true,
169
    #   2: bool im_false,
170
    #   3: byte a_bite,
171
    #   4: i16 integer16,
172
    #   5: i32 integer32,
173
    #   6: i64 integer64,
174
    #   7: double double_precision,
175
    #   8: string some_characters,
176
    #   9: string zomg_unicode,
177
    #   10: bool what_who,
178
    #   11: binary base64,
179
    # }
180
    class OneOfEach
181
      include Thrift::Struct
182
      attr_accessor :im_true, :im_false, :a_bite, :integer16, :integer32, :integer64, :double_precision, :some_characters, :zomg_unicode, :what_who, :base64
183
      FIELDS = {
184
        1 => {:type => Thrift::Types::BOOL, :name => 'im_true'},
185
        2 => {:type => Thrift::Types::BOOL, :name => 'im_false'},
186
        3 => {:type => Thrift::Types::BYTE, :name => 'a_bite'},
187
        4 => {:type => Thrift::Types::I16, :name => 'integer16'},
188
        5 => {:type => Thrift::Types::I32, :name => 'integer32'},
189
        6 => {:type => Thrift::Types::I64, :name => 'integer64'},
190
        7 => {:type => Thrift::Types::DOUBLE, :name => 'double_precision'},
191
        8 => {:type => Thrift::Types::STRING, :name => 'some_characters'},
192
        9 => {:type => Thrift::Types::STRING, :name => 'zomg_unicode'},
193
        10 => {:type => Thrift::Types::BOOL, :name => 'what_who'},
194
        11 => {:type => Thrift::Types::STRING, :name => 'base64'}
195
      }
196
 
197
      # Added for assert_equal
198
      def ==(other)
199
        [:im_true, :im_false, :a_bite, :integer16, :integer32, :integer64, :double_precision, :some_characters, :zomg_unicode, :what_who, :base64].each do |f|
200
          var = "@#{f}"
201
          return false if instance_variable_get(var) != other.instance_variable_get(var)
202
        end
203
        true
204
      end
205
 
206
      def validate
207
      end
208
    end
209
 
210
    # struct Nested1 {
211
    #   1: list<OneOfEach> a_list
212
    #   2: map<i32, OneOfEach> i32_map
213
    #   3: map<i64, OneOfEach> i64_map
214
    #   4: map<double, OneOfEach> dbl_map
215
    #   5: map<string, OneOfEach> str_map
216
    # }
217
    class Nested1
218
      include Thrift::Struct
219
      attr_accessor :a_list, :i32_map, :i64_map, :dbl_map, :str_map
220
      FIELDS = {
221
        1 => {:type => Thrift::Types::LIST, :name => 'a_list', :element => {:type => Thrift::Types::STRUCT, :class => OneOfEach}},
222
        2 => {:type => Thrift::Types::MAP, :name => 'i32_map', :key => {:type => Thrift::Types::I32}, :value => {:type => Thrift::Types::STRUCT, :class => OneOfEach}},
223
        3 => {:type => Thrift::Types::MAP, :name => 'i64_map', :key => {:type => Thrift::Types::I64}, :value => {:type => Thrift::Types::STRUCT, :class => OneOfEach}},
224
        4 => {:type => Thrift::Types::MAP, :name => 'dbl_map', :key => {:type => Thrift::Types::DOUBLE}, :value => {:type => Thrift::Types::STRUCT, :class => OneOfEach}},
225
        5 => {:type => Thrift::Types::MAP, :name => 'str_map', :key => {:type => Thrift::Types::STRING}, :value => {:type => Thrift::Types::STRUCT, :class => OneOfEach}}
226
      }
227
 
228
      def validate
229
      end
230
    end
231
 
232
    # struct Nested2 {
233
    #   1: list<Nested1> a_list
234
    #   2: map<i32, Nested1> i32_map
235
    #   3: map<i64, Nested1> i64_map
236
    #   4: map<double, Nested1> dbl_map
237
    #   5: map<string, Nested1> str_map
238
    # }
239
    class Nested2
240
      include Thrift::Struct
241
      attr_accessor :a_list, :i32_map, :i64_map, :dbl_map, :str_map
242
      FIELDS = {
243
        1 => {:type => Thrift::Types::LIST, :name => 'a_list', :element => {:type => Thrift::Types::STRUCT, :class => Nested1}},
244
        2 => {:type => Thrift::Types::MAP, :name => 'i32_map', :key => {:type => Thrift::Types::I32}, :value => {:type => Thrift::Types::STRUCT, :class => Nested1}},
245
        3 => {:type => Thrift::Types::MAP, :name => 'i64_map', :key => {:type => Thrift::Types::I64}, :value => {:type => Thrift::Types::STRUCT, :class => Nested1}},
246
        4 => {:type => Thrift::Types::MAP, :name => 'dbl_map', :key => {:type => Thrift::Types::DOUBLE}, :value => {:type => Thrift::Types::STRUCT, :class => Nested1}},
247
        5 => {:type => Thrift::Types::MAP, :name => 'str_map', :key => {:type => Thrift::Types::STRING}, :value => {:type => Thrift::Types::STRUCT, :class => Nested1}}
248
      }
249
 
250
      def validate
251
      end
252
    end
253
 
254
    # struct Nested3 {
255
    #   1: list<Nested2> a_list
256
    #   2: map<i32, Nested2> i32_map
257
    #   3: map<i64, Nested2> i64_map
258
    #   4: map<double, Nested2> dbl_map
259
    #   5: map<string, Nested2> str_map
260
    # }
261
    class Nested3
262
      include Thrift::Struct
263
      attr_accessor :a_list, :i32_map, :i64_map, :dbl_map, :str_map
264
      FIELDS = {
265
        1 => {:type => Thrift::Types::LIST, :name => 'a_list', :element => {:type => Thrift::Types::STRUCT, :class => Nested2}},
266
        2 => {:type => Thrift::Types::MAP, :name => 'i32_map', :key => {:type => Thrift::Types::I32}, :value => {:type => Thrift::Types::STRUCT, :class => Nested2}},
267
        3 => {:type => Thrift::Types::MAP, :name => 'i64_map', :key => {:type => Thrift::Types::I64}, :value => {:type => Thrift::Types::STRUCT, :class => Nested2}},
268
        4 => {:type => Thrift::Types::MAP, :name => 'dbl_map', :key => {:type => Thrift::Types::DOUBLE}, :value => {:type => Thrift::Types::STRUCT, :class => Nested2}},
269
        5 => {:type => Thrift::Types::MAP, :name => 'str_map', :key => {:type => Thrift::Types::STRING}, :value => {:type => Thrift::Types::STRUCT, :class => Nested2}}
270
      }
271
 
272
      def validate
273
      end
274
    end
275
 
276
    # struct Nested4 {
277
    #   1: list<Nested3> a_list
278
    #   2: map<i32, Nested3> i32_map
279
    #   3: map<i64, Nested3> i64_map
280
    #   4: map<double, Nested3> dbl_map
281
    #   5: map<string, Nested3> str_map
282
    # }
283
    class Nested4
284
      include Thrift::Struct
285
      attr_accessor :a_list, :i32_map, :i64_map, :dbl_map, :str_map
286
      FIELDS = {
287
        1 => {:type => Thrift::Types::LIST, :name => 'a_list', :element => {:type => Thrift::Types::STRUCT, :class => Nested3}},
288
        2 => {:type => Thrift::Types::MAP, :name => 'i32_map', :key => {:type => Thrift::Types::I32}, :value => {:type => Thrift::Types::STRUCT, :class => Nested3}},
289
        3 => {:type => Thrift::Types::MAP, :name => 'i64_map', :key => {:type => Thrift::Types::I64}, :value => {:type => Thrift::Types::STRUCT, :class => Nested3}},
290
        4 => {:type => Thrift::Types::MAP, :name => 'dbl_map', :key => {:type => Thrift::Types::DOUBLE}, :value => {:type => Thrift::Types::STRUCT, :class => Nested3}},
291
        5 => {:type => Thrift::Types::MAP, :name => 'str_map', :key => {:type => Thrift::Types::STRING}, :value => {:type => Thrift::Types::STRUCT, :class => Nested3}}
292
      }
293
 
294
      def validate
295
      end
296
    end
297
  end
298
end