From 952a2ce4daf79ad672cc09a245cbe42d4846044a Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 21 Jun 2023 14:08:03 +0200 Subject: [PATCH] Test our parser --- .../activity_pub_poc/parser_test.clj | 27 +++++++++++++++++ .../resources/deleted_comments_minimal.ttl | 1 + src/test/resources/minimal.ttl | 30 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 src/test/clj/org/domaindrivenarchitecture/activity_pub_poc/parser_test.clj create mode 100644 src/test/resources/deleted_comments_minimal.ttl create mode 100644 src/test/resources/minimal.ttl diff --git a/src/test/clj/org/domaindrivenarchitecture/activity_pub_poc/parser_test.clj b/src/test/clj/org/domaindrivenarchitecture/activity_pub_poc/parser_test.clj new file mode 100644 index 0000000..26f0025 --- /dev/null +++ b/src/test/clj/org/domaindrivenarchitecture/activity_pub_poc/parser_test.clj @@ -0,0 +1,27 @@ +(ns org.domaindrivenarchitecture.activity-pub-poc.parser-test + (:require [clojure.test :refer :all] + [org.domaindrivenarchitecture.activity-pub-poc.parser :as sut])) + + +(def processed (slurp "src/test/resources/deleted_comments_minimal.ttl")) +(def expected-definitions ["@prefix : " + "@prefix as: " + "@prefix owl: " + "@prefix rdf: " + "@prefix xml: " + "@prefix xsd: " + "@prefix rdfs: " + "@base " + " a owl:Ontology ; rdfs:comment \"Extended Activity Streams 2.0 Vocabulary\"@en ; rdfs:label \"Activity Streams 2.0\"@en ; owl:imports " + "rdf:langString a rdfs:Datatype" + "xsd:duration a rdfs:Datatype"]) + +(deftest remove-comments-test + (is + (= processed + (sut/delete-comments-and-newlines "src/test/resources/minimal.ttl")))) + +((deftest find-definitions-test + (testing "Finding definitons" + (is (= expected-definitions + (sut/find-definitions processed)))))) \ No newline at end of file diff --git a/src/test/resources/deleted_comments_minimal.ttl b/src/test/resources/deleted_comments_minimal.ttl new file mode 100644 index 0000000..664788a --- /dev/null +++ b/src/test/resources/deleted_comments_minimal.ttl @@ -0,0 +1 @@ +@prefix : .@prefix as: .@prefix owl: .@prefix rdf: .@prefix xml: .@prefix xsd: .@prefix rdfs: .@base . a owl:Ontology ; rdfs:comment "Extended Activity Streams 2.0 Vocabulary"@en ; rdfs:label "Activity Streams 2.0"@en ; owl:imports .rdf:langString a rdfs:Datatype .xsd:duration a rdfs:Datatype . \ No newline at end of file diff --git a/src/test/resources/minimal.ttl b/src/test/resources/minimal.ttl new file mode 100644 index 0000000..583aaee --- /dev/null +++ b/src/test/resources/minimal.ttl @@ -0,0 +1,30 @@ +# Downloaded from https://www.w3.org/ns/activitystreams-owl + +@prefix : . +@prefix as: . +@prefix owl: . +@prefix rdf: . +@prefix xml: . +@prefix xsd: . +@prefix rdfs: . +@base . + + a owl:Ontology ; + rdfs:comment "Extended Activity Streams 2.0 Vocabulary"@en ; + rdfs:label "Activity Streams 2.0"@en ; + owl:imports . + +################################################################# +# +# Datatypes +# +################################################################# + +rdf:langString a rdfs:Datatype . +xsd:duration a rdfs:Datatype . + +################################################################# +# +# Object Properties +# +################################################################# \ No newline at end of file