From 1866a1bb12177f889823c1c0bf3014d2da3bc54d Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Sun, 19 Dec 2021 22:39:20 +0300 Subject: [PATCH] endwalker support * added sge and rpr * changed way to define savage gear * libraries update --- build.sbt | 2 +- libraries.sbt | 22 +++++++++---------- .../me/arcanis/ffxivbis/Application.scala | 20 ++++++++++++----- .../me/arcanis/ffxivbis/models/Job.scala | 13 ++++++----- .../me/arcanis/ffxivbis/models/Piece.scala | 20 +++++++---------- .../ffxivbis/service/bis/BisProvider.scala | 2 +- .../arcanis/ffxivbis/service/bis/XivApi.scala | 2 +- .../arcanis/ffxivbis/storage/Migration.scala | 7 +++--- .../scala/me/arcanis/ffxivbis/Fixtures.scala | 3 --- .../http/api/v1/BiSEndpointTest.scala | 9 ++++---- .../http/api/v1/LootEndpointTest.scala | 9 ++++---- .../http/api/v1/PartyEndpointTest.scala | 9 ++++---- .../http/api/v1/PlayerEndpointTest.scala | 9 ++++---- .../http/api/v1/UserEndpointTest.scala | 9 ++++---- .../me/arcanis/ffxivbis/models/BiSTest.scala | 2 +- .../arcanis/ffxivbis/models/PieceTest.scala | 1 - .../service/DatabaseBiSHandlerTest.scala | 9 ++++---- .../service/DatabaseLootHandlerTest.scala | 9 ++++---- .../service/DatabasePartyHandlerTest.scala | 9 ++++---- .../service/DatabaseUserHandlerTest.scala | 9 ++++---- .../ffxivbis/service/LootSelectorTest.scala | 1 + 21 files changed, 95 insertions(+), 81 deletions(-) diff --git a/build.sbt b/build.sbt index eabf29a..635cf64 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ name := "ffxivbis" -scalaVersion := "2.13.1" +scalaVersion := "2.13.6" scalacOptions ++= Seq("-deprecation", "-feature") diff --git a/libraries.sbt b/libraries.sbt index 7bd6a13..3499008 100644 --- a/libraries.sbt +++ b/libraries.sbt @@ -1,15 +1,15 @@ -val AkkaVersion = "2.6.10" -val AkkaHttpVersion = "10.2.1" +val AkkaVersion = "2.6.17" +val AkkaHttpVersion = "10.2.7" val SlickVersion = "3.3.3" -libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3" -libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.9.2" +libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.9" +libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.9.4" libraryDependencies += "com.typesafe.akka" %% "akka-http" % AkkaHttpVersion libraryDependencies += "com.typesafe.akka" %% "akka-http-spray-json" % AkkaHttpVersion libraryDependencies += "com.typesafe.akka" %% "akka-actor-typed" % AkkaVersion libraryDependencies += "com.typesafe.akka" %% "akka-stream" % AkkaVersion -libraryDependencies += "com.github.swagger-akka-http" %% "swagger-akka-http" % "2.3.0" +libraryDependencies += "com.github.swagger-akka-http" %% "swagger-akka-http" % "2.6.0" libraryDependencies += "javax.ws.rs" % "javax.ws.rs-api" % "2.1.1" libraryDependencies += "io.spray" %% "spray-json" % "1.3.6" @@ -17,16 +17,16 @@ libraryDependencies += "com.lihaoyi" %% "scalatags" % "0.9.2" libraryDependencies += "com.typesafe.slick" %% "slick" % SlickVersion libraryDependencies += "com.typesafe.slick" %% "slick-hikaricp" % SlickVersion -libraryDependencies += "org.flywaydb" % "flyway-core" % "6.0.6" -libraryDependencies += "org.xerial" % "sqlite-jdbc" % "3.32.3.2" -libraryDependencies += "org.postgresql" % "postgresql" % "42.2.18" +libraryDependencies += "org.flywaydb" % "flyway-core" % "8.2.2" +libraryDependencies += "org.xerial" % "sqlite-jdbc" % "3.36.0.3" +libraryDependencies += "org.postgresql" % "postgresql" % "42.3.1" -libraryDependencies += "org.mindrot" % "jbcrypt" % "0.3m" +libraryDependencies += "org.mindrot" % "jbcrypt" % "0.4" // testing -libraryDependencies += "org.scalactic" %% "scalactic" % "3.1.4" % "test" -libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.4" % "test" +libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.10" % "test" +libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test" libraryDependencies += "com.typesafe.akka" %% "akka-actor-testkit-typed" % AkkaVersion % "test" libraryDependencies += "com.typesafe.akka" %% "akka-stream-testkit" % AkkaVersion % "test" diff --git a/src/main/scala/me/arcanis/ffxivbis/Application.scala b/src/main/scala/me/arcanis/ffxivbis/Application.scala index 3cd35d1..1f893d4 100644 --- a/src/main/scala/me/arcanis/ffxivbis/Application.scala +++ b/src/main/scala/me/arcanis/ffxivbis/Application.scala @@ -11,6 +11,7 @@ package me.arcanis.ffxivbis import akka.actor.typed.{Behavior, PostStop, Signal} import akka.actor.typed.scaladsl.{AbstractBehavior, ActorContext, Behaviors} import akka.http.scaladsl.Http +import akka.http.scaladsl.server.Route import akka.stream.Materializer import com.typesafe.scalalogging.StrictLogging import me.arcanis.ffxivbis.http.RootEndpoint @@ -19,6 +20,7 @@ import me.arcanis.ffxivbis.service.{Database, PartyService} import me.arcanis.ffxivbis.storage.Migration import scala.concurrent.ExecutionContext +import scala.util.{Failure, Success} class Application(context: ActorContext[Nothing]) extends AbstractBehavior[Nothing](context) with StrictLogging { @@ -42,14 +44,20 @@ class Application(context: ActorContext[Nothing]) implicit val executionContext: ExecutionContext = context.system.executionContext implicit val materializer: Materializer = Materializer(context) - Migration(config) + Migration(config) match { + case Success(_) => + val bisProvider = context.spawn(BisProvider(), "bis-provider") + val storage = context.spawn(Database(), "storage") + val party = context.spawn(PartyService(storage), "party") + val http = new RootEndpoint(context.system, party, bisProvider) - val bisProvider = context.spawn(BisProvider(), "bis-provider") - val storage = context.spawn(Database(), "storage") - val party = context.spawn(PartyService(storage), "party") - val http = new RootEndpoint(context.system, party, bisProvider) + val flow = Route.toFlow(http.route)(context.system) + Http(context.system).newServerAt(host, port).bindFlow(flow) - Http()(context.system).newServerAt(host, port).bindFlow(http.route) + case Failure(exception) => + logger.error("exception during migration", exception) + context.system.terminate() + } } } diff --git a/src/main/scala/me/arcanis/ffxivbis/models/Job.scala b/src/main/scala/me/arcanis/ffxivbis/models/Job.scala index f73f392..2afb6fc 100644 --- a/src/main/scala/me/arcanis/ffxivbis/models/Job.scala +++ b/src/main/scala/me/arcanis/ffxivbis/models/Job.scala @@ -62,6 +62,10 @@ object Job { val leftSide: LeftSide = BodyMnks val rightSide: RightSide = AccessoriesStr } + trait Drgs extends Job { + val leftSide: LeftSide = BodyDrgs + val rightSide: RightSide = AccessoriesStr + } trait Tanks extends Job { val leftSide: LeftSide = BodyTanks val rightSide: RightSide = AccessoriesVit @@ -79,12 +83,11 @@ object Job { case object WHM extends Healers case object SCH extends Healers case object AST extends Healers + case object SGE extends Healers case object MNK extends Mnks - case object DRG extends Job { - val leftSide: LeftSide = BodyDrgs - val rightSide: RightSide = AccessoriesStr - } + case object DRG extends Drgs + case object RPR extends Drgs case object NIN extends Job { val leftSide: LeftSide = BodyNins val rightSide: RightSide = AccessoriesDex @@ -100,7 +103,7 @@ object Job { case object RDM extends Casters lazy val available: Seq[Job] = - Seq(PLD, WAR, DRK, GNB, WHM, SCH, AST, MNK, DRG, NIN, SAM, BRD, MCH, DNC, BLM, SMN, RDM) + Seq(PLD, WAR, DRK, GNB, WHM, SCH, AST, SGE, MNK, DRG, RPR, NIN, SAM, BRD, MCH, DNC, BLM, SMN, RDM) lazy val availableWithAnyJob: Seq[Job] = available.prepended(AnyJob) def withName(job: String): Job.Job = diff --git a/src/main/scala/me/arcanis/ffxivbis/models/Piece.scala b/src/main/scala/me/arcanis/ffxivbis/models/Piece.scala index c50edb8..d975439 100644 --- a/src/main/scala/me/arcanis/ffxivbis/models/Piece.scala +++ b/src/main/scala/me/arcanis/ffxivbis/models/Piece.scala @@ -16,12 +16,13 @@ sealed trait Piece extends Equals { def withJob(other: Job.Job): Piece - def upgrade: Option[PieceUpgrade] = this match { - case _ if pieceType != PieceType.Tome => None - case _: Waist => Some(AccessoryUpgrade) - case _: PieceAccessory => Some(AccessoryUpgrade) - case _: PieceBody => Some(BodyUpgrade) - case _: PieceWeapon => Some(WeaponUpgrade) + def upgrade: Option[PieceUpgrade] = { + val isTome = pieceType == PieceType.Tome + Some(this).collect { + case _: PieceAccessory if isTome => AccessoryUpgrade + case _: PieceBody if isTome => BodyUpgrade + case _: PieceWeapon if isTome => WeaponUpgrade + } } // used for ring comparison @@ -54,10 +55,6 @@ case class Hands(override val pieceType: PieceType.PieceType, override val job: val piece: String = "hands" def withJob(other: Job.Job): Piece = copy(job = other) } -case class Waist(override val pieceType: PieceType.PieceType, override val job: Job.Job) extends PieceBody { - val piece: String = "waist" - def withJob(other: Job.Job): Piece = copy(job = other) -} case class Legs(override val pieceType: PieceType.PieceType, override val job: Job.Job) extends PieceBody { val piece: String = "legs" def withJob(other: Job.Job): Piece = copy(job = other) @@ -111,7 +108,6 @@ object Piece { case "head" => Head(pieceType, job) case "body" => Body(pieceType, job) case "hands" => Hands(pieceType, job) - case "waist" => Waist(pieceType, job) case "legs" => Legs(pieceType, job) case "feet" => Feet(pieceType, job) case "ears" => Ears(pieceType, job) @@ -125,7 +121,7 @@ object Piece { } lazy val available: Seq[String] = Seq("weapon", - "head", "body", "hands", "waist", "legs", "feet", + "head", "body", "hands", "legs", "feet", "ears", "neck", "wrist", "left ring", "right ring", "accessory upgrade", "body upgrade", "weapon upgrade") } diff --git a/src/main/scala/me/arcanis/ffxivbis/service/bis/BisProvider.scala b/src/main/scala/me/arcanis/ffxivbis/service/bis/BisProvider.scala index 0a0fdaf..eb3bb94 100644 --- a/src/main/scala/me/arcanis/ffxivbis/service/bis/BisProvider.scala +++ b/src/main/scala/me/arcanis/ffxivbis/service/bis/BisProvider.scala @@ -77,7 +77,7 @@ object BisProvider { case "chest" => Some("body") case "ringLeft" | "fingerL" => Some("left ring") case "ringRight" | "fingerR" => Some("right ring") - case "weapon" | "head" | "body" | "hands" | "waist" | "legs" | "feet" | "ears" | "neck" | "wrist" | "wrists" => Some(key) + case "weapon" | "head" | "body" | "hands" | "legs" | "feet" | "ears" | "neck" | "wrist" | "wrists" => Some(key) case _ => None } } diff --git a/src/main/scala/me/arcanis/ffxivbis/service/bis/XivApi.scala b/src/main/scala/me/arcanis/ffxivbis/service/bis/XivApi.scala index ce17342..464a650 100644 --- a/src/main/scala/me/arcanis/ffxivbis/service/bis/XivApi.scala +++ b/src/main/scala/me/arcanis/ffxivbis/service/bis/XivApi.scala @@ -101,7 +101,7 @@ object XivApi { .getOrElse(throw new Exception(s"${shopMap(shopId).fields(s"ItemCost$index")}, $index")) .getFields("IsUnique", "StackSize") match { case Seq(JsNumber(isUnique), JsNumber(stackSize)) => - if (isUnique == 1 || stackSize.toLong == 2000) PieceType.Tome // either upgraded gear or tomes found + if (isUnique == 1 || stackSize.toLong != 999) PieceType.Tome // either upgraded gear or tomes found else PieceType.Savage case other => throw deserializationError(s"Could not parse $other") } diff --git a/src/main/scala/me/arcanis/ffxivbis/storage/Migration.scala b/src/main/scala/me/arcanis/ffxivbis/storage/Migration.scala index eb8a9c3..330cfda 100644 --- a/src/main/scala/me/arcanis/ffxivbis/storage/Migration.scala +++ b/src/main/scala/me/arcanis/ffxivbis/storage/Migration.scala @@ -13,10 +13,11 @@ import org.flywaydb.core.Flyway import org.flywaydb.core.api.configuration.ClassicConfiguration import scala.concurrent.Future +import scala.util.Try class Migration(config: Config) { - def performMigration(): Future[Int] = { + def performMigration(): Try[Boolean] = { val section = DatabaseProfile.getSection(config) val url = section.getString("db.url") @@ -33,11 +34,11 @@ class Migration(config: Config) { flywayConfiguration.setDataSource(url, username, password) val flyway = new Flyway(flywayConfiguration) - Future.successful(flyway.migrate()) + Try(flyway.migrate().success) } } object Migration { - def apply(config: Config): Future[Int] = new Migration(config).performMigration() + def apply(config: Config): Try[Boolean] = new Migration(config).performMigration() } diff --git a/src/test/scala/me/arcanis/ffxivbis/Fixtures.scala b/src/test/scala/me/arcanis/ffxivbis/Fixtures.scala index f238227..c8dbe31 100644 --- a/src/test/scala/me/arcanis/ffxivbis/Fixtures.scala +++ b/src/test/scala/me/arcanis/ffxivbis/Fixtures.scala @@ -9,7 +9,6 @@ object Fixtures { Head(pieceType = PieceType.Savage, Job.DNC), Body(pieceType = PieceType.Savage, Job.DNC), Hands(pieceType = PieceType.Tome, Job.DNC), - Waist(pieceType = PieceType.Tome, Job.DNC), Legs(pieceType = PieceType.Tome, Job.DNC), Feet(pieceType = PieceType.Savage, Job.DNC), Ears(pieceType = PieceType.Savage, Job.DNC), @@ -25,7 +24,6 @@ object Fixtures { Head(pieceType = PieceType.Tome, Job.DNC), Body(pieceType = PieceType.Savage, Job.DNC), Hands(pieceType = PieceType.Tome, Job.DNC), - Waist(pieceType = PieceType.Tome, Job.DNC), Legs(pieceType = PieceType.Savage, Job.DNC), Feet(pieceType = PieceType.Tome, Job.DNC), Ears(pieceType = PieceType.Savage, Job.DNC), @@ -45,7 +43,6 @@ object Fixtures { lazy val lootBody: Piece = Body(pieceType = PieceType.Savage, Job.AnyJob) lazy val lootBodyCrafted: Piece = Body(pieceType = PieceType.Crafted, Job.AnyJob) lazy val lootHands: Piece = Hands(pieceType = PieceType.Tome, Job.AnyJob) - lazy val lootWaist: Piece = Waist(pieceType = PieceType.Tome, Job.AnyJob) lazy val lootLegs: Piece = Legs(pieceType = PieceType.Savage, Job.AnyJob) lazy val lootEars: Piece = Ears(pieceType = PieceType.Savage, Job.AnyJob) lazy val lootRing: Piece = Ring(pieceType = PieceType.Tome, Job.AnyJob) diff --git a/src/test/scala/me/arcanis/ffxivbis/http/api/v1/BiSEndpointTest.scala b/src/test/scala/me/arcanis/ffxivbis/http/api/v1/BiSEndpointTest.scala index 05b2960..0af7e1e 100644 --- a/src/test/scala/me/arcanis/ffxivbis/http/api/v1/BiSEndpointTest.scala +++ b/src/test/scala/me/arcanis/ffxivbis/http/api/v1/BiSEndpointTest.scala @@ -39,17 +39,18 @@ class BiSEndpointTest extends AnyWordSpecLike with Matchers with ScalatestRouteT private val party = testKit.spawn(PartyService(storage)) private val route = new BiSEndpoint(party, provider)(askTimeout, testKit.scheduler).route - override def beforeAll: Unit = { - Await.result(Migration(testConfig), askTimeout) + override def beforeAll(): Unit = { + super.beforeAll() + Migration(testConfig) Await.result(storage.ask(AddUser(Fixtures.userAdmin, isHashedPassword = true, _))(askTimeout, testKit.scheduler), askTimeout) Await.result(storage.ask(AddPlayer(Fixtures.playerEmpty, _))(askTimeout, testKit.scheduler), askTimeout) } - override def afterAll: Unit = { - super.afterAll() + override def afterAll(): Unit = { Settings.clearDatabase(testConfig) TestKit.shutdownActorSystem(system) testKit.shutdownTestKit() + super.afterAll() } private def compareBiSResponse(actual: PlayerResponse, expected: PlayerResponse): Unit = { diff --git a/src/test/scala/me/arcanis/ffxivbis/http/api/v1/LootEndpointTest.scala b/src/test/scala/me/arcanis/ffxivbis/http/api/v1/LootEndpointTest.scala index 891e82c..4cff35e 100644 --- a/src/test/scala/me/arcanis/ffxivbis/http/api/v1/LootEndpointTest.scala +++ b/src/test/scala/me/arcanis/ffxivbis/http/api/v1/LootEndpointTest.scala @@ -37,17 +37,18 @@ class LootEndpointTest extends AnyWordSpecLike with Matchers with ScalatestRoute private val party = testKit.spawn(PartyService(storage)) private val route = new LootEndpoint(party)(askTimeout, testKit.scheduler).route - override def beforeAll: Unit = { - Await.result(Migration(testConfig), askTimeout) + override def beforeAll(): Unit = { + super.beforeAll() + Migration(testConfig) Await.result(storage.ask(AddUser(Fixtures.userAdmin, isHashedPassword = true, _))(askTimeout, testKit.scheduler), askTimeout) Await.result(storage.ask(AddPlayer(Fixtures.playerEmpty, _))(askTimeout, testKit.scheduler), askTimeout) } - override def afterAll: Unit = { - super.afterAll() + override def afterAll(): Unit = { Settings.clearDatabase(testConfig) TestKit.shutdownActorSystem(system) testKit.shutdownTestKit() + super.afterAll() } "api v1 loot endpoint" must { diff --git a/src/test/scala/me/arcanis/ffxivbis/http/api/v1/PartyEndpointTest.scala b/src/test/scala/me/arcanis/ffxivbis/http/api/v1/PartyEndpointTest.scala index c08a11f..48d1d42 100644 --- a/src/test/scala/me/arcanis/ffxivbis/http/api/v1/PartyEndpointTest.scala +++ b/src/test/scala/me/arcanis/ffxivbis/http/api/v1/PartyEndpointTest.scala @@ -37,16 +37,17 @@ class PartyEndpointTest extends AnyWordSpecLike with Matchers with ScalatestRout private val party = testKit.spawn(PartyService(storage)) private val route = new PartyEndpoint(party, provider)(askTimeout, testKit.scheduler).route - override def beforeAll: Unit = { - Await.result(Migration(testConfig), askTimeout) + override def beforeAll(): Unit = { + super.beforeAll() + Migration(testConfig) Await.result(storage.ask(AddUser(Fixtures.userAdmin, isHashedPassword = true, _))(askTimeout, testKit.scheduler), askTimeout) } - override def afterAll: Unit = { - super.afterAll() + override def afterAll(): Unit = { Settings.clearDatabase(testConfig) TestKit.shutdownActorSystem(system) testKit.shutdownTestKit() + super.afterAll() } "api v1 party endpoint" must { diff --git a/src/test/scala/me/arcanis/ffxivbis/http/api/v1/PlayerEndpointTest.scala b/src/test/scala/me/arcanis/ffxivbis/http/api/v1/PlayerEndpointTest.scala index 5e998e9..aa9bd92 100644 --- a/src/test/scala/me/arcanis/ffxivbis/http/api/v1/PlayerEndpointTest.scala +++ b/src/test/scala/me/arcanis/ffxivbis/http/api/v1/PlayerEndpointTest.scala @@ -36,17 +36,18 @@ class PlayerEndpointTest extends AnyWordSpecLike with Matchers with ScalatestRou private val party = testKit.spawn(PartyService(storage)) private val route = new PlayerEndpoint(party, provider)(askTimeout, testKit.scheduler).route - override def beforeAll: Unit = { - Await.result(Migration(testConfig), askTimeout) + override def beforeAll(): Unit = { + super.beforeAll() + Migration(testConfig) Await.result(storage.ask(AddUser(Fixtures.userAdmin, isHashedPassword = true, _))(askTimeout, testKit.scheduler), askTimeout) Await.result(storage.ask(AddPlayer(Fixtures.playerEmpty, _))(askTimeout, testKit.scheduler), askTimeout) } - override def afterAll: Unit = { - super.afterAll() + override def afterAll(): Unit = { Settings.clearDatabase(testConfig) TestKit.shutdownActorSystem(system) testKit.shutdownTestKit() + super.afterAll() } "api v1 player endpoint" must { diff --git a/src/test/scala/me/arcanis/ffxivbis/http/api/v1/UserEndpointTest.scala b/src/test/scala/me/arcanis/ffxivbis/http/api/v1/UserEndpointTest.scala index fc0c1f9..005b4b2 100644 --- a/src/test/scala/me/arcanis/ffxivbis/http/api/v1/UserEndpointTest.scala +++ b/src/test/scala/me/arcanis/ffxivbis/http/api/v1/UserEndpointTest.scala @@ -33,15 +33,16 @@ class UserEndpointTest extends AnyWordSpecLike with Matchers with ScalatestRoute private val party = testKit.spawn(PartyService(storage)) private val route = new UserEndpoint(party)(askTimeout, testKit.scheduler).route - override def beforeAll: Unit = { - Await.result(Migration(testConfig), askTimeout) + override def beforeAll(): Unit = { + super.beforeAll() + Migration(testConfig) } - override def afterAll: Unit = { - super.afterAll() + override def afterAll(): Unit = { Settings.clearDatabase(testConfig) TestKit.shutdownActorSystem(system) testKit.shutdownTestKit() + super.afterAll() } "api v1 users endpoint" must { diff --git a/src/test/scala/me/arcanis/ffxivbis/models/BiSTest.scala b/src/test/scala/me/arcanis/ffxivbis/models/BiSTest.scala index 864bc90..3454010 100644 --- a/src/test/scala/me/arcanis/ffxivbis/models/BiSTest.scala +++ b/src/test/scala/me/arcanis/ffxivbis/models/BiSTest.scala @@ -46,7 +46,7 @@ class BiSTest extends AnyWordSpecLike with Matchers { } "return upgrade list" in { - Compare.mapEquals(Fixtures.bis.upgrades, Map[PieceUpgrade, Int](BodyUpgrade -> 2, AccessoryUpgrade -> 4)) shouldEqual true + Compare.mapEquals(Fixtures.bis.upgrades, Map[PieceUpgrade, Int](BodyUpgrade -> 2, AccessoryUpgrade -> 3)) shouldEqual true } } diff --git a/src/test/scala/me/arcanis/ffxivbis/models/PieceTest.scala b/src/test/scala/me/arcanis/ffxivbis/models/PieceTest.scala index 0cae8e2..d847bd9 100644 --- a/src/test/scala/me/arcanis/ffxivbis/models/PieceTest.scala +++ b/src/test/scala/me/arcanis/ffxivbis/models/PieceTest.scala @@ -12,7 +12,6 @@ class PieceTest extends AnyWordSpecLike with Matchers { Fixtures.lootWeapon.upgrade shouldEqual Some(WeaponUpgrade) Fixtures.lootBody.upgrade shouldEqual None Fixtures.lootHands.upgrade shouldEqual Some(BodyUpgrade) - Fixtures.lootWaist.upgrade shouldEqual Some(AccessoryUpgrade) Fixtures.lootLegs.upgrade shouldEqual None Fixtures.lootEars.upgrade shouldEqual None Fixtures.lootLeftRing.upgrade shouldEqual Some(AccessoryUpgrade) diff --git a/src/test/scala/me/arcanis/ffxivbis/service/DatabaseBiSHandlerTest.scala b/src/test/scala/me/arcanis/ffxivbis/service/DatabaseBiSHandlerTest.scala index cd7837b..c8360eb 100644 --- a/src/test/scala/me/arcanis/ffxivbis/service/DatabaseBiSHandlerTest.scala +++ b/src/test/scala/me/arcanis/ffxivbis/service/DatabaseBiSHandlerTest.scala @@ -19,14 +19,15 @@ class DatabaseBiSHandlerTest extends ScalaTestWithActorTestKit(Settings.withRand private val database = testKit.spawn(Database()) private val askTimeout: FiniteDuration = 60 seconds - override def beforeAll: Unit = { - Await.result(Migration(testKit.system.settings.config), askTimeout) + override def beforeAll(): Unit = { + super.beforeAll() + Migration(testKit.system.settings.config) Await.result(database.ask(AddPlayer(Fixtures.playerEmpty, _))(askTimeout, testKit.scheduler), askTimeout) } - override def afterAll: Unit = { - super.afterAll() + override def afterAll(): Unit = { Settings.clearDatabase(testKit.system.settings.config) + super.afterAll() } "database bis handler" must { diff --git a/src/test/scala/me/arcanis/ffxivbis/service/DatabaseLootHandlerTest.scala b/src/test/scala/me/arcanis/ffxivbis/service/DatabaseLootHandlerTest.scala index 38422e3..08f335d 100644 --- a/src/test/scala/me/arcanis/ffxivbis/service/DatabaseLootHandlerTest.scala +++ b/src/test/scala/me/arcanis/ffxivbis/service/DatabaseLootHandlerTest.scala @@ -19,14 +19,15 @@ class DatabaseLootHandlerTest extends ScalaTestWithActorTestKit(Settings.withRan private val database = testKit.spawn(Database()) private val askTimeout = 60 seconds - override def beforeAll: Unit = { - Await.result(Migration(testKit.system.settings.config), askTimeout) + override def beforeAll(): Unit = { + super.beforeAll() + Migration(testKit.system.settings.config) Await.result(database.ask(AddPlayer(Fixtures.playerEmpty, _))(askTimeout, testKit.scheduler), askTimeout) } - override def afterAll: Unit = { - super.afterAll() + override def afterAll(): Unit = { Settings.clearDatabase(testKit.system.settings.config) + super.afterAll() } "database loot handler actor" must { diff --git a/src/test/scala/me/arcanis/ffxivbis/service/DatabasePartyHandlerTest.scala b/src/test/scala/me/arcanis/ffxivbis/service/DatabasePartyHandlerTest.scala index daec91e..03a2614 100644 --- a/src/test/scala/me/arcanis/ffxivbis/service/DatabasePartyHandlerTest.scala +++ b/src/test/scala/me/arcanis/ffxivbis/service/DatabasePartyHandlerTest.scala @@ -18,13 +18,14 @@ class DatabasePartyHandlerTest extends ScalaTestWithActorTestKit(Settings.withRa private val database = testKit.spawn(Database()) private val askTimeout = 60 seconds - override def beforeAll: Unit = { - Await.result(Migration(testKit.system.settings.config), askTimeout) + override def beforeAll(): Unit = { + super.beforeAll() + Migration(testKit.system.settings.config) } - override def afterAll: Unit = { - super.afterAll() + override def afterAll(): Unit = { Settings.clearDatabase(testKit.system.settings.config) + super.afterAll() } "database party handler actor" must { diff --git a/src/test/scala/me/arcanis/ffxivbis/service/DatabaseUserHandlerTest.scala b/src/test/scala/me/arcanis/ffxivbis/service/DatabaseUserHandlerTest.scala index 8a6a862..6e90561 100644 --- a/src/test/scala/me/arcanis/ffxivbis/service/DatabaseUserHandlerTest.scala +++ b/src/test/scala/me/arcanis/ffxivbis/service/DatabaseUserHandlerTest.scala @@ -18,13 +18,14 @@ class DatabaseUserHandlerTest extends ScalaTestWithActorTestKit(Settings.withRan private val database = testKit.spawn(Database()) private val askTimeout = 60 seconds - override def beforeAll: Unit = { - Await.result(Migration(testKit.system.settings.config), askTimeout) + override def beforeAll(): Unit = { + super.beforeAll() + Migration(testKit.system.settings.config) } - override def afterAll: Unit = { - super.afterAll() + override def afterAll(): Unit = { Settings.clearDatabase(testKit.system.settings.config) + super.afterAll() } "database user handler actor" must { diff --git a/src/test/scala/me/arcanis/ffxivbis/service/LootSelectorTest.scala b/src/test/scala/me/arcanis/ffxivbis/service/LootSelectorTest.scala index 3f34e6b..41e1aa1 100644 --- a/src/test/scala/me/arcanis/ffxivbis/service/LootSelectorTest.scala +++ b/src/test/scala/me/arcanis/ffxivbis/service/LootSelectorTest.scala @@ -24,6 +24,7 @@ class LootSelectorTest extends AnyWordSpecLike with Matchers with BeforeAndAfter private val timeout: FiniteDuration = 60 seconds override def beforeAll(): Unit = { + super.beforeAll() val testKit = ActorTestKit(Settings.withRandomDatabase) val provider = testKit.spawn(BisProvider())