Skip to content

Commit

Permalink
Begin working on TIME validator
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco De Salvo committed Jan 8, 2025
1 parent e3170e5 commit cefe26a
Show file tree
Hide file tree
Showing 31 changed files with 533 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEAfterEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEAfterEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEAfterFinishesEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEAfterFinishesEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEAfterMetByEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEAfterMetByEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEAfterTransitiveEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEAfterTransitiveEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEBeforeEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEBeforeEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEBeforeMeetsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEBeforeMeetsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEBeforeStartsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEBeforeStartsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEBeforeTransitiveEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEBeforeTransitiveEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEContainsEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEContainsEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEContainsTransitiveEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEContainsTransitiveEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEDuringEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEDuringEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEDuringTransitiveEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEDuringTransitiveEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEEqualsInverseEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEEqualsInverseEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEEqualsTransitiveEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEEqualsTransitiveEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEFinishedByEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEFinishedByEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEFinishesEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEFinishesEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEMeetsEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEMeetsEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEMeetsStartsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEMeetsStartsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEMetByEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEMetByEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEOverlappedByEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEOverlappedByEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEOverlapsEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEOverlapsEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEStartedByEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEStartedByEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEStartsEqualsEntailmentRuleTest : TIMEBaseEntailmentRuleTest
public class TIMEStartsEqualsEntailmentRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
Expand Down
1 change: 0 additions & 1 deletion OWLSharp.Test/Extensions/TIME/Reasoner/TIMEReasonerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using OWLSharp.Extensions.TIME;
using System.Collections.Generic;

namespace OWLSharp.Test.Extensions.TIME
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ limitations under the License.
namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEBaseEntailmentRuleTest
public class TIMETestOntology
{
#region Properties
internal static OWLOntology TestOntology { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
Copyright 2014-2025 Marco De Salvo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OWLSharp.Extensions.TIME;
using OWLSharp.Ontology;
using OWLSharp.Validator;
using RDFSharp.Model;

namespace OWLSharp.Test.Extensions.TIME
{
[TestClass]
public class TIMEInstantAfterAnalysisRuleTest : TIMETestOntology
{
#region Tests
[TestMethod]
public async Task ShouldAnalyzeInstantAfterAndViolateRule1()
{
OWLOntology ontology = new OWLOntology(TestOntology);
ontology.DeclarationAxioms.AddRange([
new OWLDeclaration(new OWLNamedIndividual(new RDFResource("ex:InstantA"))),
new OWLDeclaration(new OWLNamedIndividual(new RDFResource("ex:InstantB"))),
new OWLDeclaration(new OWLNamedIndividual(new RDFResource("ex:InstantC"))),
]);
ontology.AssertionAxioms.AddRange([
new OWLClassAssertion(
new OWLClass(RDFVocabulary.TIME.INSTANT),
new OWLNamedIndividual(new RDFResource("ex:InstantA"))),
new OWLClassAssertion(
new OWLClass(RDFVocabulary.TIME.INSTANT),
new OWLNamedIndividual(new RDFResource("ex:InstantB"))),
new OWLClassAssertion(
new OWLClass(RDFVocabulary.TIME.INSTANT),
new OWLNamedIndividual(new RDFResource("ex:InstantC"))),
new OWLObjectPropertyAssertion(
new OWLObjectProperty(RDFVocabulary.TIME.AFTER),
new OWLNamedIndividual(new RDFResource("ex:InstantA")),
new OWLNamedIndividual(new RDFResource("ex:InstantB"))),
new OWLObjectPropertyAssertion(
new OWLObjectProperty(RDFVocabulary.TIME.AFTER),
new OWLNamedIndividual(new RDFResource("ex:InstantB")),
new OWLNamedIndividual(new RDFResource("ex:InstantA"))), //clash
new OWLObjectPropertyAssertion(
new OWLObjectProperty(RDFVocabulary.TIME.AFTER),
new OWLNamedIndividual(new RDFResource("ex:InstantA")),
new OWLNamedIndividual(new RDFResource("ex:InstantC"))),
]);
List<OWLIssue> issues = await TIMEInstantAfterAnalysisRule.ExecuteRuleAsync(ontology);

Assert.IsNotNull(issues);
Assert.IsTrue(issues.Count == 2);
Assert.IsTrue(issues[0].Severity == OWLEnums.OWLIssueSeverity.Error);
Assert.IsTrue(string.Equals(issues[0].RuleName, TIMEInstantAfterAnalysisRule.rulename));
Assert.IsTrue(string.Equals(issues[0].Description, TIMEInstantAfterAnalysisRule.rulesugg1));
Assert.IsTrue(issues[1].Severity == OWLEnums.OWLIssueSeverity.Error);
Assert.IsTrue(string.Equals(issues[1].RuleName, TIMEInstantAfterAnalysisRule.rulename));
Assert.IsTrue(string.Equals(issues[1].Description, TIMEInstantAfterAnalysisRule.rulesugg1));
}

[TestMethod]
public async Task ShouldAnalyzeInstantAfterAndViolateRule2()
{
OWLOntology ontology = new OWLOntology(TestOntology);
ontology.DeclarationAxioms.AddRange([
new OWLDeclaration(new OWLNamedIndividual(new RDFResource("ex:InstantA"))),
new OWLDeclaration(new OWLNamedIndividual(new RDFResource("ex:InstantB"))),
new OWLDeclaration(new OWLNamedIndividual(new RDFResource("ex:InstantC"))),
]);
ontology.AssertionAxioms.AddRange([
new OWLClassAssertion(
new OWLClass(RDFVocabulary.TIME.INSTANT),
new OWLNamedIndividual(new RDFResource("ex:InstantA"))),
new OWLClassAssertion(
new OWLClass(RDFVocabulary.TIME.INSTANT),
new OWLNamedIndividual(new RDFResource("ex:InstantB"))),
new OWLClassAssertion(
new OWLClass(RDFVocabulary.TIME.INSTANT),
new OWLNamedIndividual(new RDFResource("ex:InstantC"))),
new OWLObjectPropertyAssertion(
new OWLObjectProperty(RDFVocabulary.TIME.AFTER),
new OWLNamedIndividual(new RDFResource("ex:InstantA")),
new OWLNamedIndividual(new RDFResource("ex:InstantB"))),
new OWLObjectPropertyAssertion(
new OWLObjectProperty(RDFVocabulary.TIME.BEFORE),
new OWLNamedIndividual(new RDFResource("ex:InstantA")),
new OWLNamedIndividual(new RDFResource("ex:InstantB"))), //clash
new OWLObjectPropertyAssertion(
new OWLObjectProperty(RDFVocabulary.TIME.AFTER),
new OWLNamedIndividual(new RDFResource("ex:InstantA")),
new OWLNamedIndividual(new RDFResource("ex:InstantC"))),
]);
List<OWLIssue> issues = await TIMEInstantAfterAnalysisRule.ExecuteRuleAsync(ontology);

Assert.IsNotNull(issues);
Assert.IsTrue(issues.Count == 1);
Assert.IsTrue(issues[0].Severity == OWLEnums.OWLIssueSeverity.Error);
Assert.IsTrue(string.Equals(issues[0].RuleName, TIMEInstantAfterAnalysisRule.rulename));
Assert.IsTrue(string.Equals(issues[0].Description, TIMEInstantAfterAnalysisRule.rulesugg2));
}
#endregion
}
}
Loading

0 comments on commit cefe26a

Please sign in to comment.