<commit_before>package com.softwaremill.bootzooka.test

import com.softwaremill.bootzooka.dao.sql.SqlDatabase
import org.scalatest._

import scala.slick.jdbc.StaticQuery

trait FlatSpecWithSql extends FlatSpec with BeforeAndAfterAll with Matchers {

  private val connectionString = "jdbc:h2:mem:bootzooka_test" + this.getClass.getSimpleName + ";DB_CLOSE_DELAY=-1"

  val sqlDatabase = SqlDatabase.createEmbedded(connectionString)

  override protected def beforeAll() {
    super.beforeAll()
    createAll()
  }

  def clearData() {
    dropAll()
    createAll()
  }

  override protected def afterAll() {
    super.afterAll()
    dropAll()
    sqlDatabase.close()
  }

  private def dropAll() {
    sqlDatabase.db.withSession { implicit session =>
      StaticQuery.updateNA("DROP ALL OBJECTS").execute
    }
  }

  private def createAll() {
    sqlDatabase.updateSchema()
  }
}<commit_msg>Use new Slick API for database test utils<commit_after>package com.softwaremill.bootzooka.test

import com.softwaremill.bootzooka.dao.sql.SqlDatabase
import org.scalatest._
import org.scalatest.concurrent.ScalaFutures

import scala.slick.jdbc.StaticQuery

trait FlatSpecWithSql extends FlatSpec with BeforeAndAfterAll with Matchers with ScalaFutures {

  private val connectionString = "jdbc:h2:mem:bootzooka_test" + this.getClass.getSimpleName + ";DB_CLOSE_DELAY=-1"

  val sqlDatabase = SqlDatabase.createEmbedded(connectionString)

  override protected def beforeAll() {
    super.beforeAll()
    createAll()
  }

  def clearData() {
    dropAll()
    createAll()
  }

  override protected def afterAll() {
    super.afterAll()
    dropAll()
    sqlDatabase.close()
  }

  private def dropAll() {
    import sqlDatabase.driver.api._
    sqlDatabase.db.run(sqlu"DROP ALL OBJECTS").futureValue
  }

  private def createAll() {
    sqlDatabase.updateSchema()
  }
}
{'fraction_non_alphanumeric': 0.09644396551724138, 'fraction_numerical': 0.0021551724137931034, 'mean_word_length': 4.115702479338843, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6206802', 'n_tokens_mistral': 610, 'n_tokens_neox': 586, 'n_words': 120}