fluent-plugin-droonga 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +7 -0
  4. data/benchmark/watch/benchmark-notify.rb +6 -6
  5. data/benchmark/watch/benchmark-notify.sh +3 -2
  6. data/bin/grn2jsons +0 -3
  7. data/doc/text/news.md +13 -0
  8. data/fluent-plugin-droonga.gemspec +1 -1
  9. data/lib/droonga/catalog/base.rb +8 -3
  10. data/lib/droonga/catalog.rb +1 -16
  11. data/lib/droonga/catalog_observer.rb +57 -0
  12. data/lib/droonga/collector.rb +1 -1
  13. data/lib/droonga/dispatcher.rb +3 -1
  14. data/lib/droonga/distributor_plugin.rb +47 -19
  15. data/lib/droonga/handler_messenger.rb +26 -2
  16. data/lib/droonga/message_processing_error.rb +6 -8
  17. data/lib/droonga/output_message.rb +17 -1
  18. data/lib/droonga/plugin/collector/basic.rb +44 -81
  19. data/lib/droonga/plugin/collector/groonga.rb +83 -0
  20. data/lib/droonga/plugin/collector/search.rb +104 -0
  21. data/lib/droonga/plugin/distributor/crud.rb +41 -0
  22. data/lib/droonga/plugin/distributor/distributed_search_planner.rb +4 -4
  23. data/lib/droonga/plugin/distributor/groonga.rb +38 -0
  24. data/lib/droonga/plugin/handler/add.rb +4 -1
  25. data/lib/droonga/plugin/handler/groonga/column_create.rb +7 -0
  26. data/lib/droonga/plugin/handler/groonga/table_remove.rb +42 -0
  27. data/lib/droonga/plugin/handler/groonga.rb +17 -2
  28. data/lib/droonga/plugin/handler/watch.rb +4 -4
  29. data/lib/droonga/plugin/input_adapter/crud.rb +27 -0
  30. data/lib/droonga/plugin/input_adapter/groonga.rb +16 -1
  31. data/lib/droonga/plugin/output_adapter/crud.rb +51 -0
  32. data/lib/droonga/plugin/output_adapter/groonga.rb +8 -1
  33. data/lib/droonga/plugin.rb +1 -1
  34. data/lib/droonga/replier.rb +7 -1
  35. data/lib/droonga/searcher.rb +168 -74
  36. data/lib/droonga/session.rb +1 -1
  37. data/lib/groonga_command_converter.rb +7 -1
  38. data/test/command/config/default/catalog.json +1 -1
  39. data/test/command/suite/add/error/invalid-integer.expected +31 -1
  40. data/test/command/suite/add/error/invalid-time.expected +31 -1
  41. data/test/command/suite/add/error/missing-key.expected +17 -1
  42. data/test/command/suite/add/error/missing-table.expected +17 -1
  43. data/test/command/suite/add/error/unknown-column.expected +31 -1
  44. data/test/command/suite/add/error/unknown-table.expected +17 -1
  45. data/test/command/suite/add/minimum.expected +1 -1
  46. data/test/command/suite/add/with-values.expected +1 -1
  47. data/test/command/suite/add/without-key.expected +1 -1
  48. data/test/command/suite/groonga/column_create/scalar.expected +2 -2
  49. data/test/command/suite/groonga/column_create/unknown-table.expected +18 -0
  50. data/test/command/suite/groonga/column_create/unknown-table.test +7 -0
  51. data/test/command/suite/groonga/column_create/vector.expected +2 -2
  52. data/test/command/suite/groonga/select/minimum.expected +1 -1
  53. data/test/command/suite/groonga/table_create/array.expected +1 -1
  54. data/test/command/suite/groonga/table_create/hash.expected +1 -1
  55. data/test/command/suite/groonga/table_remove/success.expected +17 -0
  56. data/test/command/suite/groonga/table_remove/success.test +8 -0
  57. data/test/command/suite/groonga/table_remove/unknown-table.expected +18 -0
  58. data/test/command/suite/groonga/table_remove/unknown-table.test +7 -0
  59. data/test/command/suite/message/error/missing-dataset.expected +1 -1
  60. data/test/command/suite/message/error/unknown-command.expected +1 -1
  61. data/test/command/suite/message/error/unknown-dataset.expected +1 -1
  62. data/test/command/suite/search/attributes/array.expected +1 -1
  63. data/test/command/suite/search/attributes/hash.expected +1 -1
  64. data/test/command/suite/search/complex.expected +1 -1
  65. data/test/command/suite/search/condition/nested.expected +1 -1
  66. data/test/command/suite/search/condition/query.expected +1 -1
  67. data/test/command/suite/search/condition/script.expected +1 -1
  68. data/test/command/suite/search/error/cyclic-source.expected +1 -1
  69. data/test/command/suite/search/error/deeply-cyclic-source.expected +1 -1
  70. data/test/command/suite/search/error/missing-source-parameter.expected +1 -1
  71. data/test/command/suite/search/error/unknown-source.expected +1 -1
  72. data/test/command/suite/search/group/count.expected +1 -1
  73. data/test/command/suite/search/group/limit.expected +1 -1
  74. data/test/command/suite/search/group/string.expected +1 -1
  75. data/test/command/suite/search/multiple/chained.expected +1 -1
  76. data/test/command/suite/search/multiple/parallel.expected +1 -1
  77. data/test/command/suite/search/range/only-output.expected +1 -1
  78. data/test/command/suite/search/range/only-sort.expected +1 -1
  79. data/test/command/suite/search/range/sort-and-output.expected +1 -1
  80. data/test/command/suite/search/range/too-large-output-offset.expected +1 -1
  81. data/test/command/suite/search/range/too-large-sort-offset.expected +1 -1
  82. data/test/command/suite/search/response/records/value/time.expected +1 -1
  83. data/test/command/suite/search/simple.expected +1 -1
  84. data/test/command/suite/search/sort/default-offset-limit.expected +1 -1
  85. data/test/command/suite/search/sort/invisible-column.expected +1 -1
  86. data/test/command/suite/watch/subscribe.expected +1 -1
  87. data/test/command/suite/watch/unsubscribe.expected +1 -1
  88. data/test/performance/run-test.rb +56 -0
  89. data/{benchmark → test/performance}/watch/catalog.json +0 -0
  90. data/test/performance/watch/feed.json +9 -0
  91. data/{benchmark → test/performance}/watch/fluentd.conf +0 -0
  92. data/test/performance/watch/subscribe.json +3 -0
  93. data/test/unit/catalog/test_version1.rb +34 -0
  94. data/test/unit/plugin/collector/test_basic.rb +300 -479
  95. data/test/unit/plugin/collector/test_search.rb +814 -0
  96. data/test/unit/plugin/distributor/test_search.rb +4 -4
  97. data/test/unit/plugin/distributor/test_search_planner.rb +260 -260
  98. data/test/unit/plugin/handler/groonga/test_column_create.rb +15 -1
  99. data/test/unit/plugin/handler/groonga/test_table_create.rb +6 -2
  100. data/test/unit/plugin/handler/groonga/test_table_remove.rb +58 -0
  101. data/test/unit/plugin/handler/test_add.rb +3 -1
  102. data/test/unit/plugin/handler/test_groonga.rb +24 -0
  103. data/test/unit/plugin/handler/test_search.rb +294 -0
  104. data/test/unit/plugin/handler/test_watch.rb +1 -1
  105. data/test/unit/plugin/{adapter → input_adapter}/groonga/test_select.rb +5 -37
  106. data/test/unit/plugin/output_adapter/groonga/test_select.rb +55 -0
  107. metadata +38 -6
@@ -19,8 +19,22 @@ class ColumnCreateTest < GroongaHandlerTest
19
19
  process(:column_create,
20
20
  {"table" => "Books", "name" => "title", "type" => "ShortText"})
21
21
  response = @messenger.values.last
22
+ assert_valid_output(response)
23
+ response = response["result"]
22
24
  assert_equal(
23
- [[Droonga::GroongaHandler::Status::SUCCESS, NORMALIZED_START_TIME, NORMALIZED_ELAPSED_TIME], true],
25
+ [NORMALIZED_HEADER_SUCCESS, true],
26
+ [normalize_header(response.first), response.last]
27
+ )
28
+ end
29
+
30
+ def test_unknown_table
31
+ process(:column_create,
32
+ {"table" => "Unknown", "name" => "title", "type" => "ShortText"})
33
+ response = @messenger.values.last
34
+ assert_valid_output(response)
35
+ response = response["result"]
36
+ assert_equal(
37
+ [NORMALIZED_HEADER_INVALID_ARGUMENT, false],
24
38
  [normalize_header(response.first), response.last]
25
39
  )
26
40
  end
@@ -17,8 +17,10 @@ class TableCreateTest < GroongaHandlerTest
17
17
  def test_success
18
18
  process(:table_create, {"name" => "Books"})
19
19
  response = @messenger.values.last
20
+ assert_valid_output(response)
21
+ response = response["result"]
20
22
  assert_equal(
21
- [[Droonga::GroongaHandler::Status::SUCCESS, NORMALIZED_START_TIME, NORMALIZED_ELAPSED_TIME], true],
23
+ [NORMALIZED_HEADER_SUCCESS, true],
22
24
  [normalize_header(response.first), response.last]
23
25
  )
24
26
  end
@@ -26,8 +28,10 @@ class TableCreateTest < GroongaHandlerTest
26
28
  def test_failure
27
29
  process(:table_create, {})
28
30
  response = @messenger.values.last
31
+ assert_valid_output(response)
32
+ response = response["result"]
29
33
  assert_equal(
30
- [[Droonga::GroongaHandler::Status::INVALID_ARGUMENT, NORMALIZED_START_TIME, NORMALIZED_ELAPSED_TIME], false],
34
+ [NORMALIZED_HEADER_INVALID_ARGUMENT, false],
31
35
  [normalize_header(response.first), response.last]
32
36
  )
33
37
  end
@@ -0,0 +1,58 @@
1
+ # Copyright (C) 2014 Droonga Project
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
+
16
+ class TableRemoveTest < GroongaHandlerTest
17
+ def setup
18
+ super
19
+ process(:table_create, {"name" => "Books"})
20
+ end
21
+
22
+ def test_success
23
+ process(:table_remove, {"name" => "Books"})
24
+ response = @messenger.values.last
25
+ assert_valid_output(response)
26
+ response = response["result"]
27
+ assert_equal(
28
+ [NORMALIZED_HEADER_SUCCESS, true],
29
+ [normalize_header(response.first), response.last]
30
+ )
31
+ assert_equal(<<-SCHEMA, dump)
32
+ SCHEMA
33
+ end
34
+
35
+ def test_failure
36
+ process(:table_remove, {})
37
+ response = @messenger.values.last
38
+ assert_valid_output(response)
39
+ response = response["result"]
40
+ assert_equal(
41
+ [NORMALIZED_HEADER_INVALID_ARGUMENT, false],
42
+ [normalize_header(response.first), response.last]
43
+ )
44
+ end
45
+
46
+ def test_remove
47
+ process(:table_remove, {"name" => "Books"})
48
+ assert_equal(<<-SCHEMA, dump)
49
+ SCHEMA
50
+ end
51
+
52
+ def test_unknown_table
53
+ process(:table_remove, {"name" => "Unknown"})
54
+ assert_equal(<<-SCHEMA, dump)
55
+ table_create Books TABLE_HASH_KEY --key_type ShortText
56
+ SCHEMA
57
+ end
58
+ end
@@ -16,7 +16,9 @@
16
16
  require "droonga/plugin/handler/add"
17
17
 
18
18
  class AddHandlerTest < Test::Unit::TestCase
19
- SUCCESS_RESPONSE_BODY = true
19
+ SUCCESS_RESPONSE_BODY = {
20
+ "success" => true,
21
+ }
20
22
 
21
23
  def setup
22
24
  setup_database
@@ -55,4 +55,28 @@ class GroongaHandlerTest < Test::Unit::TestCase
55
55
  elapsed_time = NORMALIZED_ELAPSED_TIME
56
56
  [header[0], start_time, elapsed_time]
57
57
  end
58
+
59
+ NORMALIZED_HEADER_SUCCESS = [
60
+ Droonga::GroongaHandler::Status::SUCCESS,
61
+ NORMALIZED_START_TIME,
62
+ NORMALIZED_ELAPSED_TIME,
63
+ ]
64
+ NORMALIZED_HEADER_INVALID_ARGUMENT = [
65
+ Droonga::GroongaHandler::Status::INVALID_ARGUMENT,
66
+ NORMALIZED_START_TIME,
67
+ NORMALIZED_ELAPSED_TIME,
68
+ ]
69
+
70
+ def assert_valid_output(output)
71
+ expected = {
72
+ "result" => [],
73
+ }
74
+ normalized_output = Marshal.load(Marshal.dump(output))
75
+ normalized_output.each do |key, value|
76
+ if value.is_a?(Array)
77
+ normalized_output[key] = []
78
+ end
79
+ end
80
+ assert_equal(expected, normalized_output)
81
+ end
58
82
  end
@@ -222,6 +222,300 @@ class SearchHandlerTest < Test::Unit::TestCase
222
222
  })
223
223
  end
224
224
 
225
+ def test_attributes_simple
226
+ assert_search({
227
+ "sections-result" => {
228
+ "attributes" => [
229
+ {
230
+ "name" => "key",
231
+ "type" => "ShortText",
232
+ "vector" => false
233
+ },
234
+ {
235
+ "name" => "title",
236
+ "type" => "ShortText",
237
+ "vector" => false
238
+ }
239
+ ]
240
+ },
241
+ },
242
+ {
243
+ "queries" => {
244
+ "sections-result" => {
245
+ "source" => "Sections",
246
+ "output" => {
247
+ "elements" => [
248
+ "attributes"
249
+ ],
250
+ "attributes" => [
251
+ {
252
+ "label" => "key",
253
+ "source" => "_key",
254
+ },
255
+ "title",
256
+ ],
257
+ },
258
+ },
259
+ },
260
+ })
261
+ end
262
+
263
+ def test_attributes_complex
264
+ assert_search({
265
+ "sections-result" => {
266
+ "attributes" => {
267
+ "key" => {
268
+ "type" => "ShortText",
269
+ "vector" => false
270
+ },
271
+ "title" => {
272
+ "type" => "ShortText",
273
+ "vector" => false
274
+ }
275
+ }
276
+ },
277
+ },
278
+ {
279
+ "queries" => {
280
+ "sections-result" => {
281
+ "source" => "Sections",
282
+ "output" => {
283
+ "format" => "complex",
284
+ "elements" => [
285
+ "attributes"
286
+ ],
287
+ "attributes" => [
288
+ {
289
+ "label" => "key",
290
+ "source" => "_key",
291
+ },
292
+ "title",
293
+ ],
294
+ },
295
+ },
296
+ },
297
+ })
298
+ end
299
+
300
+ def test_attributes_expression_simple
301
+ assert_search({
302
+ "sections-result" => {
303
+ "attributes" => [
304
+ {
305
+ "name" => "text", # TODO include some information
306
+ },
307
+ ]
308
+ },
309
+ },
310
+ {
311
+ "queries" => {
312
+ "sections-result" => {
313
+ "source" => "Sections",
314
+ "output" => {
315
+ "elements" => [
316
+ "attributes"
317
+ ],
318
+ "attributes" => [
319
+ {
320
+ "label" => "text",
321
+ "source" => "'hello'",
322
+ },
323
+ ],
324
+ },
325
+ },
326
+ },
327
+ })
328
+ end
329
+
330
+ def test_attributes_expression_complex
331
+ assert_search({
332
+ "sections-result" => {
333
+ "attributes" => {
334
+ "text" => {} # TODO include some information
335
+ },
336
+ },
337
+ },
338
+ {
339
+ "queries" => {
340
+ "sections-result" => {
341
+ "source" => "Sections",
342
+ "output" => {
343
+ "format" => "complex",
344
+ "elements" => [
345
+ "attributes"
346
+ ],
347
+ "attributes" => [
348
+ {
349
+ "label" => "text",
350
+ "source" => "'hello'",
351
+ },
352
+ ],
353
+ },
354
+ },
355
+ },
356
+ })
357
+ end
358
+
359
+ def test_attributes_subrecs_simple
360
+ assert_search({
361
+ "sections-result" => {
362
+ "attributes" => [
363
+ {
364
+ "name" => "key",
365
+ "type" => "ShortText",
366
+ "vector" => false
367
+ },
368
+ {
369
+ "name" => "title",
370
+ "type" => "ShortText",
371
+ "vector" => false
372
+ },
373
+ {
374
+ "name" => "_nsubrecs",
375
+ "type" => "Int32",
376
+ "vector" => false
377
+ },
378
+ {
379
+ "name" => "subrecs",
380
+ "attributes" => [
381
+ {
382
+ "name" => "_key",
383
+ "type" => "ShortText",
384
+ "vector" => false
385
+ },
386
+ {
387
+ "name" => "sectionTitle",
388
+ "type" => "ShortText",
389
+ "vector" => false
390
+ },
391
+ {
392
+ "name" => "documentTitle",
393
+ "type" => "ShortText",
394
+ "vector" => false
395
+ }
396
+ ]
397
+ }
398
+ ]
399
+ },
400
+ },
401
+ {
402
+ "queries" => {
403
+ "sections-result" => {
404
+ "source" => "Sections",
405
+ "groupBy" => {
406
+ "key" => "document",
407
+ "maxNSubRecords" => 1
408
+ },
409
+ "output" => {
410
+ "elements" => [
411
+ "attributes"
412
+ ],
413
+ "attributes" => [
414
+ {
415
+ "label" => "key",
416
+ "source" => "_key",
417
+ },
418
+ "title",
419
+ "_nsubrecs",
420
+ {
421
+ "label" => "subrecs",
422
+ "source" => "_subrecs",
423
+ "attributes" => [
424
+ "_key",
425
+ {
426
+ "label" => "sectionTitle",
427
+ "source" => "title"
428
+ },
429
+ {
430
+ "label" => "documentTitle",
431
+ "source" => "document.title"
432
+ }
433
+ ]
434
+ }
435
+ ],
436
+ },
437
+ },
438
+ },
439
+ })
440
+ end
441
+
442
+ def test_attributes_subrecs_complex
443
+ assert_search({
444
+ "sections-result" => {
445
+ "attributes" => {
446
+ "key" => {
447
+ "type" => "ShortText",
448
+ "vector" => false
449
+ },
450
+ "title" => {
451
+ "type" => "ShortText",
452
+ "vector" => false
453
+ },
454
+ "_nsubrecs" => {
455
+ "type" => "Int32",
456
+ "vector" => false
457
+ },
458
+ "subrecs" => {
459
+ "attributes" => {
460
+ "_key" => {
461
+ "type" => "ShortText",
462
+ "vector" => false
463
+ },
464
+ "sectionTitle" => {
465
+ "type" => "ShortText",
466
+ "vector" => false
467
+ },
468
+ "documentTitle" => {
469
+ "type" => "ShortText",
470
+ "vector" => false
471
+ }
472
+ }
473
+ }
474
+ }
475
+ },
476
+ },
477
+ {
478
+ "queries" => {
479
+ "sections-result" => {
480
+ "source" => "Sections",
481
+ "groupBy" => {
482
+ "key" => "document",
483
+ "maxNSubRecords" => 1
484
+ },
485
+ "output" => {
486
+ "format" => "complex",
487
+ "elements" => [
488
+ "attributes"
489
+ ],
490
+ "attributes" => [
491
+ {
492
+ "label" => "key",
493
+ "source" => "_key",
494
+ },
495
+ "title",
496
+ "_nsubrecs",
497
+ {
498
+ "label" => "subrecs",
499
+ "source" => "_subrecs",
500
+ "attributes" => [
501
+ "_key",
502
+ {
503
+ "label" => "sectionTitle",
504
+ "source" => "title"
505
+ },
506
+ {
507
+ "label" => "documentTitle",
508
+ "source" => "document.title"
509
+ }
510
+ ]
511
+ }
512
+ ],
513
+ },
514
+ },
515
+ },
516
+ })
517
+ end
518
+
225
519
  class AttributesTest < self
226
520
  def test_source_only
227
521
  expected = {
@@ -153,7 +153,7 @@ class WatchHandlerTest < Test::Unit::TestCase
153
153
  },
154
154
  {
155
155
  "to" => "localhost:23003/output",
156
- "type" => "watch.notification",
156
+ "type" => "watch.publish",
157
157
  },
158
158
  ],
159
159
  ],
@@ -1,3 +1,4 @@
1
+
1
2
  # Copyright (C) 2013 Droonga Project
2
3
  #
3
4
  # This library is free software; you can redistribute it and/or
@@ -13,11 +14,11 @@
13
14
  # License along with this library; if not, write to the Free Software
14
15
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
16
 
16
- require "droonga/plugin/adapter/groonga/select"
17
+ require "droonga/plugin/input_adapter/groonga/select"
17
18
 
18
- class AdapterGroongaSelectTest < Test::Unit::TestCase
19
+ class InputAdapterGroongaSelectTest < Test::Unit::TestCase
19
20
  def setup
20
- @select = Droonga::GroongaAdapter::Select.new
21
+ @select = Droonga::GroongaInputAdapter::Select.new
21
22
  end
22
23
 
23
24
  class RequestTest < self
@@ -52,7 +53,7 @@ class AdapterGroongaSelectTest < Test::Unit::TestCase
52
53
 
53
54
  private
54
55
  def convert(select_request)
55
- @select.convert_request(select_request)
56
+ @select.convert(select_request)
56
57
  end
57
58
 
58
59
  class OutputColumnsTest < self
@@ -244,37 +245,4 @@ class AdapterGroongaSelectTest < Test::Unit::TestCase
244
245
  end
245
246
  end
246
247
  end
247
-
248
- class ResponseTest < self
249
- def test_empty
250
- start_time = "2001-08-02T10:45:23.5+09:00"
251
- elapsed_time = 0
252
- count = 0
253
-
254
- search_response = {
255
- "EmptyTable" => {
256
- "startTime" => start_time,
257
- "elapsedTime" => elapsed_time,
258
- "count" => count,
259
- "attributes" => [
260
- {"name" => "_id", "type" => "UInt32", "vector" => false},
261
- ],
262
- "records" => [],
263
- },
264
- }
265
-
266
- status_code = 0
267
- start_time_in_unix_time = Time.parse(start_time).to_f
268
- headers = [["_id","UInt32"]]
269
- expected_select_response = [[status_code, start_time_in_unix_time, elapsed_time],
270
- [[[count], headers]]]
271
-
272
- assert_equal(expected_select_response, convert(search_response))
273
- end
274
-
275
- private
276
- def convert(search_response)
277
- @select.convert_response(search_response)
278
- end
279
- end
280
248
  end
@@ -0,0 +1,55 @@
1
+ # Copyright (C) 2013 Droonga Project
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
+
16
+ require "droonga/plugin/output_adapter/groonga/select"
17
+
18
+ class OutputAdapterGroongaSelectTest < Test::Unit::TestCase
19
+ def setup
20
+ @select = Droonga::GroongaOutputAdapter::Select.new
21
+ end
22
+
23
+ class ResponseTest < self
24
+ def test_empty
25
+ start_time = "2001-08-02T10:45:23.5+09:00"
26
+ elapsed_time = 0
27
+ count = 0
28
+
29
+ search_response = {
30
+ "EmptyTable" => {
31
+ "startTime" => start_time,
32
+ "elapsedTime" => elapsed_time,
33
+ "count" => count,
34
+ "attributes" => [
35
+ {"name" => "_id", "type" => "UInt32", "vector" => false},
36
+ ],
37
+ "records" => [],
38
+ },
39
+ }
40
+
41
+ status_code = 0
42
+ start_time_in_unix_time = Time.parse(start_time).to_f
43
+ headers = [["_id","UInt32"]]
44
+ expected_select_response = [[status_code, start_time_in_unix_time, elapsed_time],
45
+ [[[count], headers]]]
46
+
47
+ assert_equal(expected_select_response, convert(search_response))
48
+ end
49
+
50
+ private
51
+ def convert(search_response)
52
+ @select.convert(search_response)
53
+ end
54
+ end
55
+ end