Skip to content
Snippets Groups Projects
Select Git revision
  • 9b547cc1be335eb43d1c9693d0a1d75cbc55acce
  • master default protected
  • dev protected
  • Issue/3003-stsInstitute
  • gitkeep
  • Issue/2449-GuidPidSlugToProjectSettings
  • Issue/2309-docs
  • Fix/xxxx-updateDependencies
  • Issue/2364-testingKpiParser
  • Issue/2287-guestRole
  • Test/xxxx-pipelineTriggers
  • Issue/2102-gitLabResTypeRCV
  • Issue/2278-gitlabToS
  • Issue/2101-gitLabResTypeUi
  • Issue/1788-extractionCronjob
  • Issue/2183-kpiGeneratorResource
  • Issue/2222-resourceDateCreated
  • Issue/2221-projectDateCreated
  • Issue/1321-pidEnquiryOverhaul
  • Issue/1999-gitlabResourcesLib
  • Issue/1951-quotaImplementation
  • v2.22.0
  • v2.20.0
  • v2.19.1
  • v2.19.0
  • v2.18.0
  • v2.17.0
  • v2.16.2
  • v2.16.1
  • v2.16.0
  • v2.15.0
  • v2.14.0
  • v2.13.0
  • v2.12.1
  • v2.12.0
  • v2.11.1
  • v2.11.0
  • v2.10.1
  • v2.10.0
  • v2.9.1
  • v2.9.0
41 results

AssemblyInfo.cs

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    GenericTests.cs 3.86 KiB
    using Coscine.Configuration;
    using NUnit.Framework;
    using System;
    using VDS.RDF.Parsing;
    
    namespace Coscine.Metadata.Tests
    {
        [TestFixture]
        public class GenericTests
        {
            private readonly IConfiguration _configuration = new ConsulConfiguration();
    
            private RdfStoreConnector _rdfStoreConnector;
    
            [OneTimeSetUp]
            public void Init()
            {
                _rdfStoreConnector = new RdfStoreConnector(_configuration.GetStringAndWait("coscine/local/virtuoso/additional/url"));
            }
    
            [Test]
            public void HasGraphTest()
            {
                Assert.IsTrue(_rdfStoreConnector.HasGraph("http://www.openlinksw.com/schemas/virtrdf#"));
                Assert.IsTrue(_rdfStoreConnector.HasGraph("http://localhost:8890/DAV/"));
                Assert.IsFalse(_rdfStoreConnector.HasGraph("https://test.de/fdgdhjklö/"));
            }
    
            [Test]
            public void GetGraphTest()
            {
                Assert.IsFalse(_rdfStoreConnector.GetGraph("http://www.openlinksw.com/schemas/virtrdf#").IsEmpty);
                Assert.IsFalse(_rdfStoreConnector.GetGraph("http://localhost:8890/DAV/").IsEmpty);
                // Returns an empty graph, if the graph does not exists
                Assert.IsTrue(_rdfStoreConnector.GetGraph("https://test.de/fdgdhjklö/").IsEmpty);
            }
    
            [Test]
            public void GetOrganizations()
            {
                Assert.NotNull(_rdfStoreConnector.GetTriplesByObject(null, null, new Uri("http://www.w3.org/ns/org#FormalOrganization")));
            }
    
            [Test]
            public void TestValidation()
            {
                string metadata = "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.\r\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.\r\n@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.\r\n\r\n<https://hdl.handle.net/11148/865c34ff-0b34-49ce-a3cb-9e63026e540d@path=%2Findex.ttl> <http://purl.obolibrary.org/obo/NCIT_C12801> \"Heart\";\r\n                                                                                      <http://purl.obolibrary.org/obo/NCIT_C25219> \"wer\";\r\n                                                                                      <http://purl.obolibrary.org/obo/NCIT_C42790> \"awt\";\r\n                                                                                      <http://purl.obolibrary.org/obo/NCIT_C45293> \"Human\";\r\n                                                                                      <http://purl.obolibrary.org/obo/NCIT_C48163> \"FFPE\";\r\n                                                                                      <http://purl.obolibrary.org/obo/NCIT_C80225> \"eweraerawrawerawerwearawerwaerawerawerer\";\r\n                                                                                      <http://purl.obolibrary.org/obo/SCDO_0002829> \"awt\";\r\n                                                                                      <http://purl.org/dc/terms/created> \"2023-01-18\"^^xsd:date;\r\n                                                                                      <http://purl.org/dc/terms/creator> \"Benedikt Heinrichs\";\r\n                                                                                      a <https://purl.org/coscine/ap/kuppelab/merfish/>;\r\n                                                                                      <https://purl.org/coscine/terms/4978e908-8918-4022-aed6-f295a5d6a2d8/> \"wer\".\r\n";
                Uri graphNameUri = new("https://hdl.handle.net/11148/865c34ff-0b34-49ce-a3cb-9e63026e540d@path=%2Findex.ttl");
    
                var graph = _rdfStoreConnector.ParseGraph(metadata, new TurtleParser());
                graph.BaseUri = new Uri("https://hdl.handle.net/11148/865c34ff-0b34-49ce-a3cb-9e63026e540d@path=%2Findex.ttl");
    
                Assert.IsTrue(_rdfStoreConnector.ValidateShacl(graph, graphNameUri, new Uri("https://purl.org/coscine/ap/kuppelab/merfish/1669378490042/")));
            }
        }
    }