<commit_before>package com.socrata.tileserver
package services

import scala.util.control.NoStackTrace

import com.rojoma.json.v3.ast.JString
import org.mockito.Mockito.{verify, when}
import org.scalatest.mock.MockitoSugar
import org.scalatest.prop.PropertyChecks
import org.scalatest.{FunSuite, MustMatchers}
import org.slf4j.Logger

import com.socrata.http.server.HttpRequest

class ImageQueryServiceTest
    extends FunSuite
    with MustMatchers
    with PropertyChecks
    with MockitoSugar {
  implicit val logger: Logger = mock[Logger]

  def jStr(s: String): String = JString(s).toString

  ignore("Bad request must include message and cause") {
    forAll { (message: String, causeMessage: String) =>
      val outputStream = new util.ByteArrayServletOutputStream
      val resp = outputStream.responseFor
      val cause = new NoStackTrace {
        override def getMessage = causeMessage
      }

      ImageQueryService.badRequest(message, cause).apply(resp)

      verify(resp).setStatus(400)
      verify(resp).setContentType("application/json; charset=UTF-8")

      outputStream.getLowStr must include ("message")
      outputStream.getString must include (jStr(message))
      outputStream.getLowStr must include ("cause")
      outputStream.getString must include (jStr(causeMessage))
    }
  }

  ignore("Bad request must include message and info") {
    forAll { (message: String, info: String) =>
      val outputStream = new util.ByteArrayServletOutputStream
      val resp = outputStream.responseFor

      ImageQueryService.badRequest(message, info).apply(resp)

      verify(resp).setStatus(400)
      verify(resp).setContentType("application/json; charset=UTF-8")

      outputStream.getLowStr must include ("message")
      outputStream.getString must include (jStr(message))
      outputStream.getLowStr must include ("info")
      outputStream.getString must include (jStr(info))
    }
  }
}<commit_msg>Escape unicode strings in tests<commit_after>package com.socrata.tileserver
package services

import scala.util.control.NoStackTrace

import com.rojoma.json.v3.ast.JString
import org.mockito.Mockito.{verify, when}
import org.scalatest.mock.MockitoSugar
import org.scalatest.prop.PropertyChecks
import org.scalatest.{FunSuite, MustMatchers}
import org.slf4j.Logger

import com.socrata.http.server.HttpRequest

class ImageQueryServiceTest
    extends FunSuite
    with MustMatchers
    with PropertyChecks
    with MockitoSugar {
  implicit val logger: Logger = mock[Logger]

  def jStr(s: String): String = JString(s).toString

  def escape(s: String): String = s.toCharArray map { _.toInt } mkString ","

  test("Bad request must include message and cause") {
    forAll { (message: String, causeMessage: String) =>
      val outputStream = new util.ByteArrayServletOutputStream
      val resp = outputStream.responseFor
      val cause = new NoStackTrace {
        override def getMessage = causeMessage
      }

      ImageQueryService.badRequest(message, cause).apply(resp)

      verify(resp).setStatus(400)
      verify(resp).setContentType("application/json; charset=UTF-8")

      outputStream.getLowStr must include ("message")
      escape(outputStream.getString) must include (escape(jStr(message)))
      outputStream.getLowStr must include ("cause")
      escape(outputStream.getString) must include (escape(jStr(causeMessage)))
    }
  }

  test("Bad request must include message and info") {
    forAll { (message: String, info: String) =>
      val outputStream = new util.ByteArrayServletOutputStream
      val resp = outputStream.responseFor

      ImageQueryService.badRequest(message, info).apply(resp)

      verify(resp).setStatus(400)
      verify(resp).setContentType("application/json; charset=UTF-8")

      outputStream.getLowStr must include ("message")
      escape(outputStream.getString) must include (escape(jStr(message)))
      outputStream.getLowStr must include ("info")
      escape(outputStream.getString) must include (escape(jStr(info)))
    }
  }
}
{'fraction_non_alphanumeric': 0.0955223880597015, 'fraction_numerical': 0.004975124378109453, 'mean_word_length': 4.038847117794486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3111916', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1131, 'n_words': 272}