<commit_before>package io.gatling.core.filter

import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner

@RunWith(classOf[JUnitRunner])
class FiltersSpec extends Specification {

	"Filters" should {
		"be able to deal with incorrect patterns" in {
			val w = WhiteList(List("http://foo\\.com.*", "},{"))
			(w.regexes must not beEmpty) and (w.accept("http://foo.com/bar.html") must beTrue)
		}
	}

	val hosts = List(
		"http://excilys.com",
		"http://ebusinessinformation.fr",
		"http://gatling.io")

	val paths = List(
		"",
		"infos.html",
		"/assets/images/foo.png",
		"/assets/js/bar.js")

	val urls = for {
		host <- hosts
		path <- paths
	} yield host + path

	val whiteList = WhiteList(List("http://excilys.*"))
	val emptyWhiteList = WhiteList()
	val blackList = BlackList(List("http://.*/assets/.*"))
	val emptyBlackList = BlackList()

	"FiltersHelper" should {

		def isRequestAccepted(filters: Filters, partition: (List[String], List[String])) = {
			val (expectedAccepted, expectedRejected) = partition

			(filters.accept(_: String) must beTrue).foreach(expectedAccepted) and (
				(filters.accept(_: String) must beFalse).foreach(expectedRejected))
		}

		"filter whitelist correctly when blacklist is empty" in {

			isRequestAccepted(Filters(whiteList, emptyBlackList), urls.partition(_.contains("excilys")))
		}

		"filter whitelist then blacklist when both are specified on whitefirst mode" in {

			isRequestAccepted(Filters(whiteList, blackList), urls.partition { url =>
				url.contains("excilys") && !url.contains("assets")
			})
		}

		"filter blacklist correctly when whitelist is empty" in {

			isRequestAccepted(Filters(blackList, emptyWhiteList), urls.partition { url =>
				!url.contains("assets")
			})
		}

		"filter blacklist then whitelist when both are specified on blackfirst mode" in {

			isRequestAccepted(Filters(blackList, whiteList), urls.partition { url =>
				!url.contains("assets") && url.contains("excilys")
			})
		}
	}
}
<commit_msg>FiltersHelper doesn't exist anymore.<commit_after>package io.gatling.core.filter

import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner

@RunWith(classOf[JUnitRunner])
class FiltersSpec extends Specification {

	val hosts = List(
		"http://excilys.com",
		"http://ebusinessinformation.fr",
		"http://gatling.io")

	val paths = List(
		"",
		"infos.html",
		"/assets/images/foo.png",
		"/assets/js/bar.js")

	val urls = for {
		host <- hosts
		path <- paths
	} yield host + path

	val whiteList = WhiteList(List("http://excilys.*"))
	val emptyWhiteList = WhiteList()
	val blackList = BlackList(List("http://.*/assets/.*"))
	val emptyBlackList = BlackList()

	"Filters" should {

		def isRequestAccepted(filters: Filters, partition: (List[String], List[String])) = {
			val (expectedAccepted, expectedRejected) = partition

			(filters.accept(_: String) must beTrue).foreach(expectedAccepted) and (
				(filters.accept(_: String) must beFalse).foreach(expectedRejected))
		}

		"filter whitelist correctly when blacklist is empty" in {

			isRequestAccepted(Filters(whiteList, emptyBlackList), urls.partition(_.contains("excilys")))
		}

		"filter whitelist then blacklist when both are specified on whitefirst mode" in {

			isRequestAccepted(Filters(whiteList, blackList), urls.partition { url =>
				url.contains("excilys") && !url.contains("assets")
			})
		}

		"filter blacklist correctly when whitelist is empty" in {

			isRequestAccepted(Filters(blackList, emptyWhiteList), urls.partition { url =>
				!url.contains("assets")
			})
		}

		"filter blacklist then whitelist when both are specified on blackfirst mode" in {

			isRequestAccepted(Filters(blackList, whiteList), urls.partition { url =>
				!url.contains("assets") && url.contains("excilys")
			})
		}

		"be able to deal with incorrect patterns" in {
			val w = WhiteList(List("http://foo\\.com.*", "},{"))
			(w.regexes must not beEmpty) and (w.accept("http://foo.com/bar.html") must beTrue)
		}
	}
}

{'fraction_non_alphanumeric': 0.14391325776244454, 'fraction_numerical': 0.0009857072449482504, 'mean_word_length': 4.278283485045514, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '4264802', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1308, 'n_words': 299}