qa 3.1.0 → 4.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +16 -548
- data/app/controllers/qa/linked_data_terms_controller.rb +64 -42
- data/app/controllers/qa/terms_controller.rb +14 -6
- data/app/models/qa/iri_template/url_config.rb +47 -0
- data/app/models/qa/iri_template/variable_map.rb +62 -0
- data/app/models/qa/linked_data/config/context_map.rb +77 -0
- data/app/models/qa/linked_data/config/context_property_map.rb +144 -0
- data/app/models/qa/linked_data/config/helper.rb +34 -0
- data/app/services/qa/iri_template_service.rb +31 -0
- data/{lib/qa/authorities → app/services/qa}/linked_data/authority_service.rb +3 -4
- data/app/services/qa/linked_data/authority_url_service.rb +48 -0
- data/app/services/qa/linked_data/deep_sort_service.rb +238 -0
- data/app/services/qa/linked_data/graph_service.rb +106 -0
- data/app/services/qa/linked_data/language_service.rb +30 -0
- data/app/services/qa/linked_data/language_sort_service.rb +81 -0
- data/app/services/qa/linked_data/mapper/context_mapper_service.rb +59 -0
- data/app/services/qa/linked_data/mapper/graph_mapper_service.rb +40 -0
- data/app/services/qa/linked_data/mapper/search_results_mapper_service.rb +70 -0
- data/config/authorities/linked_data/loc.json +5 -2
- data/config/authorities/linked_data/oclc_fast.json +3 -2
- data/config/initializers/linked_data_authorities.rb +1 -1
- data/config/locales/qa.en.yml +9 -0
- data/lib/generators/qa/install/templates/config/initializers/qa.rb +4 -0
- data/lib/qa.rb +8 -0
- data/lib/qa/authorities/assign_fast/generic_authority.rb +1 -1
- data/lib/qa/authorities/base.rb +0 -11
- data/lib/qa/authorities/crossref/generic_authority.rb +1 -1
- data/lib/qa/authorities/geonames.rb +1 -1
- data/lib/qa/authorities/getty/aat.rb +7 -2
- data/lib/qa/authorities/getty/tgn.rb +7 -2
- data/lib/qa/authorities/getty/ulan.rb +7 -2
- data/lib/qa/authorities/linked_data.rb +0 -1
- data/lib/qa/authorities/linked_data/config.rb +29 -28
- data/lib/qa/authorities/linked_data/config/search_config.rb +21 -79
- data/lib/qa/authorities/linked_data/config/term_config.rb +7 -77
- data/lib/qa/authorities/linked_data/find_term.rb +25 -17
- data/lib/qa/authorities/linked_data/generic_authority.rb +6 -5
- data/lib/qa/authorities/linked_data/rdf_helper.rb +6 -73
- data/lib/qa/authorities/linked_data/search_query.rb +54 -101
- data/lib/qa/authorities/loc/generic_authority.rb +4 -4
- data/lib/qa/authorities/web_service_base.rb +1 -8
- data/lib/qa/configuration.rb +7 -0
- data/lib/qa/version.rb +1 -1
- data/lib/tasks/mesh.rake +19 -18
- data/spec/controllers/linked_data_terms_controller_spec.rb +51 -1
- data/spec/controllers/terms_controller_spec.rb +15 -15
- data/spec/fixtures/authorities/linked_data/lod_encoding_config.json +2 -1
- data/spec/fixtures/authorities/linked_data/lod_full_config.json +56 -2
- data/spec/fixtures/authorities/linked_data/lod_full_config_1_0.json +164 -0
- data/spec/fixtures/authorities/linked_data/lod_lang_defaults.json +5 -4
- data/spec/fixtures/authorities/linked_data/lod_lang_multi_defaults.json +3 -2
- data/spec/fixtures/authorities/linked_data/lod_lang_no_defaults.json +3 -2
- data/spec/fixtures/authorities/linked_data/lod_lang_param.json +3 -2
- data/spec/fixtures/authorities/linked_data/lod_min_config.json +3 -2
- data/spec/fixtures/authorities/linked_data/lod_search_only_config.json +2 -1
- data/spec/fixtures/authorities/linked_data/lod_sort.json +2 -1
- data/spec/fixtures/authorities/linked_data/lod_term_id_param_config.json +2 -1
- data/spec/fixtures/authorities/linked_data/lod_term_only_config.json +2 -1
- data/spec/fixtures/authorities/linked_data/lod_term_uri_param_config.json +2 -1
- data/spec/fixtures/getty-error-response.txt +10 -0
- data/spec/fixtures/lod_2_ranked_2_unranked.nt +17 -0
- data/spec/fixtures/lod_3_ranked_varying_preds.nt +16 -0
- data/spec/fixtures/lod_lang_search_filtering.nt +11 -0
- data/spec/fixtures/lod_search_with_blanknode_subjects.nt +18 -0
- data/spec/fixtures/lod_term_with_blanknode_objects.nt +8 -0
- data/spec/lib/authorities/assign_fast_spec.rb +1 -0
- data/spec/lib/authorities/getty/aat_spec.rb +14 -2
- data/spec/lib/authorities/getty/tgn_spec.rb +14 -2
- data/spec/lib/authorities/getty/ulan_spec.rb +14 -2
- data/spec/lib/authorities/linked_data/authority_service_spec.rb +2 -1
- data/spec/lib/authorities/linked_data/config_spec.rb +284 -5
- data/spec/lib/authorities/linked_data/find_term_spec.rb +3 -1
- data/spec/lib/authorities/linked_data/generic_authority_spec.rb +92 -42
- data/spec/lib/authorities/linked_data/search_config_spec.rb +67 -160
- data/spec/lib/authorities/linked_data/search_query_spec.rb +3 -127
- data/spec/lib/authorities/linked_data/term_config_spec.rb +6 -134
- data/spec/lib/authorities/loc_spec.rb +9 -9
- data/spec/lib/configuration_spec.rb +20 -7
- data/spec/lib/tasks/mesh.rake_spec.rb +2 -2
- data/spec/models/iri_template/url_config_spec.rb +102 -0
- data/spec/models/iri_template/variable_map_spec.rb +105 -0
- data/spec/models/linked_data/config/context_map_spec.rb +148 -0
- data/spec/models/linked_data/config/context_property_map_spec.rb +286 -0
- data/spec/services/iri_template_service_spec.rb +69 -0
- data/spec/services/linked_data/authority_url_service_spec.rb +107 -0
- data/spec/services/linked_data/deep_sort_service_spec.rb +260 -0
- data/spec/services/linked_data/graph_service_spec.rb +232 -0
- data/spec/services/linked_data/language_service_spec.rb +66 -0
- data/spec/services/linked_data/language_sort_service_spec.rb +58 -0
- data/spec/services/linked_data/mapper/context_mapper_service_spec.rb +137 -0
- data/spec/services/linked_data/mapper/graph_mapper_service_spec.rb +110 -0
- data/spec/services/linked_data/mapper/search_results_mapper_service_spec.rb +109 -0
- data/spec/spec_helper.rb +10 -2
- metadata +81 -11
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Qa::Authorities::LinkedData::FindTerm do
|
4
|
-
|
4
|
+
# all term fetch functionality is tested in spec/lib/authorities/linked_data/generic_authority_spec.rb and
|
5
|
+
# spec/controllers/linked_data_term_controller_spec.rb
|
6
|
+
it "is tested elsewhere"
|
5
7
|
end
|
@@ -69,50 +69,75 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
69
69
|
describe "language processing" do
|
70
70
|
context "when filtering #search results" do
|
71
71
|
context "and lang NOT passed in" do
|
72
|
-
context "and NO
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
context "and NO language defined in authority config" do
|
73
|
+
context "and NO language defined in Qa config" do
|
74
|
+
let(:lod_lang_no_defaults) { described_class.new(:LOD_LANG_NO_DEFAULTS) }
|
75
|
+
let :results do
|
76
|
+
stub_request(:get, "http://localhost/test_no_default/search?query=milk")
|
77
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_search_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
78
|
+
lod_lang_no_defaults.search('milk')
|
79
|
+
end
|
80
|
+
|
81
|
+
before do
|
82
|
+
Qa.config.default_language = []
|
83
|
+
end
|
84
|
+
|
85
|
+
after do
|
86
|
+
Qa.config.default_language = :en
|
87
|
+
end
|
88
|
+
|
89
|
+
it "is not filtered" do
|
90
|
+
expect(results.first[:label]).to eq('[buttermilk, Babeurre] (yummy, délicieux)')
|
91
|
+
expect(results.second[:label]).to eq('[condensed milk, lait condensé] (creamy, crémeux)')
|
92
|
+
expect(results.third[:label]).to eq('[dried milk, lait en poudre] (powdery, poudreux)')
|
93
|
+
end
|
78
94
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
95
|
+
|
96
|
+
context "and default_language is defined in Qa config" do
|
97
|
+
let(:lod_lang_no_defaults) { described_class.new(:LOD_LANG_NO_DEFAULTS) }
|
98
|
+
let :results do
|
99
|
+
stub_request(:get, "http://localhost/test_no_default/search?query=milk")
|
100
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_search_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
101
|
+
lod_lang_no_defaults.search('milk')
|
102
|
+
end
|
103
|
+
it "filters using Qa configured default" do
|
104
|
+
expect(results.first[:label]).to eq('buttermilk (yummy)')
|
105
|
+
expect(results.second[:label]).to eq('condensed milk (creamy)')
|
106
|
+
expect(results.third[:label]).to eq('dried milk (powdery)')
|
107
|
+
end
|
83
108
|
end
|
84
109
|
end
|
85
110
|
|
86
|
-
context "and
|
111
|
+
context "and language IS defined in authority config" do
|
87
112
|
let(:lod_lang_defaults) { described_class.new(:LOD_LANG_DEFAULTS) }
|
88
113
|
let :results do
|
89
114
|
stub_request(:get, "http://localhost/test_default/search?query=milk")
|
90
115
|
.to_return(status: 200, body: webmock_fixture("lod_lang_search_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
91
116
|
lod_lang_defaults.search('milk')
|
92
117
|
end
|
93
|
-
it "is filtered to
|
94
|
-
expect(results.first[:label]).to eq('
|
95
|
-
expect(results.second[:label]).to eq('
|
96
|
-
expect(results.third[:label]).to eq('
|
118
|
+
it "is filtered to authority defined language" do
|
119
|
+
expect(results.first[:label]).to eq('Babeurre (délicieux)')
|
120
|
+
expect(results.second[:label]).to eq('lait condensé (crémeux)')
|
121
|
+
expect(results.third[:label]).to eq('lait en poudre (poudreux)')
|
97
122
|
end
|
98
123
|
end
|
99
124
|
end
|
100
125
|
|
101
|
-
context "and multiple
|
126
|
+
context "and multiple languages ARE defined in authority config" do
|
102
127
|
let(:lod_lang_multi_defaults) { described_class.new(:LOD_LANG_MULTI_DEFAULTS) }
|
103
128
|
let :results do
|
104
129
|
stub_request(:get, "http://localhost/test_default/search?query=milk")
|
105
130
|
.to_return(status: 200, body: webmock_fixture("lod_lang_search_enfrde.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
106
131
|
lod_lang_multi_defaults.search('milk')
|
107
132
|
end
|
108
|
-
it "is filtered to
|
133
|
+
it "is filtered to authority defined languages" do
|
109
134
|
expect(results.first[:label]).to eq('[buttermilk, Babeurre] (yummy, délicieux)')
|
110
135
|
expect(results.second[:label]).to eq('[condensed milk, lait condensé] (creamy, crémeux)')
|
111
136
|
expect(results.third[:label]).to eq('[dried milk, lait en poudre] (powdery, poudreux)')
|
112
137
|
end
|
113
138
|
end
|
114
139
|
|
115
|
-
context "and
|
140
|
+
context "and language IS passed in to search" do
|
116
141
|
let(:lod_lang_defaults) { described_class.new(:LOD_LANG_DEFAULTS) }
|
117
142
|
let :results do
|
118
143
|
stub_request(:get, "http://localhost/test_default/search?query=milk")
|
@@ -313,46 +338,71 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
313
338
|
describe "language processing" do
|
314
339
|
context "when filtering #find result" do
|
315
340
|
context "and lang NOT passed in" do
|
316
|
-
context "and NO
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
341
|
+
context "and NO language defined in authority config" do
|
342
|
+
context "and NO language defined in Qa config" do
|
343
|
+
let(:lod_lang_no_defaults) { described_class.new(:LOD_LANG_NO_DEFAULTS) }
|
344
|
+
let :results do
|
345
|
+
stub_request(:get, "http://localhost/test_no_default/term/c_9513")
|
346
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
347
|
+
lod_lang_no_defaults.find('c_9513')
|
348
|
+
end
|
349
|
+
|
350
|
+
before do
|
351
|
+
Qa.config.default_language = []
|
352
|
+
end
|
353
|
+
|
354
|
+
after do
|
355
|
+
Qa.config.default_language = :en
|
356
|
+
end
|
357
|
+
|
358
|
+
it "is not filtered" do
|
359
|
+
expect(results[:label]).to eq ['buttermilk', 'Babeurre']
|
360
|
+
expect(results[:altlabel]).to eq ['yummy', 'délicieux']
|
361
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
362
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
363
|
+
end
|
322
364
|
end
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
365
|
+
context "and default_language is defined in Qa config" do
|
366
|
+
let(:lod_lang_no_defaults) { described_class.new(:LOD_LANG_NO_DEFAULTS) }
|
367
|
+
let :results do
|
368
|
+
stub_request(:get, "http://localhost/test_no_default/term/c_9513")
|
369
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
370
|
+
lod_lang_no_defaults.find('c_9513')
|
371
|
+
end
|
372
|
+
it "filters using Qa configured default for summary but not for predicates list" do
|
373
|
+
expect(results[:label]).to eq ['buttermilk']
|
374
|
+
expect(results[:altlabel]).to eq ['yummy']
|
375
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
376
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
377
|
+
end
|
328
378
|
end
|
329
379
|
end
|
330
|
-
context "and
|
380
|
+
context "and language IS defined in authority config" do
|
331
381
|
let(:lod_lang_defaults) { described_class.new(:LOD_LANG_DEFAULTS) }
|
332
382
|
let :results do
|
333
383
|
stub_request(:get, "http://localhost/test_default/term/c_9513")
|
334
384
|
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
335
385
|
lod_lang_defaults.find('c_9513')
|
336
386
|
end
|
337
|
-
it "
|
338
|
-
expect(results[:label]).to eq ['
|
339
|
-
expect(results[:altlabel]).to eq ['
|
340
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to
|
341
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to
|
387
|
+
it "filters using authority configured language for summary but not for predicates list" do
|
388
|
+
expect(results[:label]).to eq ['Babeurre']
|
389
|
+
expect(results[:altlabel]).to eq ['délicieux']
|
390
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
391
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
342
392
|
end
|
343
393
|
end
|
344
|
-
context "and multiple
|
394
|
+
context "and multiple languages ARE defined in authority config" do
|
345
395
|
let(:lod_lang_multi_defaults) { described_class.new(:LOD_LANG_MULTI_DEFAULTS) }
|
346
396
|
let :results do
|
347
397
|
stub_request(:get, "http://localhost/test_default/term/c_9513")
|
348
398
|
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfrde.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
349
399
|
lod_lang_multi_defaults.find('c_9513')
|
350
400
|
end
|
351
|
-
it "
|
401
|
+
it "filters using authority configured languages for summary but not for predicates list" do
|
352
402
|
expect(results[:label]).to eq ['buttermilk', 'Babeurre']
|
353
403
|
expect(results[:altlabel]).to eq ['yummy', 'délicieux']
|
354
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
355
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
404
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre", "Buttermilch")
|
405
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux", "lecker")
|
356
406
|
end
|
357
407
|
end
|
358
408
|
end
|
@@ -367,8 +417,8 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
367
417
|
it "is filtered to specified language" do
|
368
418
|
expect(results[:label]).to eq ['Babeurre']
|
369
419
|
expect(results[:altlabel]).to eq ['délicieux']
|
370
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to
|
371
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to
|
420
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
421
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
372
422
|
end
|
373
423
|
end
|
374
424
|
|
@@ -381,7 +431,7 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
381
431
|
end
|
382
432
|
it "is filtered to specified language" do
|
383
433
|
expect(results[:label]).to eq ['Babeurre']
|
384
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to
|
434
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
385
435
|
end
|
386
436
|
end
|
387
437
|
|
@@ -12,7 +12,7 @@ RSpec.describe Qa::Authorities::LinkedData::SearchConfig do
|
|
12
12
|
url: {
|
13
13
|
:@context => 'http://www.w3.org/ns/hydra/context.jsonld',
|
14
14
|
:@type => 'IriTemplate',
|
15
|
-
template: 'http://localhost/test_default/search?
|
15
|
+
template: 'http://localhost/test_default/search?{?subauth}&{?query}&{?param1}&{?param2}',
|
16
16
|
variableRepresentation: 'BasicRepresentation',
|
17
17
|
mapping: [
|
18
18
|
{
|
@@ -55,6 +55,55 @@ RSpec.describe Qa::Authorities::LinkedData::SearchConfig do
|
|
55
55
|
altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel',
|
56
56
|
sort_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel'
|
57
57
|
},
|
58
|
+
context: {
|
59
|
+
groups: {
|
60
|
+
dates: {
|
61
|
+
group_label_i18n: "qa.linked_data.authority.locnames_ld4l_cache.dates",
|
62
|
+
group_label_default: "Dates"
|
63
|
+
},
|
64
|
+
hierarchy: {
|
65
|
+
group_label_i18n: "qa.linked_data.authority.locgenres_ld4l_cache.hierarchy",
|
66
|
+
group_label_default: "Hierarchy"
|
67
|
+
}
|
68
|
+
},
|
69
|
+
properties: [
|
70
|
+
{
|
71
|
+
property_label_i18n: "qa.linked_data.authority.locgenres_ld4l_cache.authoritative_label",
|
72
|
+
property_label_default: "Authoritative Label",
|
73
|
+
ldpath: "madsrdf:authoritativeLabel",
|
74
|
+
selectable: true,
|
75
|
+
drillable: false
|
76
|
+
},
|
77
|
+
{
|
78
|
+
group_id: "dates",
|
79
|
+
property_label_i18n: "qa.linked_data.authority.locnames_ld4l_cache.birth_date",
|
80
|
+
property_label_default: "Birth",
|
81
|
+
ldpath: "madsrdf:identifiesRWO/madsrdf:birthDate/schema:label",
|
82
|
+
selectable: false,
|
83
|
+
drillable: false
|
84
|
+
},
|
85
|
+
{
|
86
|
+
group_id: "hierarchy",
|
87
|
+
property_label_i18n: "qa.linked_data.authority.locgenres_ld4l_cache.narrower",
|
88
|
+
property_label_default: "Narrower",
|
89
|
+
ldpath: "skos:narrower :: xsd:string",
|
90
|
+
selectable: true,
|
91
|
+
drillable: true,
|
92
|
+
expansion_label_ldpath: "skos:prefLabel ::xsd:string",
|
93
|
+
expansion_id_ldpath: "loc:lccn ::xsd:string"
|
94
|
+
},
|
95
|
+
{
|
96
|
+
group_id: "hierarchy",
|
97
|
+
property_label_i18n: "qa.linked_data.authority.locgenres_ld4l_cache.broader",
|
98
|
+
property_label_default: "Broader",
|
99
|
+
ldpath: "skos:broader :: xsd:string",
|
100
|
+
selectable: true,
|
101
|
+
drillable: true,
|
102
|
+
expansion_label_ldpath: "skos:prefLabel ::xsd:string",
|
103
|
+
expansion_id_ldpath: "loc:lccn ::xsd:string"
|
104
|
+
}
|
105
|
+
]
|
106
|
+
},
|
58
107
|
subauthorities: {
|
59
108
|
search_sub1_key: 'search_sub1_name',
|
60
109
|
search_sub2_key: 'search_sub2_name',
|
@@ -80,60 +129,12 @@ RSpec.describe Qa::Authorities::LinkedData::SearchConfig do
|
|
80
129
|
end
|
81
130
|
end
|
82
131
|
|
83
|
-
describe '#
|
84
|
-
let(:url_config) do
|
85
|
-
{
|
86
|
-
:@context => 'http://www.w3.org/ns/hydra/context.jsonld',
|
87
|
-
:@type => 'IriTemplate',
|
88
|
-
template: 'http://localhost/test_default/search?subauth={?subauth}&query={?query}¶m1={?param1}¶m2={?param2}',
|
89
|
-
variableRepresentation: 'BasicRepresentation',
|
90
|
-
mapping: [
|
91
|
-
{
|
92
|
-
:@type => 'IriTemplateMapping',
|
93
|
-
variable: 'query',
|
94
|
-
property: 'hydra:freetextQuery',
|
95
|
-
required: true
|
96
|
-
},
|
97
|
-
{
|
98
|
-
:@type => 'IriTemplateMapping',
|
99
|
-
variable: 'subauth',
|
100
|
-
property: 'hydra:freetextQuery',
|
101
|
-
required: false,
|
102
|
-
default: 'search_sub1_name'
|
103
|
-
},
|
104
|
-
{
|
105
|
-
:@type => 'IriTemplateMapping',
|
106
|
-
variable: 'param1',
|
107
|
-
property: 'hydra:freetextQuery',
|
108
|
-
required: false,
|
109
|
-
default: 'delta'
|
110
|
-
},
|
111
|
-
{
|
112
|
-
:@type => 'IriTemplateMapping',
|
113
|
-
variable: 'param2',
|
114
|
-
property: 'hydra:freetextQuery',
|
115
|
-
required: false,
|
116
|
-
default: 'echo'
|
117
|
-
}
|
118
|
-
]
|
119
|
-
}
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'returns nil if only term configuration is defined' do
|
123
|
-
expect(term_only_config.url).to eq nil
|
124
|
-
end
|
125
|
-
it 'returns the search url from the configuration' do
|
126
|
-
expect(full_config.url).to eq url_config
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe '#url_template' do
|
132
|
+
describe '#url_config' do
|
131
133
|
it 'returns nil if only term configuration is defined' do
|
132
|
-
expect(term_only_config.
|
134
|
+
expect(term_only_config.url_config).to eq nil
|
133
135
|
end
|
134
|
-
it 'returns the
|
135
|
-
|
136
|
-
expect(full_config.url_template).to eq expected_url_template
|
136
|
+
it 'returns the url config from the configuration' do
|
137
|
+
expect(full_config.url_config).to be_kind_of Qa::IriTemplate::UrlConfig
|
137
138
|
end
|
138
139
|
end
|
139
140
|
|
@@ -221,45 +222,27 @@ RSpec.describe Qa::Authorities::LinkedData::SearchConfig do
|
|
221
222
|
end
|
222
223
|
end
|
223
224
|
|
224
|
-
describe '#
|
225
|
+
describe '#supports_context?' do
|
225
226
|
it 'returns false if only term configuration is defined' do
|
226
|
-
expect(term_only_config.
|
227
|
-
end
|
228
|
-
it 'returns false if the configuration does NOT define replacements' do
|
229
|
-
expect(min_config.replacements?).to eq false
|
230
|
-
end
|
231
|
-
it 'returns true if the configuration defines replacements' do
|
232
|
-
expect(full_config.replacements?).to eq true
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
describe '#replacement_count' do
|
237
|
-
it 'returns 0 if only term configuration is defined' do
|
238
|
-
expect(term_only_config.replacement_count).to eq 0
|
227
|
+
expect(term_only_config.supports_context?).to eq false
|
239
228
|
end
|
240
|
-
it 'returns
|
241
|
-
expect(min_config.
|
229
|
+
it 'returns false if NOT defined in the configuration' do
|
230
|
+
expect(min_config.supports_context?).to eq false
|
242
231
|
end
|
243
|
-
it 'returns
|
244
|
-
expect(full_config.
|
232
|
+
it 'returns true if defined in the configuration' do
|
233
|
+
expect(full_config.supports_context?).to eq true
|
245
234
|
end
|
246
235
|
end
|
247
236
|
|
248
|
-
describe '#
|
249
|
-
it 'returns
|
250
|
-
|
251
|
-
expect(term_only_config.replacements).to eq empty_hash
|
237
|
+
describe '#context_map' do
|
238
|
+
it 'returns nil if only term configuration is defined' do
|
239
|
+
expect(term_only_config.context_map).to eq nil
|
252
240
|
end
|
253
|
-
it 'returns
|
254
|
-
|
255
|
-
expect(min_config.replacements).to eq empty_hash
|
241
|
+
it 'returns nil if NOT defined in the configuration' do
|
242
|
+
expect(min_config.context_map).to eq nil
|
256
243
|
end
|
257
|
-
it 'returns
|
258
|
-
|
259
|
-
param1: { :@type => 'IriTemplateMapping', variable: 'param1', property: 'hydra:freetextQuery', required: false, default: 'delta' },
|
260
|
-
param2: { :@type => 'IriTemplateMapping', variable: 'param2', property: 'hydra:freetextQuery', required: false, default: 'echo' }
|
261
|
-
}
|
262
|
-
expect(full_config.replacements).to eq expected_hash
|
244
|
+
it 'returns the context map if defined in the configuration' do
|
245
|
+
expect(full_config.context_map).to be_kind_of Qa::LinkedData::Config::ContextMap
|
263
246
|
end
|
264
247
|
end
|
265
248
|
|
@@ -320,80 +303,4 @@ RSpec.describe Qa::Authorities::LinkedData::SearchConfig do
|
|
320
303
|
expect(full_config.subauthorities).to eq expected_hash
|
321
304
|
end
|
322
305
|
end
|
323
|
-
|
324
|
-
describe '#subauthority_replacement_pattern' do
|
325
|
-
it 'returns empty hash if only term configuration is defined' do
|
326
|
-
empty_hash = {}
|
327
|
-
expect(term_only_config.subauthority_replacement_pattern).to eq empty_hash
|
328
|
-
end
|
329
|
-
it 'returns empty hash if no subauthorities are defined' do
|
330
|
-
empty_hash = {}
|
331
|
-
expect(min_config.subauthority_replacement_pattern).to eq empty_hash
|
332
|
-
end
|
333
|
-
it 'returns hash replacement pattern for subauthority and the default value' do
|
334
|
-
expected_hash = { pattern: 'subauth', default: 'search_sub1_name' }
|
335
|
-
expect(full_config.subauthority_replacement_pattern).to eq expected_hash
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
# rubocop:disable RSpec/RepeatedExample
|
340
|
-
describe '#search_url_with_replacements' do
|
341
|
-
it 'returns nil if only term configuration is defined' do
|
342
|
-
expect(term_only_config.url_with_replacements('Smith')).to eq nil
|
343
|
-
end
|
344
|
-
context 'when subauthorities ARE defined' do
|
345
|
-
it 'returns the url with query substitution applied' do
|
346
|
-
expected_url = 'http://localhost/test_default/search?subauth=search_sub1_name&query=Smith¶m1=delta¶m2=echo'
|
347
|
-
expect(full_config.url_with_replacements('Smith')).to eq expected_url
|
348
|
-
end
|
349
|
-
it 'returns the url with default subauthority when NOT specified' do
|
350
|
-
expected_url = 'http://localhost/test_default/search?subauth=search_sub1_name&query=Smith¶m1=delta¶m2=echo'
|
351
|
-
expect(full_config.url_with_replacements('Smith')).to eq expected_url
|
352
|
-
end
|
353
|
-
it 'returns the url with subauthority substitution when specified' do
|
354
|
-
expected_url = 'http://localhost/test_default/search?subauth=search_sub3_name&query=Smith¶m1=delta¶m2=echo'
|
355
|
-
expect(full_config.url_with_replacements('Smith', 'search_sub3_key')).to eq expected_url
|
356
|
-
end
|
357
|
-
it 'returns the url with default values when replacements are NOT specified' do
|
358
|
-
expected_url = 'http://localhost/test_default/search?subauth=search_sub1_name&query=Smith¶m1=delta¶m2=echo'
|
359
|
-
expect(full_config.url_with_replacements('Smith')).to eq expected_url
|
360
|
-
end
|
361
|
-
it 'returns the url with replacement substitution values when replacements are specified' do
|
362
|
-
expected_url = 'http://localhost/test_default/search?subauth=search_sub1_name&query=Smith¶m1=golf¶m2=hotel'
|
363
|
-
expect(full_config.url_with_replacements('Smith', nil, param1: 'golf', param2: 'hotel')).to eq expected_url
|
364
|
-
end
|
365
|
-
end
|
366
|
-
|
367
|
-
context 'when subauthorities are not defined' do
|
368
|
-
it 'returns the url with query substitution applied' do
|
369
|
-
expected_url = 'http://localhost/test_default/search?query=Smith'
|
370
|
-
expect(min_config.url_with_replacements('Smith')).to eq expected_url
|
371
|
-
end
|
372
|
-
it 'and subauth param is included returns the url with query substitution applied ignoring the subauth' do
|
373
|
-
expected_url = 'http://localhost/test_default/search?query=Smith'
|
374
|
-
expect(min_config.url_with_replacements('Smith', 'fake_subauth_key')).to eq expected_url
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
context 'when replacements are not defined' do
|
379
|
-
it 'returns the url with query substitution applied' do
|
380
|
-
expected_url = 'http://localhost/test_default/search?query=Smith'
|
381
|
-
expect(min_config.url_with_replacements('Smith')).to eq expected_url
|
382
|
-
end
|
383
|
-
it 'and replacements param is included returns the url with query substitution applied ignoring the replacements' do
|
384
|
-
expected_url = 'http://localhost/test_default/search?query=Smith'
|
385
|
-
expect(min_config.url_with_replacements('Smith', nil, fake_replacement_key: 'fake_value')).to eq expected_url
|
386
|
-
end
|
387
|
-
end
|
388
|
-
|
389
|
-
context 'with encoding specified in config' do
|
390
|
-
it 'returns the uri as the url' do
|
391
|
-
expected_url = 'http://localhost/test_default/search?query=encoded%20because%3Aencode%3Dtrue&yes%3Aencoded%20here&no:encoding here&defaults:to not encoded'
|
392
|
-
query = 'encoded because:encode=true'
|
393
|
-
replacements = { encode_true: 'yes:encoded here', encode_false: 'no:encoding here', encode_not_specified: 'defaults:to not encoded' }
|
394
|
-
expect(encoding_config.url_with_replacements(query, nil, replacements)).to eq expected_url
|
395
|
-
end
|
396
|
-
end
|
397
|
-
end
|
398
|
-
# rubocop:enable RSpec/RepeatedExample
|
399
306
|
end
|