<commit_before>package castalia.matcher

import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec}

/**
  * Created by <NAME> on 2016-01-09
  */
class RequestMatcherTest extends WordSpec with Matchers with BeforeAndAfterEach{

  private var uriMatcher: RequestMatcher = _

  override def beforeEach() {
    val s1 = List("sample", "path", "with", "{partyId}", "id")
    val s2 = List("another", "path", "without", "id")

    val m1 = new Matcher(s1, "a1")
    val m2 = new Matcher(s2, "a2")

    val matchers = List(m1, m2)

    uriMatcher = new RequestMatcher(matchers)
  }

  "RequestMatcherTest" should {

    "not find a match for an incorrect Request" in {

      val r1 = uriMatcher.matchRequest("foo")
      r1.shouldBe(None)

    }

    "find a match for a correct Request" in {
      val r1 = uriMatcher.matchRequest("http://localhost:1234/sample/path/with/12/id?p1=foo&p2=bar")
      r1.get.handler.shouldBe("a1")
    }

    "find a match for another correct Request" in {
      val r1 = uriMatcher.matchRequest("http://localhost:1234/another/path/without/id?p1=foo&p2=bar")
      r1.get.handler.shouldBe("a2")
    }
  }
}
<commit_msg>Improve unit test (verify correct extraction of path parameters<commit_after>package castalia.matcher

import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec}

/**
  * Created by <NAME> on 2016-01-09
  */
class RequestMatcherTest extends WordSpec with Matchers with BeforeAndAfterEach{

  private var uriMatcher: RequestMatcher = _

  override def beforeEach() {
    val s1 = List("sample", "path", "with", "{partyId}", "id")
    val s2 = List("another", "path", "without", "id")

    val m1 = new Matcher(s1, "a1")
    val m2 = new Matcher(s2, "a2")

    val matchers = List(m1, m2)

    uriMatcher = new RequestMatcher(matchers)
  }

  "RequestMatcherTest" should {

    "not find a match for an incorrect Request" in {

      val r1 = uriMatcher.matchRequest("foo")
      r1.shouldBe(None)

    }

    "find a match for a correct Request" in {
      val r1 = uriMatcher.matchRequest("http://localhost:1234/sample/path/with/12/id?p1=foo&p2=bar")
      r1.get.handler.shouldBe("a1")

      val pathParms = r1.get.pathParams

      pathParms.length.shouldBe(1)
      pathParms.head._1.shouldBe("partyId")
      pathParms.head._2.shouldBe("12")
    }

    "find a match for another correct Request" in {
      val r1 = uriMatcher.matchRequest("http://localhost:1234/another/path/without/id?p1=foo&p2=bar")
      r1.get.handler.shouldBe("a2")
      val pathParms = r1.get.pathParams
      pathParms.isEmpty.shouldBe(true)
    }
  }
}

{'fraction_non_alphanumeric': 0.13181291070738307, 'fraction_numerical': 0.03362968689601856, 'mean_word_length': 3.349579831932773, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '3868680', 'n_tokens_mistral': 929, 'n_tokens_neox': 871, 'n_words': 208}