test/controllers/test_external_mappings_controller.rb
# Create and delete an interportal mapping
Create and delete an interportal mapping
Create and delete an interportal mapping
def delete_interportal_mappings
    classes = { "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Knowledge_Extraction"=> "BRO-TEST-MAP-0",
                "http://neurolog.unice.fr/ontoneurolog/v3.0/dolce-particular.owl#event"=> "ncbo:OntoVIP"
    }
    mapping = { classes: classes,
                comment: "testing external mappings",
                relation: ["http://www.w3.org/2004/02/skos/core#exactMatch", "http://purl.org/linguistics/gold/translation"],
                creator: "tim"
    }
    post "/mappings", MultiJson.dump(mapping), "CONTENT_TYPE" => "application/json"
    assert last_response.status == 201, "Error creating the interportal mapping: #{last_response.body}"
    mapping_created = false
    LinkedData::Models::RestBackupMapping.all.each do |m|
      m_id = CGI.escape(m.id.to_s)
      get "/mappings/#{m_id}"
      assert last_response.status == 200
      mapping = MultiJson.load(last_response.body)
      assert mapping["classes"].length == 2
      mapping["classes"].each do |cls|
        if cls["@id"].to_s == "http://neurolog.unice.fr/ontoneurolog/v3.0/dolce-particular.owl#event"
          mapping_created = true
        end
      end
      assert mapping["process"] != nil
      delete "/mappings/#{m_id}"
      assert last_response.status == 204
      get "/mappings/#{m_id}"
      assert last_response.status == 404
    end
    assert mapping_created == true
    assert LinkedData::Models::RestBackupMapping.all.count == 0
  end
def delete_interportal_mappings classes = { "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Knowledge_Extraction" => "BRO-TEST-MAP-0" , "http://neurolog.unice.fr/ontoneurolog/v3.0/dolce-particular.owl#event" => "ncbo:OntoVIP" } mapping = { classes : classes , comment : "testing external mappings" , relation : [ "http://www.w3.org/2004/02/skos/core#exactMatch" , "http://purl.org/linguistics/gold/translation" ] , creator : "tim" } post "/mappings" , MultiJson . dump ( mapping ) , "CONTENT_TYPE" => "application/json" assert last_response . status == 201 , "Error creating the interportal mapping: #{last_response.body}" mapping_created = false LinkedData :: Models :: RestBackupMapping . all . each do | m | m_id = CGI . escape ( m . id . to_s ) get "/mappings/#{m_id}" assert last_response . status == 200 mapping = MultiJson . load ( last_response . body ) assert mapping [ "classes" ] . length == 2 mapping [ "classes" ] . each do | cls | if cls [ "@id" ] . to_s == "http://neurolog.unice.fr/ontoneurolog/v3.0/dolce-particular.owl#event" mapping_created = true end end assert mapping [ "process" ] != nil delete "/mappings/#{m_id}" assert last_response . status == 204 get "/mappings/#{m_id}" assert last_response . status == 404 end assert mapping_created == true assert LinkedData :: Models :: RestBackupMapping . all . count == 0 end
Create and delete an interportal mapping
Create and delete an interportal mapping
# For this test to work the test.rb config file has to include: # config.interportal_hash   = {"ncbo" => {"api" => "http://data.bioontology.org", "ui" => "http://bioportal.bioontology.org", "apikey" => "..."}} # to check if the interportal mapping we wanted have been created