
import de.tu_dresden.lat.prettyPrinting.datatypes.{BaseConcept, BaseRole, DisjointnessAxiom, DomainAxiom, TransitiveRoleAxiom, ConceptEquivalence, Ontology}
import de.tu_dresden.lat.prettyPrinting.parsing.DLParser
import org.junit.Test
import org.junit.Assert.assertEquals
import org.scalatest.junit.JUnitSuite


class TestParsing extends JUnitSuite {
  val disjointnessString =
    "disjoint(<http://www.co-ode.org/ontologies/pizza/pizza.owl#FruitTopping>, <http://www.co-ode.org/ontologies/pizza/pizza.owl#CheeseTopping>, <http://www.co-ode.org/ontologies/pizza/pizza.owl#SauceTopping>)"
  val disjointnessOntology = Ontology.buildFrom(Set(DisjointnessAxiom(Set(
    BaseConcept("<http://www.co-ode.org/ontologies/pizza/pizza.owl#FruitTopping>"),
    BaseConcept("<http://www.co-ode.org/ontologies/pizza/pizza.owl#CheeseTopping>"),
    BaseConcept("<http://www.co-ode.org/ontologies/pizza/pizza.owl#SauceTopping>")))))

  val domainString =
    "domain(<http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping>) = <http://www.co-ode.org/ontologies/pizza/pizza.owl#Pizza>"
  val domainOntology = Ontology.buildFrom(Set(DomainAxiom(
    BaseRole("<http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping>"),
    BaseConcept("<http://www.co-ode.org/ontologies/pizza/pizza.owl#Pizza>"))))

  val transitiveString =
    "trans(<http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping>)"
  val transitiveOntology = Ontology.buildFrom(Set(TransitiveRoleAxiom(
    BaseRole("<http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping>"))))

  val equivalenceString =
    "<http://www.co-ode.org/ontologies/pizza/pizza.owl#FruitTopping>=<http://www.co-ode.org/ontologies/pizza/pizza.owl#CheeseTopping>"
  val equivalenceOntology = Ontology.buildFrom(Set(ConceptEquivalence(Set(
    BaseConcept("<http://www.co-ode.org/ontologies/pizza/pizza.owl#FruitTopping>"),
    BaseConcept("<http://www.co-ode.org/ontologies/pizza/pizza.owl#CheeseTopping>")))))

  @Test
  def testParsingStrings() = {

    val parsedDisjointness = DLParser.parse(disjointnessString)
    assertEquals(parsedDisjointness, disjointnessOntology)
    
    val parsedTransitive = DLParser.parse(transitiveString)
    assertEquals(parsedTransitive, transitiveOntology)
    
    val parsedDomain = DLParser.parse(domainString)
    assertEquals(parsedDomain, domainOntology)

    val parsedEquivalence = DLParser.parse(equivalenceString)
    assertEquals(parsedEquivalence, equivalenceOntology)
  }


}
