<commit_before>package es.weso.server

import cats.effect.IO
import io.circe.Json
import io.circe.parser._
import org.http4s.{ Query, Request, Response, Uri }
import org.scalatest._
import org.http4s.dsl._
import cats.syntax.either._
import org.http4s.dsl.io._

class ValidateShEx extends FunSpec with Matchers with EitherValues {

  val ip = "0.0.0.0"
  val port = 8080
  val server = new ShaclexServer(ip, port)

  def serve(req: Request[IO]): Response[IO] =
    server.service.orNotFound(req).unsafeRunSync

  describe("ValidateShEx") {
    it("Should return 200 when asking for root") {
      val response = serve(Request(GET, Uri(path = "/")))
      response.status should be(Ok)
    }

    it("Should run test API method") {
      val response = serve(Request(
        GET,
        Uri(
          path = "/api/test",
          query = Query.fromPairs(("name", "<John>")))))
      response.status should be(Ok)
      response.as[String].unsafeRunSync() should be("Hello <John>")
    }

    it("Should validate a single example using ShEx") {
      val dataStr =
        """prefix : <http://example.org/>
          |prefix sh: <http://www.w3.org/ns/shacl#>
          |:x :p 1 .
          |:S sh:targetNode :x .
          |""".stripMargin

      val schemaStr =
        """prefix : <http://example.org/>
          |:S { :p . }
          |""".stripMargin

      val response = serve(Request(
        GET,
        Uri(
          path = "/api/validate",
          query = Query.fromPairs(
            ("data", dataStr), ("schema", schemaStr),
            ("schemaFormat", "SHEXC"), ("schemaEngine", "ShEx")))))

      response.status should be(Ok)
      val strResponse = response.as[String].unsafeRunSync()
      println(s"strResponse=$strResponse")
      val jsonResponse = parse(strResponse).getOrElse(Json.Null)
      println(s"jsonResponse=$jsonResponse")
      val isValid: Option[Boolean] =
        jsonResponse.hcursor.get[Boolean]("valid").toOption
      isValid shouldBe Some(true)
    }
  }
}<commit_msg>Repaired Query clash name in test<commit_after>package es.weso.server

import cats.effect.IO
import io.circe.Json
import io.circe.parser._
import org.http4s.{ Request, Response, Uri }
import org.http4s.{ Query => HQuery }
import org.scalatest._
import org.http4s.dsl._
import cats.syntax.either._
import org.http4s.dsl.io._

class ValidateShEx extends FunSpec with Matchers with EitherValues {

  val ip = "0.0.0.0"
  val port = 8080
  val server = new ShaclexServer(ip, port)

  def serve(req: Request[IO]): Response[IO] =
    server.service.orNotFound(req).unsafeRunSync

  describe("ValidateShEx") {
    it("Should return 200 when asking for root") {
      val response = serve(Request(GET, Uri(path = "/")))
      response.status should be(Ok)
    }

    it("Should run test API method") {
      val response = serve(Request(
        GET,
        Uri(
          path = "/api/test",
          query = HQuery.fromPairs(("name", "<John>")))))
      response.status should be(Ok)
      response.as[String].unsafeRunSync() should be("Hello <John>")
    }

    it("Should validate a single example using ShEx") {
      val dataStr =
        """prefix : <http://example.org/>
          |prefix sh: <http://www.w3.org/ns/shacl#>
          |:x :p 1 .
          |:S sh:targetNode :x .
          |""".stripMargin

      val schemaStr =
        """prefix : <http://example.org/>
          |:S { :p . }
          |""".stripMargin

      val response = serve(Request(
        GET,
        Uri(
          path = "/api/validate",
          query = HQuery.fromPairs(
            ("data", dataStr), ("schema", schemaStr),
            ("schemaFormat", "SHEXC"), ("schemaEngine", "ShEx")))))

      response.status should be(Ok)
      val strResponse = response.as[String].unsafeRunSync()
      println(s"strResponse=$strResponse")
      val jsonResponse = parse(strResponse).getOrElse(Json.Null)
      println(s"jsonResponse=$jsonResponse")
      val isValid: Option[Boolean] =
        jsonResponse.hcursor.get[Boolean]("valid").toOption
      isValid shouldBe Some(true)
    }
  }
}
{'fraction_non_alphanumeric': 0.14278716629928973, 'fraction_numerical': 0.008082292432035268, 'mean_word_length': 2.5543951261966926, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1217578', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1275, 'n_words': 300}