From 926fe1e7f928c300aa32d2cd61a4655fb073fdb9 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 11 Feb 2022 09:34:42 +0100 Subject: [PATCH 01/15] Auto stash before merge of "upstream" and "upstream/master" --- .gitignore | 2 ++ Gemfile.lock | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 68d9c3f8e..4045ab4b2 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,5 @@ test/test_run.log test/data/ontology_files/catalog-v001.xml create_permissions.log + +ontologies_api.iml diff --git a/Gemfile.lock b/Gemfile.lock index cb883e4f4..991897524 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/ncbo/goo.git - revision: d26b364dc5e8a22753cf9f8495a77c398112683f + revision: 89a8f665f70644989adf70cd132bf0f38ef3414d branch: master specs: goo (0.0.2) @@ -16,7 +16,7 @@ GIT GIT remote: https://github.com/ncbo/ncbo_annotator.git - revision: 94a77bb64f3a5af72d909c597869e9923bac3831 + revision: e224f46dafc254b7d4a1685eb6c5c26d97ab33b7 branch: master specs: ncbo_annotator (0.0.1) @@ -27,7 +27,7 @@ GIT GIT remote: https://github.com/ncbo/ncbo_cron.git - revision: 2861124483e60071266f48b2ed6d72e4394de975 + revision: 3d585ec682d84054668f939b613388186020faa0 branch: master specs: ncbo_cron (0.0.1) From b68a8dc21aa277774cfce8ef2a1f328400feede6 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 19 Aug 2022 16:36:41 +0200 Subject: [PATCH 02/15] auto lint mappings_controller et test_mappings --- controllers/mappings_controller.rb | 26 +++---- test/controllers/test_mappings_controller.rb | 77 ++++++++++---------- 2 files changed, 51 insertions(+), 52 deletions(-) diff --git a/controllers/mappings_controller.rb b/controllers/mappings_controller.rb index 29e26483a..6154bd920 100644 --- a/controllers/mappings_controller.rb +++ b/controllers/mappings_controller.rb @@ -11,7 +11,7 @@ class MappingsController < ApplicationController end mappings = LinkedData::Mappings.mappings_ontology(submission, - 0,0, + 0, 0, cls.id) populate_mapping_classes(mappings.to_a) reply mappings @@ -21,15 +21,15 @@ class MappingsController < ApplicationController get '/ontologies/:ontology/mappings' do ontology = ontology_from_acronym(@params[:ontology]) if ontology.nil? - error(404, "Ontology not found") + error(404, "Ontology not found") end page, size = page_params submission = ontology.latest_submission if submission.nil? - error(404, "Submission not found for ontology " + ontology.acronym) + error(404, "Submission not found for ontology " + ontology.acronym) end mappings = LinkedData::Mappings.mappings_ontology(submission, - page,size, + page, size, nil) populate_mapping_classes(mappings) reply mappings @@ -55,8 +55,8 @@ class MappingsController < ApplicationController if sub2.nil? error(404, "Submission not found for ontology " + ontologies[1].id.to_s) end - mappings = LinkedData::Mappings.mappings_ontologies(sub1,sub2, - page,size) + mappings = LinkedData::Mappings.mappings_ontologies(sub1, sub2, + page, size) populate_mapping_classes(mappings) reply mappings end @@ -70,7 +70,7 @@ class MappingsController < ApplicationController else mappings = LinkedData::Mappings.recent_rest_mappings(size + 15) populate_mapping_classes(mappings) - reply mappings[0..size-1] + reply mappings[0..size - 1] end end @@ -166,9 +166,9 @@ class MappingsController < ApplicationController persistent_counts = {} f = Goo::Filter.new(:pair_count) == false LinkedData::Models::MappingCount.where.filter(f) - .include(:ontologies,:count) - .all - .each do |m| + .include(:ontologies, :count) + .all + .each do |m| persistent_counts[m.ontologies.first] = m.count end reply persistent_counts @@ -189,9 +189,9 @@ class MappingsController < ApplicationController persistent_counts = {} LinkedData::Models::MappingCount.where(pair_count: true) .and(ontologies: ontology.acronym) - .include(:ontologies,:count) - .all - .each do |m| + .include(:ontologies, :count) + .all + .each do |m| other = m.ontologies.first if other == ontology.acronym other = m.ontologies[1] diff --git a/test/controllers/test_mappings_controller.rb b/test/controllers/test_mappings_controller.rb index 44bfa0321..e52ad2e35 100644 --- a/test/controllers/test_mappings_controller.rb +++ b/test/controllers/test_mappings_controller.rb @@ -4,7 +4,7 @@ class TestMappingsController < TestCase def self.before_suite - ["BRO-TEST-MAP-0","CNO-TEST-MAP-0","FAKE-TEST-MAP-0"].each do |acr| + ["BRO-TEST-MAP-0", "CNO-TEST-MAP-0", "FAKE-TEST-MAP-0"].each do |acr| LinkedData::Models::OntologySubmission.where(ontology: [acronym: acr]).to_a.each do |s| s.delete end @@ -14,29 +14,29 @@ def self.before_suite end end LinkedData::SampleData::Ontology.create_ontologies_and_submissions({ - process_submission: true, - acronym: "BRO-TEST-MAP", - name: "BRO-TEST-MAP", - file_path: "./test/data/ontology_files/BRO_v3.2.owl", - ont_count: 1, - submission_count: 1 - }) + process_submission: true, + acronym: "BRO-TEST-MAP", + name: "BRO-TEST-MAP", + file_path: "./test/data/ontology_files/BRO_v3.2.owl", + ont_count: 1, + submission_count: 1 + }) LinkedData::SampleData::Ontology.create_ontologies_and_submissions({ - process_submission: true, - acronym: "CNO-TEST-MAP", - name: "CNO-TEST-MAP", - file_path: "./test/data/ontology_files/CNO_05.owl", - ont_count: 1, - submission_count: 1 - }) + process_submission: true, + acronym: "CNO-TEST-MAP", + name: "CNO-TEST-MAP", + file_path: "./test/data/ontology_files/CNO_05.owl", + ont_count: 1, + submission_count: 1 + }) LinkedData::SampleData::Ontology.create_ontologies_and_submissions({ - process_submission: true, - acronym: "FAKE-TEST-MAP", - name: "FAKE-TEST-MAP", - file_path: "./test/data/ontology_files/fake_for_mappings.owl", - ont_count: 1, - submission_count: 1 - }) + process_submission: true, + acronym: "FAKE-TEST-MAP", + name: "FAKE-TEST-MAP", + file_path: "./test/data/ontology_files/fake_for_mappings.owl", + ont_count: 1, + submission_count: 1 + }) NcboCron::Models::QueryWarmer.new(Logger.new(TestLogFile.new)).run end @@ -162,7 +162,7 @@ def mappings_with_display get "/ontologies/#{ontology}/mappings?pagesize=#{pagesize}&page=#{page}&display=prefLabel" assert last_response.ok? mappings = MultiJson.load(last_response.body) - assert mappings["collection"].all? {|m| m["classes"].all? {|c| c["prefLabel"].is_a?(String) && c["prefLabel"].length > 0} } + assert mappings["collection"].all? { |m| m["classes"].all? { |c| c["prefLabel"].is_a?(String) && c["prefLabel"].length > 0 } } def_count = 0 next_page = 1 @@ -170,7 +170,7 @@ def mappings_with_display get "/ontologies/#{ontology}/mappings?pagesize=#{pagesize}&page=#{next_page}&display=prefLabel,definition" assert last_response.ok? mappings = MultiJson.load(last_response.body) - def_count += mappings["collection"].map {|m| m["classes"].map {|c| (c["definition"] || []).length }}.flatten.sum + def_count += mappings["collection"].map { |m| m["classes"].map { |c| (c["definition"] || []).length } }.flatten.sum next_page = mappings["nextPage"] end while (next_page) assert 10, def_count @@ -284,24 +284,23 @@ def delete_mapping rest_predicate = LinkedData::Mappings.mapping_predicates()["REST"][0] epr = Goo.sparql_query_client(:main) epr.query("SELECT (count(?s) as ?c) WHERE { ?s <#{rest_predicate}> ?o . }") - .each do |sol| + .each do |sol| assert sol[:c].object == 0 end mapping_term_a = ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Image_Algorithm", - "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Image", - "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Integration_and_Interoperability_Tools" ] - mapping_ont_a = ["BRO-TEST-MAP-0","BRO-TEST-MAP-0","BRO-TEST-MAP-0"] - + "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Image", + "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Integration_and_Interoperability_Tools"] + mapping_ont_a = ["BRO-TEST-MAP-0", "BRO-TEST-MAP-0", "BRO-TEST-MAP-0"] mapping_term_b = ["http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000202", - "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000203", - "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000205" ] - mapping_ont_b = ["CNO-TEST-MAP-0","CNO-TEST-MAP-0","CNO-TEST-MAP-0"] + "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000203", + "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000205"] + mapping_ont_b = ["CNO-TEST-MAP-0", "CNO-TEST-MAP-0", "CNO-TEST-MAP-0"] - relations = [ "http://www.w3.org/2004/02/skos/core#exactMatch", - "http://www.w3.org/2004/02/skos/core#closeMatch", - "http://www.w3.org/2004/02/skos/core#relatedMatch" ] + relations = ["http://www.w3.org/2004/02/skos/core#exactMatch", + "http://www.w3.org/2004/02/skos/core#closeMatch", + "http://www.w3.org/2004/02/skos/core#relatedMatch"] 3.times do |i| classes = {} @@ -315,8 +314,8 @@ def delete_mapping } post "/mappings/", - MultiJson.dump(mapping), - "CONTENT_TYPE" => "application/json" + MultiJson.dump(mapping), + "CONTENT_TYPE" => "application/json" assert last_response.status == 201 response = MultiJson.load(last_response.body) @@ -330,7 +329,7 @@ def delete_mapping elsif cls["links"]["ontology"].split("/")[-1] == mapping_ont_b[i] assert cls["@id"] == mapping_term_b[i] else - assert 1==0, "uncontrolled mapping response in post" + assert 1 == 0, "uncontrolled mapping response in post" end end sleep(1.2) # to ensure different in times in dates. Later test on recent mappings @@ -352,7 +351,7 @@ def delete_mapping epr = Goo.sparql_query_client(:main) epr.query("SELECT (count(?s) as ?c) WHERE { ?s <#{rest_predicate}> ?o . }") - .each do |sol| + .each do |sol| assert sol[:c].object == 0 end end From 48816ea06aa0148e6a748ac1c22ee2b7e06f9026 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 19 Aug 2022 16:38:05 +0200 Subject: [PATCH 03/15] move request_has_file? and ile_from_request to applicatio_helper --- helpers/application_helper.rb | 17 +++++++++++++++++ helpers/ontology_helper.rb | 16 ---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/helpers/application_helper.rb b/helpers/application_helper.rb index 181630992..75f93df07 100644 --- a/helpers/application_helper.rb +++ b/helpers/application_helper.rb @@ -421,6 +421,23 @@ def include_param_contains?(str) return class_params_include || params_include end + + ## + # Checks to see if the request has a file attached + def request_has_file? + @params.any? {|p,v| v.instance_of?(Hash) && v.key?(:tempfile) && v[:tempfile].instance_of?(Tempfile)} + end + + ## + # Looks for a file that was included as a multipart in a request + def file_from_request + @params.each do |param, value| + if value.instance_of?(Hash) && value.has_key?(:tempfile) && value[:tempfile].instance_of?(Tempfile) + return value[:filename], value[:tempfile] + end + end + return nil, nil + end private def naive_expiring_cache_write(key, object, timeout = 60) diff --git a/helpers/ontology_helper.rb b/helpers/ontology_helper.rb index e5798ff7d..898ce1038 100644 --- a/helpers/ontology_helper.rb +++ b/helpers/ontology_helper.rb @@ -35,22 +35,6 @@ def create_submission(ont) ont_submission end - ## - # Checks to see if the request has a file attached - def request_has_file? - @params.any? {|p,v| v.instance_of?(Hash) && v.key?(:tempfile) && v[:tempfile].instance_of?(Tempfile)} - end - - ## - # Looks for a file that was included as a multipart in a request - def file_from_request - @params.each do |param, value| - if value.instance_of?(Hash) && value.has_key?(:tempfile) && value[:tempfile].instance_of?(Tempfile) - return value[:filename], value[:tempfile] - end - end - return nil, nil - end ## # Add a file to the submission if a file exists in the params From 8d7203d0ec65002474669eab547b7bd8fc0c1841 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 19 Aug 2022 16:51:40 +0200 Subject: [PATCH 04/15] add mappings json file parser as a mapping helper --- helpers/mappings_helper.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/helpers/mappings_helper.rb b/helpers/mappings_helper.rb index e65a98d38..63b385311 100644 --- a/helpers/mappings_helper.rb +++ b/helpers/mappings_helper.rb @@ -33,6 +33,18 @@ def populate_mapping_classes(mappings) mappings end + ## + # Parse the uploaded mappings file + def parse_bulk_load_file + filename, tmpfile = file_from_request + if tmpfile + if filename.nil? + error 400, "Failure to resolve mappings json filename from upload file." + end + Array(::JSON.parse(tmpfile.read,{:symbolize_names => true})) + end + + end end end end From 007dcc82f16a72390047a14418d0b3146b0377bb Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 19 Aug 2022 16:54:02 +0200 Subject: [PATCH 05/15] add the '/load' post endpoint to mappings namespace --- controllers/mappings_controller.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/controllers/mappings_controller.rb b/controllers/mappings_controller.rb index 6154bd920..65925bd38 100644 --- a/controllers/mappings_controller.rb +++ b/controllers/mappings_controller.rb @@ -147,6 +147,18 @@ class MappingsController < ApplicationController reply(201, mapping) end + post '/load' do + begin + mappings = parse_bulk_load_file + loaded_mappings, errors = LinkedData::Mappings.bulk_load_mappings(mappings, current_user, check_exist: true) + response = {} + response[:created] = loaded_mappings unless loaded_mappings.empty? + response[:errors] = errors unless errors.empty? + reply(201, response) + rescue ::JSON::ParserError => e + error(404, "File parsing error: #{e.message}") + end + end # Delete a mapping delete '/:mapping' do mapping_id = RDF::URI.new(replace_url_prefix(params[:mapping])) From 061e9a8292e599a069c76a3ad53598b1c3bf9a5e Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 19 Aug 2022 16:55:35 +0200 Subject: [PATCH 06/15] extract commun_created_mappings_test method --- test/controllers/test_mappings_controller.rb | 57 ++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/test/controllers/test_mappings_controller.rb b/test/controllers/test_mappings_controller.rb index e52ad2e35..43bed4c29 100644 --- a/test/controllers/test_mappings_controller.rb +++ b/test/controllers/test_mappings_controller.rb @@ -54,6 +54,63 @@ def test_mappings_controllers_in_order mappings_statistics_for_ontology end + private + + def commun_created_mappings_test(created, mapping_ont_a, mapping_ont_b, mapping_term_a, mapping_term_b, relations) + assert_equal 3, created.size + created.each_with_index do |mapping, i| + + assert_equal "comment for mapping test #{i}", mapping["process"]["comment"] + refute_nil mapping["process"]["creator"]["users/tim"] + assert_equal [relations[i]], mapping["process"]["relation"] + refute_nil mapping["process"]["date"] + + mapping["classes"].each do |cls| + if cls["links"]["ontology"].split("/")[-1] == mapping_ont_a[i] + assert_equal mapping_term_a[i], cls["@id"] + elsif cls["links"]["ontology"].split("/")[-1] == mapping_ont_b[i] + assert_equal mapping_term_b[i], cls["@id"] + else + assert 1 == 0, 'uncontrolled mapping response in post' + end + end + end + + #there three mappings in BRO with processes + NcboCron::Models::QueryWarmer.new(Logger.new(TestLogFile.new)).run + ontology = "BRO-TEST-MAP-0" + get "/ontologies/#{ontology}/mappings?pagesize=1000&page=1" + assert last_response.ok? + mappings = MultiJson.load(last_response.body) + mappings = mappings["collection"] + assert_equal 21, mappings.length + rest_count = 0 + mappings.each do |x| + if x["process"] != nil + rest_count += 1 + #assert x["@id"] != nil + end + end + assert rest_count == 3 + + get "/mappings/recent/" + assert last_response.status == 200 + response = MultiJson.load(last_response.body) + assert (response.length == 5) + date = nil + response.each do |x| + assert x["@id"] != nil + assert x["classes"].length == 2 + assert x["process"] != nil + date_x = DateTime.iso8601(x["process"]["date"]) + if date + assert date >= date_x + end + date = date_x + end + + end + def mappings_for_ontology LinkedData::Models::RestBackupMapping.all.each do |m| LinkedData::Mappings.delete_rest_mapping(m.id) From eedaa3d258750ed20afe4099d2d9e772c2734d5d Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 19 Aug 2022 16:56:13 +0200 Subject: [PATCH 07/15] extract build_mappings_hash method in the test_mappings_controller --- test/controllers/test_mappings_controller.rb | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/controllers/test_mappings_controller.rb b/test/controllers/test_mappings_controller.rb index 43bed4c29..021b293a1 100644 --- a/test/controllers/test_mappings_controller.rb +++ b/test/controllers/test_mappings_controller.rb @@ -448,4 +448,40 @@ def mappings_statistics_for_ontology assert_equal 9, stats["CNO-TEST-MAP-0"] end + def build_mappings_hash(old_style: true) + # old_style is to remove when update and harmonize how we post a rest mapping + mapping_term_a = ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Image_Algorithm", + "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Image", + "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Integration_and_Interoperability_Tools"] + mapping_ont_a = ["BRO-TEST-MAP-0", "BRO-TEST-MAP-0", "BRO-TEST-MAP-0"] + + mapping_term_b = ["http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000202", + "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000203", + "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000205"] + mapping_ont_b = ["CNO-TEST-MAP-0", "CNO-TEST-MAP-0", "CNO-TEST-MAP-0"] + + relations = ["http://www.w3.org/2004/02/skos/core#exactMatch", + "http://www.w3.org/2004/02/skos/core#closeMatch", + "http://www.w3.org/2004/02/skos/core#relatedMatch"] + + mappings = [] + 3.times do |i| + + if old_style + classes = {} + classes[mapping_term_a[i]] = mapping_ont_a[i] + classes[mapping_term_b[i]] = mapping_ont_b[i] + else + classes = [mapping_term_a[i], mapping_term_b[i]] + end + + mappings << { classes: classes, + name: "name for mapping test #{i}", + comment: "comment for mapping test #{i}", + relation: relations[i], + creator: "http://data.bioontology.org/users/tim" + } + end + [mappings, mapping_ont_a, mapping_ont_b, mapping_term_a, mapping_term_b, relations] + end end From bbc40f17838611b20575af2fa19f7cd254ee6905 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 19 Aug 2022 17:00:52 +0200 Subject: [PATCH 08/15] use commun_created_mappings_test and build_mappings_hash --- test/controllers/test_mappings_controller.rb | 84 +++----------------- 1 file changed, 10 insertions(+), 74 deletions(-) diff --git a/test/controllers/test_mappings_controller.rb b/test/controllers/test_mappings_controller.rb index 021b293a1..d175c725f 100644 --- a/test/controllers/test_mappings_controller.rb +++ b/test/controllers/test_mappings_controller.rb @@ -249,88 +249,24 @@ def create_mapping LinkedData::Models::RestBackupMapping.all.each do |m| LinkedData::Mappings.delete_rest_mapping(m.id) end + mappings, mapping_ont_a, mapping_ont_b, mapping_term_a, mapping_term_b, relations = build_mappings_hash + created = [] - mapping_term_a = ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Image_Algorithm", - "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Image", - "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Integration_and_Interoperability_Tools" ] - mapping_ont_a = ["BRO-TEST-MAP-0","BRO-TEST-MAP-0","BRO-TEST-MAP-0"] - - - mapping_term_b = ["http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000202", - "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000203", - "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000205" ] - mapping_ont_b = ["CNO-TEST-MAP-0","CNO-TEST-MAP-0","CNO-TEST-MAP-0"] - - relations = [ "http://www.w3.org/2004/02/skos/core#exactMatch", - "http://www.w3.org/2004/02/skos/core#closeMatch", - "http://www.w3.org/2004/02/skos/core#relatedMatch" ] - - 3.times do |i| - classes = {} - classes[mapping_term_a[i]] = mapping_ont_a[i] - classes[mapping_term_b[i]] = mapping_ont_b[i] - - mapping = { classes: classes, - comment: "comment for mapping test #{i}", - relation: relations[i], - creator: "http://data.bioontology.org/users/tim" - } - - post "/mappings/", - MultiJson.dump(mapping), - "CONTENT_TYPE" => "application/json" + mappings.each_with_index do |mapping, i| + post '/mappings/', + MultiJson.dump(mapping), + "CONTENT_TYPE" => "application/json" assert last_response.status == 201 - response = MultiJson.load(last_response.body) - assert response["process"]["comment"] == "comment for mapping test #{i}" - assert response["process"]["creator"]["users/tim"] - assert response["process"]["relation"] == relations[i] - assert response["process"]["date"] != nil - response["classes"].each do |cls| - if cls["links"]["ontology"].split("/")[-1] == mapping_ont_a[i] - assert cls["@id"] == mapping_term_a[i] - elsif cls["links"]["ontology"].split("/")[-1] == mapping_ont_b[i] - assert cls["@id"] == mapping_term_b[i] - else - assert 1==0, "uncontrolled mapping response in post" - end - end + created << MultiJson.load(last_response.body) # to ensure different in times in dates. Later test on recent mappings sleep(1.2) end - #there three mappings in BRO with processes - NcboCron::Models::QueryWarmer.new(Logger.new(TestLogFile.new)).run - ontology = "BRO-TEST-MAP-0" - get "/ontologies/#{ontology}/mappings?pagesize=1000&page=1" - assert last_response.ok? - mappings = MultiJson.load(last_response.body) - mappings = mappings["collection"] - assert mappings.length == 21 - rest_count = 0 - mappings.each do |x| - if x["process"] != nil - rest_count += 1 - #assert x["@id"] != nil - end - end - assert rest_count == 3 + commun_created_mappings_test(created, mapping_ont_a, + mapping_ont_b, mapping_term_a, + mapping_term_b, relations) - get "/mappings/recent/" - assert last_response.status == 200 - response = MultiJson.load(last_response.body) - assert (response.length == 5) - date = nil - response.each do |x| - assert x["@id"] != nil - assert x["classes"].length == 2 - assert x["process"] != nil - date_x = DateTime.iso8601(x["process"]["date"]) - if date - assert date >= date_x - end - date = date_x - end end def delete_mapping From 5cf87e195e2ffec08fa099420cf14298a2c8c9b9 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 19 Aug 2022 17:01:22 +0200 Subject: [PATCH 09/15] add test_mappings_file_load in the test_mappings_controller.rb --- test/controllers/test_mappings_controller.rb | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/controllers/test_mappings_controller.rb b/test/controllers/test_mappings_controller.rb index d175c725f..d5cef2d41 100644 --- a/test/controllers/test_mappings_controller.rb +++ b/test/controllers/test_mappings_controller.rb @@ -54,6 +54,34 @@ def test_mappings_controllers_in_order mappings_statistics_for_ontology end + def test_mappings_file_load + LinkedData::Models::RestBackupMapping.all.each do |m| + LinkedData::Mappings.delete_rest_mapping(m.id) + end + + mappings, mapping_ont_a, mapping_ont_b, mapping_term_a, mapping_term_b, relations = build_mappings_hash(old_style: false) + file = Tempfile.open do |file| + file.write(mappings.to_json) + file.rewind + file + end + + user = User.all.first + user.bring :apikey + + header 'Authorization', "apikey token=#{user.apikey}" + post '/mappings/load', + file: Rack::Test::UploadedFile.new(file.to_path, 'application/json') + + assert last_response.status == 201 + response = MultiJson.load(last_response.body) + created = response["created"] + + LinkedData::Mappings.create_mapping_counts(Logger.new(TestLogFile.new)) + commun_created_mappings_test(created, mapping_ont_a, mapping_ont_b, + mapping_term_a, mapping_term_b, relations) + end + private def commun_created_mappings_test(created, mapping_ont_a, mapping_ont_b, mapping_term_a, mapping_term_b, relations) From 0682e855c8c0cd2cb1d010123d7e24e2bad213a4 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 19 Aug 2022 17:07:12 +0200 Subject: [PATCH 10/15] set OLD gem to 'pr/feature/add-rest-mapping-bulk-loader' to pass tests --- Gemfile | 2 +- Gemfile.lock | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index fdc0aac6f..9873e8a50 100644 --- a/Gemfile +++ b/Gemfile @@ -46,7 +46,7 @@ gem 'goo', github: 'ncbo/goo', branch: 'master' gem 'ncbo_annotator', github: 'ncbo/ncbo_annotator', branch: 'master' gem 'ncbo_cron', github: 'ncbo/ncbo_cron', branch: 'master' gem 'ncbo_ontology_recommender', github: 'ncbo/ncbo_ontology_recommender', branch: 'master' -gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'master' +gem 'ontologies_linked_data', github: 'ontoportal-lirmm/ontologies_linked_data', branch: 'pr/feature/add-rest-mapping-bulk-loader' gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'master' group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 2bea0ca41..b98b143a5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -52,9 +52,19 @@ GIT redis GIT - remote: https://github.com/ncbo/ontologies_linked_data.git - revision: 8196bf34b45c75f8104bb76dfcba1db0f2c048e4 + remote: https://github.com/ncbo/sparql-client.git + revision: fb4a89b420f8eb6dda5190a126b6c62e32c4c0c9 branch: master + specs: + sparql-client (1.0.1) + json_pure (>= 1.4) + net-http-persistent (= 2.9.4) + rdf (>= 1.0) + +GIT + remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git + revision: 0d524c89479b253cb0962eec5aaf3989663c4acf + branch: pr/feature/add-rest-mapping-bulk-loader specs: ontologies_linked_data (0.0.1) activesupport @@ -71,16 +81,6 @@ GIT rsolr rubyzip -GIT - remote: https://github.com/ncbo/sparql-client.git - revision: fb4a89b420f8eb6dda5190a126b6c62e32c4c0c9 - branch: master - specs: - sparql-client (1.0.1) - json_pure (>= 1.4) - net-http-persistent (= 2.9.4) - rdf (>= 1.0) - GIT remote: https://github.com/palexander/rack-post-body-to-params.git revision: 0fd30e710386d0cb8a3a6833d9549d7b655d5398 @@ -325,6 +325,7 @@ GEM webrick (1.7.0) PLATFORMS + x86_64-darwin-21 x86_64-linux DEPENDENCIES From fcc10e675d8023c9922a2f995abd3cb918d9231c Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Wed, 14 Sep 2022 18:44:56 +0200 Subject: [PATCH 11/15] add mappings_helpers to find the creator user of a mapping --- helpers/mappings_helper.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/helpers/mappings_helper.rb b/helpers/mappings_helper.rb index 63b385311..bd4036db7 100644 --- a/helpers/mappings_helper.rb +++ b/helpers/mappings_helper.rb @@ -45,6 +45,20 @@ def parse_bulk_load_file end end + def creator_id + params[:creator]&.start_with?("http://") ? + params[:creator]&.split("/")[-1] : params[:creator] + end + + def find_user + user_id = creator_id + user_creator = LinkedData::Models::User.find(user_id) + .include(:username).first + if user_creator.nil? + raise StandardError, "User with id `#{params[:creator]}` not found" + end + user_creator + end end end end From 8adfb027a3e6e2954f35a1f6aaee609d75fb9c86 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Wed, 14 Sep 2022 18:45:21 +0200 Subject: [PATCH 12/15] use LinkedData::Mappings.create_mapping --- controllers/mappings_controller.rb | 53 +++--------------------------- 1 file changed, 5 insertions(+), 48 deletions(-) diff --git a/controllers/mappings_controller.rb b/controllers/mappings_controller.rb index 65925bd38..644928572 100644 --- a/controllers/mappings_controller.rb +++ b/controllers/mappings_controller.rb @@ -96,55 +96,12 @@ class MappingsController < ApplicationController # Create a new mapping post do - error(400, "Input does not contain classes") if !params[:classes] - if params[:classes].length > 2 - error(400, "Input does not contain at least 2 terms") - end - error(400, "Input does not contain mapping relation") if !params[:relation] - error(400, "Input does not contain user creator ID") if !params[:creator] - classes = [] - params[:classes].each do |class_id,ontology_id| - o = ontology_id - o = o.start_with?("http://") ? ontology_id : - ontology_uri_from_acronym(ontology_id) - o = LinkedData::Models::Ontology.find(RDF::URI.new(o)) - .include(submissions: - [:submissionId, :submissionStatus]).first - if o.nil? - error(400, "Ontology with ID `#{ontology_id}` not found") - end - submission = o.latest_submission - if submission.nil? - error(400, - "Ontology with id #{ontology_id} does not have parsed valid submission") - end - submission.bring(ontology: [:acronym]) - c = LinkedData::Models::Class.find(RDF::URI.new(class_id)) - .in(submission) - .first - if c.nil? - error(400, "Class ID `#{id}` not found in `#{submission.id.to_s}`") - end - classes << c - end - user_id = params[:creator].start_with?("http://") ? - params[:creator].split("/")[-1] : params[:creator] - user_creator = LinkedData::Models::User.find(user_id) - .include(:username).first - if user_creator.nil? - error(400, "User with id `#{params[:creator]}` not found") - end - process = LinkedData::Models::MappingProcess.new( - :creator => user_creator, :name => "REST Mapping") - process.relation = RDF::URI.new(params[:relation]) - process.date = DateTime.now - process_fields = [:source,:source_name, :comment] - process_fields.each do |att| - process.send("#{att}=",params[att]) if params[att] + begin + mapping = LinkedData::Mappings.create_mapping(mapping_hash: params, user_creator: find_user) + reply(201, mapping) + rescue StandardError => e + error(400, e.message) end - process.save - mapping = LinkedData::Mappings.create_rest_mapping(classes,process) - reply(201, mapping) end post '/load' do From 5f41bb581d33dfda898766bfbd68a9e1ef4e2389 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Wed, 14 Sep 2022 18:46:21 +0200 Subject: [PATCH 13/15] update tests with the new mapping_hash structure --- Gemfile.lock | 2 +- test/controllers/test_mappings_controller.rb | 98 ++++++-------------- 2 files changed, 31 insertions(+), 69 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b98b143a5..b4a941a80 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -63,7 +63,7 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: 0d524c89479b253cb0962eec5aaf3989663c4acf + revision: b47236be37cb032366c25b457621a835fdce32ec branch: pr/feature/add-rest-mapping-bulk-loader specs: ontologies_linked_data (0.0.1) diff --git a/test/controllers/test_mappings_controller.rb b/test/controllers/test_mappings_controller.rb index d5cef2d41..a73f7fb54 100644 --- a/test/controllers/test_mappings_controller.rb +++ b/test/controllers/test_mappings_controller.rb @@ -59,7 +59,7 @@ def test_mappings_file_load LinkedData::Mappings.delete_rest_mapping(m.id) end - mappings, mapping_ont_a, mapping_ont_b, mapping_term_a, mapping_term_b, relations = build_mappings_hash(old_style: false) + mappings, mapping_ont_a, mapping_ont_b, mapping_term_a, mapping_term_b, relations = build_mappings_hash file = Tempfile.open do |file| file.write(mappings.to_json) file.rewind @@ -72,35 +72,30 @@ def test_mappings_file_load header 'Authorization', "apikey token=#{user.apikey}" post '/mappings/load', file: Rack::Test::UploadedFile.new(file.to_path, 'application/json') - assert last_response.status == 201 response = MultiJson.load(last_response.body) + created = response["created"] LinkedData::Mappings.create_mapping_counts(Logger.new(TestLogFile.new)) - commun_created_mappings_test(created, mapping_ont_a, mapping_ont_b, - mapping_term_a, mapping_term_b, relations) + commun_created_mappings_test(created, mapping_term_a, mapping_term_b, relations) end private - def commun_created_mappings_test(created, mapping_ont_a, mapping_ont_b, mapping_term_a, mapping_term_b, relations) + def commun_created_mappings_test(created, mapping_term_a, mapping_term_b, relations) + refute_nil created assert_equal 3, created.size created.each_with_index do |mapping, i| assert_equal "comment for mapping test #{i}", mapping["process"]["comment"] refute_nil mapping["process"]["creator"]["users/tim"] - assert_equal [relations[i]], mapping["process"]["relation"] + assert_equal [relations[i]], Array(mapping["process"]["relation"]) refute_nil mapping["process"]["date"] mapping["classes"].each do |cls| - if cls["links"]["ontology"].split("/")[-1] == mapping_ont_a[i] - assert_equal mapping_term_a[i], cls["@id"] - elsif cls["links"]["ontology"].split("/")[-1] == mapping_ont_b[i] - assert_equal mapping_term_b[i], cls["@id"] - else - assert 1 == 0, 'uncontrolled mapping response in post' - end + assert (mapping_term_b[i] == cls["@id"]) || (mapping_term_a[i] == cls["@id"]), + 'uncontrolled mapping response in post' end end @@ -291,9 +286,7 @@ def create_mapping sleep(1.2) end - commun_created_mappings_test(created, mapping_ont_a, - mapping_ont_b, mapping_term_a, - mapping_term_b, relations) + commun_created_mappings_test(created, mapping_term_a, mapping_term_b, relations) end @@ -309,52 +302,19 @@ def delete_mapping assert sol[:c].object == 0 end - mapping_term_a = ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Image_Algorithm", - "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Image", - "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Integration_and_Interoperability_Tools"] - mapping_ont_a = ["BRO-TEST-MAP-0", "BRO-TEST-MAP-0", "BRO-TEST-MAP-0"] - - mapping_term_b = ["http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000202", - "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000203", - "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000205"] - mapping_ont_b = ["CNO-TEST-MAP-0", "CNO-TEST-MAP-0", "CNO-TEST-MAP-0"] - - relations = ["http://www.w3.org/2004/02/skos/core#exactMatch", - "http://www.w3.org/2004/02/skos/core#closeMatch", - "http://www.w3.org/2004/02/skos/core#relatedMatch"] + mappings, mapping_ont_a, mapping_ont_b, mapping_term_a, mapping_term_b, relations = build_mappings_hash - 3.times do |i| - classes = {} - classes[mapping_term_a[i]] = mapping_ont_a[i] - classes[mapping_term_b[i]] = mapping_ont_b[i] - - mapping = { classes: classes, - comment: "comment for mapping test #{i}", - relation: relations[i], - creator: "http://data.bioontology.org/users/tim" - } + created = [] + mappings.each do |mapping| post "/mappings/", MultiJson.dump(mapping), "CONTENT_TYPE" => "application/json" - assert last_response.status == 201 - response = MultiJson.load(last_response.body) - assert response["process"]["comment"] == "comment for mapping test #{i}" - assert response["process"]["creator"]["users/tim"] - assert response["process"]["relation"] == relations[i] - assert response["process"]["date"] != nil - response["classes"].each do |cls| - if cls["links"]["ontology"].split("/")[-1] == mapping_ont_a[i] - assert cls["@id"] == mapping_term_a[i] - elsif cls["links"]["ontology"].split("/")[-1] == mapping_ont_b[i] - assert cls["@id"] == mapping_term_b[i] - else - assert 1 == 0, "uncontrolled mapping response in post" - end - end + created << MultiJson.load(last_response.body) sleep(1.2) # to ensure different in times in dates. Later test on recent mappings end + commun_created_mappings_test(created, mapping_term_a, mapping_term_b, relations) LinkedData::Models::RestBackupMapping.all.each do |m| m_id = CGI.escape(m.id.to_s) @@ -386,9 +346,9 @@ def mappings_statistics get "/mappings/statistics/ontologies/" assert last_response.ok? stats = MultiJson.load(last_response.body) - data = {"BRO-TEST-MAP-0"=>18, - "CNO-TEST-MAP-0"=>19, - "FAKE-TEST-MAP-0"=>17} + data = { "BRO-TEST-MAP-0" => 18, + "CNO-TEST-MAP-0" => 19, + "FAKE-TEST-MAP-0" => 17 } assert_equal data, stats end @@ -412,17 +372,23 @@ def mappings_statistics_for_ontology assert_equal 9, stats["CNO-TEST-MAP-0"] end - def build_mappings_hash(old_style: true) + def build_mappings_hash # old_style is to remove when update and harmonize how we post a rest mapping mapping_term_a = ["http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Image_Algorithm", "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Image", "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Integration_and_Interoperability_Tools"] - mapping_ont_a = ["BRO-TEST-MAP-0", "BRO-TEST-MAP-0", "BRO-TEST-MAP-0"] + mapping_ont_a = ["http://bioontology.org/ontologies/BiomedicalResources.owl", + "http://bioontology.org/ontologies/BiomedicalResources.owl", + "http://bioontology.org/ontologies/BiomedicalResources.owl" + ] mapping_term_b = ["http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000202", "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000203", "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl#cno_0000205"] - mapping_ont_b = ["CNO-TEST-MAP-0", "CNO-TEST-MAP-0", "CNO-TEST-MAP-0"] + + mapping_ont_b = ["http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl", + "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl", + "http://purl.org/incf/ontology/Computational_Neurosciences/cno_alpha.owl"] relations = ["http://www.w3.org/2004/02/skos/core#exactMatch", "http://www.w3.org/2004/02/skos/core#closeMatch", @@ -431,18 +397,14 @@ def build_mappings_hash(old_style: true) mappings = [] 3.times do |i| - if old_style - classes = {} - classes[mapping_term_a[i]] = mapping_ont_a[i] - classes[mapping_term_b[i]] = mapping_ont_b[i] - else - classes = [mapping_term_a[i], mapping_term_b[i]] - end + classes = [mapping_term_a[i], mapping_term_b[i]] mappings << { classes: classes, name: "name for mapping test #{i}", comment: "comment for mapping test #{i}", - relation: relations[i], + "subject_source_id": mapping_ont_a[i], + "object_source_id": mapping_ont_b[i], + relation: Array(relations[i]), creator: "http://data.bioontology.org/users/tim" } end From 34f0c7e0142603ce2f871b4ea4569f1ebcfc75bb Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Thu, 15 Sep 2022 18:38:45 +0200 Subject: [PATCH 14/15] update ontologies_linked_data brach to pass tests --- Gemfile | 2 +- Gemfile.lock | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 9873e8a50..e7548ba55 100644 --- a/Gemfile +++ b/Gemfile @@ -46,7 +46,7 @@ gem 'goo', github: 'ncbo/goo', branch: 'master' gem 'ncbo_annotator', github: 'ncbo/ncbo_annotator', branch: 'master' gem 'ncbo_cron', github: 'ncbo/ncbo_cron', branch: 'master' gem 'ncbo_ontology_recommender', github: 'ncbo/ncbo_ontology_recommender', branch: 'master' -gem 'ontologies_linked_data', github: 'ontoportal-lirmm/ontologies_linked_data', branch: 'pr/feature/add-rest-mapping-bulk-loader' +gem 'ontologies_linked_data', github: 'ontoportal-lirmm/ontologies_linked_data', branch: 'pr/refactor/centralize-mapping-creation' gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'master' group :development do diff --git a/Gemfile.lock b/Gemfile.lock index b4a941a80..abd0a0a04 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -63,8 +63,8 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: b47236be37cb032366c25b457621a835fdce32ec - branch: pr/feature/add-rest-mapping-bulk-loader + revision: 7868dd6bed68797086f5a9ac5e0faceb403c98a6 + branch: pr/refactor/centralize-mapping-creation specs: ontologies_linked_data (0.0.1) activesupport @@ -103,8 +103,8 @@ GEM activesupport (3.2.22.5) i18n (~> 0.6, >= 0.6.4) multi_json (~> 1.0) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) airbrussh (1.4.1) sshkit (>= 1.6.1, != 1.7.0) backports (3.23.0) @@ -131,7 +131,7 @@ GEM docile (1.4.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - faraday (1.10.1) + faraday (1.10.2) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -159,7 +159,7 @@ GEM ffi (~> 1.0) google-apis-analytics_v3 (0.10.0) google-apis-core (>= 0.7, < 2.a) - google-apis-core (0.7.0) + google-apis-core (0.7.2) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.16.2, < 2.a) httpclient (>= 2.8.1, < 3.a) @@ -188,7 +188,7 @@ GEM json-schema (2.8.1) addressable (>= 2.4) json_pure (2.6.2) - jwt (2.4.1) + jwt (2.5.0) kgio (2.11.4) libxml-ruby (3.2.3) logger (1.5.1) @@ -213,7 +213,7 @@ GEM net-ssh (>= 2.6.5) net-ssh (7.0.1) netrc (0.11.0) - newrelic_rpm (8.9.0) + newrelic_rpm (8.10.1) oj (2.18.5) omni_logger (0.1.4) logger @@ -224,7 +224,7 @@ GEM pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) - public_suffix (4.0.7) + public_suffix (5.0.0) rack (1.6.13) rack-accept (0.4.5) rack (>= 0.4) @@ -246,7 +246,7 @@ GEM rdf (1.0.8) addressable (>= 2.2) redcarpet (3.5.1) - redis (4.7.1) + redis (4.8.0) redis-activesupport (5.3.0) activesupport (>= 3, < 8) redis-store (>= 1.3, < 2) @@ -301,7 +301,7 @@ GEM rack-test sinatra (~> 1.4.0) tilt (>= 1.3, < 3) - sshkit (1.21.2) + sshkit (1.21.3) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) systemu (2.6.5) From 22f185e73bdd1297d6640874cecebb2364024124 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 16 Sep 2022 09:25:20 +0200 Subject: [PATCH 15/15] extract create_mapping_counts to the before_suite of mappings test --- test/controllers/test_mappings_controller.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/controllers/test_mappings_controller.rb b/test/controllers/test_mappings_controller.rb index a73f7fb54..031cb09ad 100644 --- a/test/controllers/test_mappings_controller.rb +++ b/test/controllers/test_mappings_controller.rb @@ -38,10 +38,14 @@ def self.before_suite submission_count: 1 }) NcboCron::Models::QueryWarmer.new(Logger.new(TestLogFile.new)).run + LinkedData::Mappings.create_mapping_counts(Logger.new(TestLogFile.new)) end def test_mappings_controllers_in_order - LinkedData::Mappings.create_mapping_counts(Logger.new(TestLogFile.new)) + LinkedData::Models::RestBackupMapping.all.each do |m| + LinkedData::Mappings.delete_rest_mapping(m.id) + end + mappings_between_ontologies mappings_for_ontology mappings_for_ontology_pages @@ -76,8 +80,7 @@ def test_mappings_file_load response = MultiJson.load(last_response.body) created = response["created"] - - LinkedData::Mappings.create_mapping_counts(Logger.new(TestLogFile.new)) + commun_created_mappings_test(created, mapping_term_a, mapping_term_b, relations) end