Skip to content

Commit e5ba63b

Browse files
author
Braktar
committed
Add vehicle test
1 parent fecda71 commit e5ba63b

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

spec/issues/751_deeply_nested_objects_spec.rb

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ def self.vrp_request_service(this)
4343
end
4444
this.mutually_exclusive :activity, :activities
4545
end
46+
47+
def self.vrp_request_vehicle(this)
48+
this.requires(:id, type: String, allow_blank: false)
49+
this.optional(:cost_time_multiplier, type: Float)
50+
51+
this.optional(:matrix_id, type: String)
52+
this.optional(:router_mode, type: String)
53+
this.exactly_one_of :matrix_id, :router_mode
54+
55+
this.optional(:skills, type: Array[Array[String]])
56+
57+
this.optional(:start_point_id, type: String)
58+
this.optional(:end_point_id, type: String)
59+
60+
this.optional(:sequence_timewindows, type: Array) do
61+
Vrp.vrp_request_timewindow(self)
62+
end
63+
this.optional(:timewindow, type: Hash) do
64+
Vrp.vrp_request_timewindow(self)
65+
end
66+
this.mutually_exclusive :sequence_timewindows, :timewindow
67+
end
4668
end
4769

4870
namespace :vrp do
@@ -57,6 +79,10 @@ def self.vrp_request_service(this)
5779
optional(:services, type: Array) do
5880
Vrp.vrp_request_service(self)
5981
end
82+
83+
optional(:vehicles, type: Array) do
84+
Vrp.vrp_request_vehicle(self)
85+
end
6086
end
6187
end
6288
post do
@@ -187,4 +213,72 @@ def self.vrp_request_service(this)
187213
)
188214
end
189215
end
216+
217+
describe 'Correctness of vrp Vehicles' do
218+
let(:get_points_response) { subject['definitions']['postVrpSubmit']['properties']['vrp']['properties']['vehicles'] }
219+
specify do
220+
expect(get_points_response).to eql(
221+
'type' => 'array',
222+
'items' => {
223+
'type' => 'object',
224+
'properties' => {
225+
'id' => {
226+
'type' => 'string'
227+
},
228+
'cost_time_multiplier' => {
229+
'type' => 'float',
230+
'format' => 'number'
231+
},
232+
'matrix_id' => {
233+
'type' => 'string'
234+
},
235+
'router_mode' => {
236+
'type' => 'string'
237+
},
238+
'skills' => {
239+
'type' => 'array',
240+
'items' => {
241+
'type' => 'array',
242+
'items' => {
243+
'type' => 'string'
244+
}
245+
}
246+
},
247+
'start_point_id' => {
248+
'type' => 'string'
249+
},
250+
'end_point_id' => {
251+
'type' => 'string'
252+
},
253+
'timewindow' => {
254+
'type' => 'object',
255+
'properties' => {
256+
'start' => {
257+
'type' => 'string'
258+
},
259+
'end' => {
260+
'type' => 'string'
261+
}
262+
}
263+
},
264+
'sequence_timewindows' => {
265+
'type' => 'array',
266+
'items' => {
267+
'type' => 'object',
268+
'properties' => {
269+
'start' => {
270+
'type' => 'string'
271+
},
272+
'end' => {
273+
'type' => 'string'
274+
}
275+
}
276+
}
277+
}
278+
},
279+
'required' => ['id']
280+
}
281+
)
282+
end
283+
end
190284
end

0 commit comments

Comments
 (0)