/**
Open Bank Project - API
Copyright (C) 2011-2016, TESOBE Ltd

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Email: contact@tesobe.com
TESOBE Ltd
Osloerstrasse 16/17
Berlin 13359, Germany

  This product includes software developed at
  TESOBE (http://www.tesobe.com/)
  by
  Simon Redfern : simon AT tesobe DOT com
  Stefan Bethge : stefan AT tesobe DOT com
  Everett Sochowski : everett AT tesobe DOT com
  Ayoub Benali: ayoub AT tesobe DOT com

 */

package code.api

import code.TestServer
import dispatch._
import net.liftweb.common._
import net.liftweb.json.{DefaultFormats, ShortTypeHints}
import org.scalatest._
import code.util.Helper.MdcLoggable

trait ServerSetup extends FeatureSpec with SendServerRequests
  with BeforeAndAfterEach with GivenWhenThen
  with BeforeAndAfterAll
  with ShouldMatchers with MdcLoggable {

  var server = TestServer
  implicit val formats = DefaultFormats.withHints(ShortTypeHints(List()))
  val h = Http
  def baseRequest = host(server.host, server.port)

}

trait ServerSetupWithTestData extends ServerSetup with DefaultConnectorTestSetup {

  override def beforeEach() = {
    super.beforeEach()

    implicit val dateFormats = net.liftweb.json.DefaultFormats
    //create fake data for the tests

    //fake banks
    val banks = createBanks()
    //fake bank accounts
    val accounts = createAccounts(banks)
    //fake transactions
    createTransactions(accounts)
  }

  override def afterEach() = {
    super.afterEach()
    wipeTestData()
  }

}