diff --git a/build.sbt b/build.sbt index 71fae963..90f060ec 100644 --- a/build.sbt +++ b/build.sbt @@ -77,6 +77,7 @@ def baseProject(module: String, majorMinorVersion: String) = Project(s"$module-p "-deprecation", "-Xfatal-warnings" ), + libraryDependencies += scalaTest, publishTo := sonatypePublishToBundle.value, sonatypeReleaseSettings ) @@ -86,7 +87,6 @@ def faciaJson_playJsonVersion(majorMinorVersion: String) = baseProject("facia-js libraryDependencies ++= Seq( awsSdk, commonsIo, - specs2, "com.typesafe.play" %% "play-json" % exactPlayJsonVersions(majorMinorVersion), "org.scala-lang.modules" %% "scala-collection-compat" % "2.11.0", scalaLogging @@ -99,7 +99,7 @@ def fapiClient_playJsonVersion(majorMinorVersion: String) = baseProject("fapi-c contentApi, contentApiDefault, commercialShared, - scalaTest, + scalaTestMockito, mockito ) ) diff --git a/facia-json/src/test/scala/com/gu/facia/client/ApiClientSpec.scala b/facia-json/src/test/scala/com/gu/facia/client/ApiClientSpec.scala index e6ae1ff5..91f499a2 100644 --- a/facia-json/src/test/scala/com/gu/facia/client/ApiClientSpec.scala +++ b/facia-json/src/test/scala/com/gu/facia/client/ApiClientSpec.scala @@ -1,33 +1,33 @@ package com.gu.facia.client -import org.specs2.mutable.Specification -import scala.concurrent.Future -import scala.concurrent.Await import com.gu.facia.client.lib.ResourcesHelper -import scala.concurrent.duration.Duration +import org.scalatest.OptionValues +import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + import scala.concurrent.ExecutionContext.Implicits.global +import scala.concurrent.Future -class ApiClientSpec extends Specification { +class ApiClientSpec extends AnyFlatSpec with Matchers with OptionValues with ScalaFutures with IntegrationPatience { object FakeS3Client extends S3Client with ResourcesHelper { override def get(bucket: String, path: String): Future[FaciaResult] = Future { slurpOrDie(path) } } - val client = ApiClient("not used", "DEV", FakeS3Client) + val client: ApiClient = ApiClient("not used", "DEV", FakeS3Client) - "ApiClient" should { - "fetch the config" in { - /** Nasty. PlaySpecification gives you a way of avoiding using Await ... TODO, maybe import that? */ - val config = Await.result(client.config, Duration.Inf) + "ApiClient" should "fetch the config" in { + val config = client.config.futureValue - (config.collections.size mustEqual 334) and (config.fronts.size mustEqual 79) - } + config.collections should have size 334 + config.fronts should have size 79 + } - "fetch a collection" in { - val collection = Await.result(client.collection("2409-31b3-83df0-de5a"), Duration.Inf) + it should "fetch a collection" in { + val collectionOpt = client.collection("2409-31b3-83df0-de5a").futureValue - collection must beSome.which(_.live must haveLength(8)) - } + collectionOpt.value.live should have size 8 } } \ No newline at end of file diff --git a/facia-json/src/test/scala/com/gu/facia/client/models/CollectionSpec.scala b/facia-json/src/test/scala/com/gu/facia/client/models/CollectionSpec.scala index dfd0aa77..e0ff1933 100644 --- a/facia-json/src/test/scala/com/gu/facia/client/models/CollectionSpec.scala +++ b/facia-json/src/test/scala/com/gu/facia/client/models/CollectionSpec.scala @@ -1,11 +1,13 @@ package com.gu.facia.client.models -import org.specs2.mutable.Specification -import play.api.libs.json.{JsString, JsSuccess, JsError, Json} import com.gu.facia.client.lib.ResourcesHelper -import org.joda.time.{DateTimeZone, DateTime} +import org.joda.time.{DateTime, DateTimeZone} +import org.scalatest.OptionValues +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers +import play.api.libs.json.{JsError, JsString, JsSuccess, Json} -class CollectionSpec extends Specification with ResourcesHelper { +class CollectionSpec extends AnyFlatSpec with Matchers with OptionValues with ResourcesHelper { def getCollectionFixture(path: String) = Json.fromJson[CollectionJson]( Json.parse(slurpOrDie(path).get) ) match { @@ -14,105 +16,95 @@ class CollectionSpec extends Specification with ResourcesHelper { throw new RuntimeException("ARGH") } - "Collection" should { - "deserialize" in { - val collection = getCollectionFixture("DEV/frontsapi/collection/2409-31b3-83df0-de5a/collection.json") - - collection.live must haveLength(8) - - collection.live.find(_.id == "football/quiz/2014/jun/11/world-cup-2014-the-ultimate-world-cup-trivia-quiz") must - beSome.which({ front => - (front.frontPublicationDate mustEqual 1402500092818L) and (front.meta mustEqual Some(TrailMetaData.withDefaults( - ("headline", JsString("The ultimate World Cup trivia quiz")), - ("group", JsString("0")) - ))) - }) - - collection.lastUpdated mustEqual new DateTime(2014, 6, 12, 8, 30, 20, 67, DateTimeZone.UTC) - - collection.updatedBy mustEqual "Katherine Le Ruez" - - collection.updatedEmail mustEqual "katherine.leruez@guardian.co.uk" - } - - "deserialize content with image src widths and heights attached" in { - val collection = getCollectionFixture("PROD/frontsapi/collection/uk-alpha/news/regular-stories/collection2.json") - - collection.live.lift(1) must beSome.which({ item => - item.safeMeta.imageSrcWidth mustEqual Some("940") and (item.safeMeta.imageSrcHeight mustEqual Some("564")) - }) - } - - "deserialize content with slideshows, where captions are optional" in { - val collection = getCollectionFixture("PROD/frontsapi/collection/uk-alpha/news/regular-stories/collection-with-captions.json") - - collection.live.lift(0) must beSome.which({ item => - item.safeMeta.slideshow mustEqual Some( - List( - SlideshowAsset( - "http://static.guim.co.uk/sys-images/Guardian/Pix/pictures/2014/8/4/1407146294410/PrinceWilliamCatherineDuche.jpg", - "940", - "720" - ), - SlideshowAsset( - "http://static.guim.co.uk/sys-images/Guardian/Pix/pictures/2014/8/4/1407140556976/AustraliansingerKylieMinogu.jpg", - "940", - "720", - Some("Kylie Minogue") - ) - ) - ) - }) - } - - "deserialize content without metadata" in { - val collection = getCollectionFixture("PROD/frontsapi/collection/754c-8e8c-fad9-a927/collection.json") - - collection.live.lift(2) must beSome.which({ item => - item.meta mustEqual None - }) - } - - "deserialize content with supporting items" in { - val collection = getCollectionFixture("PROD/frontsapi/collection/uk-alpha/news/regular-stories/collection.json") - - collection.live.headOption must beSome.which({ item => - item.safeMeta.supporting must beSome.which({ supportingContent => - supportingContent must haveLength(3) - - supportingContent.lift(1) must beSome.which({ item => - item.id mustEqual "internal-code/content/442568601" - item.publishedBy mustEqual Some("user1") - - item.meta must beSome.which({ meta => - meta.group mustEqual Some("2") - - meta.headline mustEqual Some("Special report: Scores killed in deadliest assault in Gaza so far") - }) - }) - }) - }) - - "be able to serialize and deserialize the same object" in { - val collectionJson = CollectionJson( - live = List(Trail("id-123", DateTime.now.getMillis, None, None)), - draft = None, - treats = None, - lastUpdated = DateTime.now(), - updatedBy = "A test", - updatedEmail = "a test email", - displayName = None, - href = None, - previously = None, - targetedTerritory = None + "Collection" should "deserialize" in { + val collection = getCollectionFixture("DEV/frontsapi/collection/2409-31b3-83df0-de5a/collection.json") + + collection.live should have size 8 + + val front = collection.live.find(_.id == "football/quiz/2014/jun/11/world-cup-2014-the-ultimate-world-cup-trivia-quiz").value + + front.frontPublicationDate shouldBe 1402500092818L + front.meta.value shouldBe TrailMetaData.withDefaults( + ("headline", JsString("The ultimate World Cup trivia quiz")), + ("group", JsString("0")) + ) + + collection.lastUpdated shouldBe new DateTime(2014, 6, 12, 8, 30, 20, 67, DateTimeZone.UTC) + + collection.updatedBy shouldBe "Katherine Le Ruez" + + collection.updatedEmail shouldBe "katherine.leruez@guardian.co.uk" + } + + it should "deserialize content with image src widths and heights attached" in { + val collection = getCollectionFixture("PROD/frontsapi/collection/uk-alpha/news/regular-stories/collection2.json") + + val itemMeta = collection.live.lift(1).value.safeMeta + itemMeta.imageSrcWidth.value shouldBe "940" + itemMeta.imageSrcHeight.value shouldBe "564" + } + + it should "deserialize content with slideshows, where captions are optional" in { + val collection = getCollectionFixture("PROD/frontsapi/collection/uk-alpha/news/regular-stories/collection-with-captions.json") + + val item = collection.live.lift(0).value + item.safeMeta.slideshow shouldBe Some( + List( + SlideshowAsset( + "http://static.guim.co.uk/sys-images/Guardian/Pix/pictures/2014/8/4/1407146294410/PrinceWilliamCatherineDuche.jpg", + "940", + "720" + ), + SlideshowAsset( + "http://static.guim.co.uk/sys-images/Guardian/Pix/pictures/2014/8/4/1407140556976/AustraliansingerKylieMinogu.jpg", + "940", + "720", + Some("Kylie Minogue") ) + ) + ) + } + + it should "deserialize content without metadata" in { + val collection = getCollectionFixture("PROD/frontsapi/collection/754c-8e8c-fad9-a927/collection.json") + + collection.live.lift(2).value.meta shouldBe None + } + + it should "deserialize content with supporting items" in { + val collection = getCollectionFixture("PROD/frontsapi/collection/uk-alpha/news/regular-stories/collection.json") + + val supportingContent = collection.live.headOption.value.safeMeta.supporting.value + supportingContent should have size 3 - val collectionJsonAsString = Json.stringify(Json.toJson(collectionJson)) - val newCollectionJson = Json.parse(collectionJsonAsString).as[CollectionJson] + val item = supportingContent.lift(1).value + item.id shouldBe "internal-code/content/442568601" + item.publishedBy shouldBe Some("user1") - newCollectionJson.lastUpdated should beEqualTo (collectionJson.lastUpdated) - newCollectionJson should beEqualTo (collectionJson) - } - } + val meta = item.meta.value + meta.group shouldBe Some("2") + + meta.headline shouldBe Some("Special report: Scores killed in deadliest assault in Gaza so far") + } + + it should "be able to serialize and deserialize the same object" in { + val collectionJson = CollectionJson( + live = List(Trail("id-123", DateTime.now.getMillis, None, None)), + draft = None, + treats = None, + lastUpdated = DateTime.now(), + updatedBy = "A test", + updatedEmail = "a test email", + displayName = None, + href = None, + previously = None, + targetedTerritory = None + ) + + val collectionJsonAsString = Json.stringify(Json.toJson(collectionJson)) + val newCollectionJson = Json.parse(collectionJsonAsString).as[CollectionJson] + + newCollectionJson.lastUpdated shouldBe collectionJson.lastUpdated + newCollectionJson shouldBe collectionJson } } diff --git a/facia-json/src/test/scala/com/gu/facia/client/models/ConfigSpec.scala b/facia-json/src/test/scala/com/gu/facia/client/models/ConfigSpec.scala index cc5f0b7b..673b0055 100644 --- a/facia-json/src/test/scala/com/gu/facia/client/models/ConfigSpec.scala +++ b/facia-json/src/test/scala/com/gu/facia/client/models/ConfigSpec.scala @@ -1,39 +1,39 @@ package com.gu.facia.client.models import com.gu.facia.client.lib.ResourcesHelper -import org.specs2.mutable.Specification +import org.scalatest.OptionValues import play.api.libs.json.Json +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers -class ConfigSpec extends Specification with ResourcesHelper { - "Config" should { - "deserialize" in { +class ConfigSpec extends AnyFlatSpec with Matchers with OptionValues with ResourcesHelper { + "Config" should "deserialize" in { val config = Json.fromJson[ConfigJson](Json.parse(slurpOrDie("DEV/frontsapi/config/config.json").get)).get - config.collections.get("uk/commentisfree/most-viewed/regular-stories") must beSome.which({ collection => - (collection.displayName must beSome.which(_ == "Most popular")) and - (collection.`type` must beSome.which(_ == "news/most-popular")) and - (collection.uneditable must beSome.which(identity)) and - (collection.backfill must beSome.which({ backfill => - (backfill.`type` == "capi") and - (backfill.query == "uk/commentisfree?show-most-viewed=true&show-editors-picks=false&hide-recent-content=true") - })) - }) + val collection = config.collections.get("uk/commentisfree/most-viewed/regular-stories").value - config.fronts.get("lifeandstyle/home-and-garden") must beSome.which({ front => - (front.collections must haveLength(2)) and - (front.title must beSome.which(_ == "Home, interiors and gardening news, comment and advice")) and - (front.description must beSome.which(_ == "Latest news, comment and advice on homes, interior design, " + - "decorating and gardening from the Guardian, the world's leading liberal voice")) - }) + collection.displayName.value shouldBe "Most popular" + collection.`type`.value shouldBe "news/most-popular" + collection.uneditable.value shouldBe true + val backfill = collection.backfill.value + backfill.`type` shouldBe "capi" + backfill.query shouldBe "uk/commentisfree?show-most-viewed=true&show-editors-picks=false&hide-recent-content=true" + + val front = config.fronts.get("lifeandstyle/home-and-garden").value + + front.collections should have length 2 + front.title.value shouldBe "Home, interiors and gardening news, comment and advice" + front.description.value shouldBe "Latest news, comment and advice on homes, interior design, " + + "decorating and gardening from the Guardian, the world's leading liberal voice" } - "deserialize territories" in { + + it should "deserialize territories" in { val config = Json.fromJson[ConfigJson](Json.parse(slurpOrDie("DEV/frontsapi/config/config.json").get)).get - config.collections.get("au/sport/golf/regular-stories") must beSome.which({ collection => - collection.targetedTerritory.get mustEqual(EU27Territory) - }) + config.collections.get("au/sport/golf/regular-stories").value.targetedTerritory.value shouldBe EU27Territory } - "deserialize unsupported territories as unknown" in { + + it should "deserialize unsupported territories as unknown" in { val configJson = """{ | "displayName" : "Golf", @@ -46,19 +46,15 @@ class ConfigSpec extends Specification with ResourcesHelper { | "targetedTerritory": "Made-Up-Territory" | }""".stripMargin val parsed = Json.fromJson[CollectionConfigJson](Json.parse(configJson)) - parsed.asOpt must beSome.which({ config => - config.targetedTerritory must beSome(UnknownTerritory: TargetedTerritory) - }) + parsed.asOpt.value.targetedTerritory.value shouldBe UnknownTerritory } - "serialize territories" in { - val config = Json.fromJson[ConfigJson](Json.parse(slurpOrDie("DEV/frontsapi/config/config.json").get)).get + it should "serialize territories" in { + val config = Json.fromJson[ConfigJson](Json.parse(slurpOrDie("DEV/frontsapi/config/config.json").get)).get - config.collections.get("uk/commentisfree/most-viewed/regular-stories") must beSome.which({ collection => - val collectionWithTerritory = collection.copy(targetedTerritory = Some(NZTerritory)) - val json = Json.toJson(collectionWithTerritory).toString() - json mustEqual """{"displayName":"Most popular","backfill":{"type":"capi","query":"uk/commentisfree?show-most-viewed=true&show-editors-picks=false&hide-recent-content=true"},"type":"news/most-popular","uneditable":true,"targetedTerritory":"NZ"}""" - }) - } + val collection = config.collections.get("uk/commentisfree/most-viewed/regular-stories").value + val collectionWithTerritory = collection.copy(targetedTerritory = Some(NZTerritory)) + val json = Json.toJson(collectionWithTerritory).toString() + json shouldBe """{"displayName":"Most popular","backfill":{"type":"capi","query":"uk/commentisfree?show-most-viewed=true&show-editors-picks=false&hide-recent-content=true"},"type":"news/most-popular","uneditable":true,"targetedTerritory":"NZ"}""" } } diff --git a/fapi-client/src/test/scala/com/gu/facia/api/ResponseTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/ResponseTest.scala index eea0d911..4326053e 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/ResponseTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/ResponseTest.scala @@ -2,9 +2,12 @@ package com.gu.facia.api import org.scalatest.concurrent.ScalaFutures import org.scalatest._ +import org.scalatest.freespec.AnyFreeSpec +import org.scalatest.matchers.should.Matchers + import scala.concurrent.ExecutionContext.Implicits.global -class ResponseTest extends FreeSpec with Matchers with ScalaFutures { +class ResponseTest extends AnyFreeSpec with Matchers with ScalaFutures { "Response.filter" - { "should return the same result if the filter function returns true" in { diff --git a/fapi-client/src/test/scala/com/gu/facia/api/contentapi/ContentApiTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/contentapi/ContentApiTest.scala index f23e4f88..d10b0020 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/contentapi/ContentApiTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/contentapi/ContentApiTest.scala @@ -1,7 +1,6 @@ package com.gu.facia.api.contentapi import java.net.URI - import com.gu.contentapi.client.model.ItemQuery import com.gu.contentapi.client.model.v1.{Content, ItemResponse, SearchResponse, Tag} import com.gu.contentapi.client.{ContentApiClient, ContentApiQueries, GuardianContentClient} @@ -10,11 +9,13 @@ import lib.ExecutionContext import org.mockito.Mockito._ import org.scalatest._ import org.scalatest.concurrent.ScalaFutures +import org.scalatest.freespec.AnyFreeSpec +import org.scalatest.matchers.should.Matchers import org.scalatestplus.mockito.MockitoSugar import scala.concurrent.Future -class ContentApiTest extends FreeSpec +class ContentApiTest extends AnyFreeSpec with Matchers with OptionValues with EitherValues diff --git a/fapi-client/src/test/scala/com/gu/facia/api/contentapi/IdsSearchQueriesTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/contentapi/IdsSearchQueriesTest.scala index 19e1b251..da9741cf 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/contentapi/IdsSearchQueriesTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/contentapi/IdsSearchQueriesTest.scala @@ -1,8 +1,9 @@ package com.gu.facia.api.contentapi -import org.scalatest.{Matchers, FreeSpec} +import org.scalatest.freespec.AnyFreeSpec +import org.scalatest.matchers.should.Matchers -class IdsSearchQueriesTest extends FreeSpec with Matchers { +class IdsSearchQueriesTest extends AnyFreeSpec with Matchers { "limit batches" - { val fifty = List.fill(50)("abc").toSeq diff --git a/fapi-client/src/test/scala/com/gu/facia/api/integration/IntegrationTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/integration/IntegrationTest.scala index 1586e365..3a981d52 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/integration/IntegrationTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/integration/IntegrationTest.scala @@ -1,20 +1,22 @@ package com.gu.facia.api.integration import com.gu.contentapi.client.model.v1.TagType -import com.gu.facia.api.{ApiError, FAPI} import com.gu.facia.api.contentapi.ContentApi.{AdjustItemQuery, AdjustSearchQuery} import com.gu.facia.api.models._ -import com.gu.facia.api.utils.{InvalidBackfillConfiguration, SectionKicker} +import com.gu.facia.api.utils.SectionKicker +import com.gu.facia.api.{ApiError, FAPI} import com.gu.facia.client.models._ import lib.IntegrationTestConfig import org.joda.time.DateTime +import org.scalatest.OptionValues import org.scalatest.concurrent.ScalaFutures +import org.scalatest.freespec.AnyFreeSpec +import org.scalatest.matchers.should.Matchers import org.scalatest.time.{Millis, Seconds, Span} -import org.scalatest.{FreeSpec, Matchers, OptionValues} import play.api.libs.json.{JsArray, JsString, Json} // TODO: reinstate ignored tests when cmsFronts account has access to test fixtures -class IntegrationTest extends FreeSpec with Matchers with ScalaFutures with OptionValues with IntegrationTestConfig { +class IntegrationTest extends AnyFreeSpec with Matchers with ScalaFutures with OptionValues with IntegrationTestConfig { implicit val patience = PatienceConfig(Span(20, Seconds), Span(50, Millis)) def makeCollectionJson(trails: Trail*) = CollectionJson( diff --git a/fapi-client/src/test/scala/com/gu/facia/api/models/CollectionTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/models/CollectionTest.scala index 07b41647..4b821607 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/models/CollectionTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/models/CollectionTest.scala @@ -6,11 +6,13 @@ import com.gu.facia.api.utils._ import com.gu.facia.client.models.{Branded, CollectionConfigJson, CollectionJson, Trail, TrailMetaData} import org.joda.time.DateTime import org.mockito.Mockito._ +import org.scalatest.OneInstancePerTest +import org.scalatest.freespec.AnyFreeSpec +import org.scalatest.matchers.should.Matchers import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{FreeSpec, OneInstancePerTest, Matchers} import play.api.libs.json.{JsArray, JsString, Json} -class CollectionTest extends FreeSpec with Matchers with MockitoSugar with OneInstancePerTest { +class CollectionTest extends AnyFreeSpec with Matchers with MockitoSugar with OneInstancePerTest { val trailMetadata = spy(TrailMetaData.empty) val trail = Trail("internal-code/page/123", 1, None, Some(trailMetadata)) val collectionJson = CollectionJson( diff --git a/fapi-client/src/test/scala/com/gu/facia/api/models/CuratedContentTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/models/CuratedContentTest.scala index f3667fc0..2a29cc73 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/models/CuratedContentTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/models/CuratedContentTest.scala @@ -1,15 +1,15 @@ package com.gu.facia.api.models -import com.gu.contentapi.client.model.v1.{TagType, ContentFields, Tag, Content} -import com.gu.facia.api.utils.{TagKicker, SectionKicker} +import com.gu.contentapi.client.model.v1.{ContentFields, Tag, TagType} +import com.gu.facia.api.utils.{ResolvedMetaData, SectionKicker, TagKicker} import com.gu.facia.client.models.{CollectionConfigJson, TrailMetaData} import lib.TestContent -import org.scalatest.{FreeSpec, Matchers} -import play.api.libs.json.{JsBoolean, JsString} import org.scalatest.OptionValues._ -import com.gu.facia.api.utils.ResolvedMetaData +import org.scalatest.freespec.AnyFreeSpec +import org.scalatest.matchers.should.Matchers +import play.api.libs.json.{JsBoolean, JsString} -class CuratedContentTest extends FreeSpec with Matchers with TestContent { +class CuratedContentTest extends AnyFreeSpec with Matchers with TestContent { val collectionConfig = CollectionConfig.fromCollectionJson(CollectionConfigJson.withDefaults()) diff --git a/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaContentHelperTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaContentHelperTest.scala index cad37194..f1f75b08 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaContentHelperTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaContentHelperTest.scala @@ -4,9 +4,10 @@ import com.gu.contentapi.client.model.v1.ContentFields import com.gu.facia.api.utils.{ContentProperties, DefaultCardstyle, FaciaContentUtils} import com.gu.facia.client.models.{Trail, TrailMetaData} import lib.TestContent -import org.scalatest.{FreeSpec, Matchers} +import org.scalatest.freespec.AnyFreeSpec +import org.scalatest.matchers.should.Matchers -class FaciaContentHelperTest extends FreeSpec with Matchers with TestContent { +class FaciaContentHelperTest extends AnyFreeSpec with Matchers with TestContent { val emptyTrail: Trail = Trail("no-id", 0, None, Option(TrailMetaData.empty)) diff --git a/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaImageCutoutTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaImageCutoutTest.scala index 2ddf6e22..c2a31f54 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaImageCutoutTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaImageCutoutTest.scala @@ -1,13 +1,14 @@ package com.gu.facia.api.models -import com.gu.contentapi.client.model.v1.{TagType, ContentFields, Tag, Content} +import com.gu.contentapi.client.model.v1.{Content, ContentFields, Tag, TagType} import com.gu.facia.api.utils.ResolvedMetaData import com.gu.facia.client.models.TrailMetaData import lib.TestContent -import org.scalatest.{Matchers, FreeSpec} -import play.api.libs.json.{JsString, JsBoolean} +import org.scalatest.freespec.AnyFreeSpec +import org.scalatest.matchers.should.Matchers +import play.api.libs.json.{JsBoolean, JsString} -class FaciaImageCutoutTest extends FreeSpec with Matchers with TestContent { +class FaciaImageCutoutTest extends AnyFreeSpec with Matchers with TestContent { def trailMetaDataWithImageCutout( imageCutoutReplace: Boolean = false, diff --git a/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaImageReplaceTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaImageReplaceTest.scala index 571b61d2..a1675c1d 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaImageReplaceTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaImageReplaceTest.scala @@ -2,10 +2,11 @@ package com.gu.facia.api.models import com.gu.facia.api.utils.ResolvedMetaData import com.gu.facia.client.models.TrailMetaData -import org.scalatest.{Matchers, FlatSpec} -import play.api.libs.json.{JsObject, JsString, JsBoolean} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers +import play.api.libs.json.{JsBoolean, JsObject, JsString} -class FaciaImageReplaceTest extends FlatSpec with Matchers { +class FaciaImageReplaceTest extends AnyFlatSpec with Matchers { val trailMetaDataWithoutImageReplace = TrailMetaData(Map( "imageReplace" -> JsBoolean(value = false), diff --git a/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaImageSlideshowTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaImageSlideshowTest.scala index 07ecf335..36c27725 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaImageSlideshowTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/models/FaciaImageSlideshowTest.scala @@ -2,10 +2,11 @@ package com.gu.facia.api.models import com.gu.facia.api.utils.ResolvedMetaData import com.gu.facia.client.models.TrailMetaData -import org.scalatest.{Matchers, FlatSpec} -import play.api.libs.json.{JsObject, JsArray, JsString, JsBoolean} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers +import play.api.libs.json.{JsArray, JsBoolean, JsObject, JsString} -class FaciaImageSlideshowTest extends FlatSpec with Matchers { +class FaciaImageSlideshowTest extends AnyFlatSpec with Matchers { val assetOne = JsObject(List( "src" -> JsString("theImageSrcOne"), "width" -> JsString("theImageSrcWidthOne"), diff --git a/fapi-client/src/test/scala/com/gu/facia/api/models/FrontTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/models/FrontTest.scala index 04b19b03..e27c36d6 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/models/FrontTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/models/FrontTest.scala @@ -2,9 +2,11 @@ package com.gu.facia.api.models import com.gu.facia.client.models.FrontJson import org.scalatest._ +import org.scalatest.freespec.AnyFreeSpec +import org.scalatest.matchers.should.Matchers import org.scalatestplus.mockito.MockitoSugar -class FrontTest extends FreeSpec with Matchers with MockitoSugar with OneInstancePerTest { +class FrontTest extends AnyFreeSpec with Matchers with MockitoSugar with OneInstancePerTest { "fromFrontJson" - { "when generating the canonical field" - { val frontJson = FrontJson( diff --git a/fapi-client/src/test/scala/com/gu/facia/api/utils/ContainerBrandingFinderTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/utils/ContainerBrandingFinderTest.scala index cb8eb4eb..30575c6e 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/utils/ContainerBrandingFinderTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/utils/ContainerBrandingFinderTest.scala @@ -1,14 +1,16 @@ package com.gu.facia.api.utils -import com.gu.facia.api.TestModel.{getContentItem, getTag} +import com.gu.commercial.branding.{Branding, Logo, PaidMultiSponsorBranding, Sponsored} import com.gu.contentapi.client.model.v1.Content +import com.gu.facia.api.TestModel.{getContentItem, getTag} import com.gu.facia.api.models.CollectionConfig -import com.gu.facia.client.models.Branded -import org.scalatest.{FlatSpec, Matchers, OptionValues} -import com.gu.commercial.branding.{Branding, BrandingFinder, Sponsored, Logo, PaidMultiSponsorBranding} import com.gu.facia.api.utils.ContainerBrandingFinder._ +import com.gu.facia.client.models.Branded +import org.scalatest.OptionValues +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers -class ContainerBrandingFinderTest extends FlatSpec with Matchers with OptionValues { +class ContainerBrandingFinderTest extends AnyFlatSpec with Matchers with OptionValues { private def getTagBrandedItem = getContentItem("TagBrandedContent.json") private def getMultipleTagBrandedItem = getContentItem("TagBrandedContent-MultipleBrands.json") diff --git a/fapi-client/src/test/scala/com/gu/facia/api/utils/ExternalLinksTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/utils/ExternalLinksTest.scala index efb5e7ba..53459612 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/utils/ExternalLinksTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/utils/ExternalLinksTest.scala @@ -1,9 +1,11 @@ package com.gu.facia.api.utils -import org.scalatest.{Inspectors, Matchers, FlatSpec} -import ExternalLinks._ +import com.gu.facia.api.utils.ExternalLinks._ +import org.scalatest.Inspectors +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers -class ExternalLinksTest extends FlatSpec with Matchers with Inspectors { +class ExternalLinksTest extends AnyFlatSpec with Matchers with Inspectors { val testPaths = Seq( "/sport/cycling", "/cities/2014/nov/24/equal-streets-happier-healthier-mumbai", diff --git a/fapi-client/src/test/scala/com/gu/facia/api/utils/FaciaContentUtilsTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/utils/FaciaContentUtilsTest.scala index d593f8a4..b7f27512 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/utils/FaciaContentUtilsTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/utils/FaciaContentUtilsTest.scala @@ -1,13 +1,14 @@ package com.gu.facia.api.utils import com.gu.contentapi.client.model.v1._ -import com.gu.facia.api.models.{ContentFormat, CuratedContent, LatestSnap, LinkSnap, SupportingCuratedContent} +import com.gu.facia.api.models._ import lib.TestContent import org.joda.time.DateTime import org.joda.time.format.ISODateTimeFormat -import org.scalatest.{FreeSpec, Matchers} +import org.scalatest.freespec.AnyFreeSpec +import org.scalatest.matchers.should.Matchers -class FaciaContentUtilsTest extends FreeSpec with Matchers with TestContent { +class FaciaContentUtilsTest extends AnyFreeSpec with Matchers with TestContent { val emptyProperties = ContentProperties.fromResolvedMetaData(ResolvedMetaData.Default) diff --git a/fapi-client/src/test/scala/com/gu/facia/api/utils/ItemKickerTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/utils/ItemKickerTest.scala index cdeade23..36677221 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/utils/ItemKickerTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/utils/ItemKickerTest.scala @@ -1,15 +1,17 @@ package com.gu.facia.api.utils -import com.gu.contentapi.client.model.v1.{ContentFields, Content} +import com.gu.contentapi.client.model.v1.{Content, ContentFields} import com.gu.facia.api.models.CollectionConfig import com.gu.facia.client.models.{CollectionConfigJson, TrailMetaData} import org.mockito.Mockito -import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.{OneInstancePerTest, OptionValues, Matchers, FreeSpec} import org.mockito.Mockito._ +import org.scalatest.freespec.AnyFreeSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.{OneInstancePerTest, OptionValues} +import org.scalatestplus.mockito.MockitoSugar -class ItemKickerTest extends FreeSpec with Matchers with MockitoSugar with OptionValues with OneInstancePerTest { +class ItemKickerTest extends AnyFreeSpec with Matchers with MockitoSugar with OptionValues with OneInstancePerTest { val trailMetadata = Mockito.spy(TrailMetaData.empty) val content = mock[Content] val collectionConfig = Mockito.spy(CollectionConfig.fromCollectionJson(CollectionConfigJson.withDefaults())) diff --git a/fapi-client/src/test/scala/com/gu/facia/api/utils/ResolvedMetaDataTest.scala b/fapi-client/src/test/scala/com/gu/facia/api/utils/ResolvedMetaDataTest.scala index 2b880577..ba105f22 100644 --- a/fapi-client/src/test/scala/com/gu/facia/api/utils/ResolvedMetaDataTest.scala +++ b/fapi-client/src/test/scala/com/gu/facia/api/utils/ResolvedMetaDataTest.scala @@ -2,11 +2,12 @@ package com.gu.facia.api.utils import com.gu.contentapi.client.model.v1._ import com.gu.facia.client.models.TrailMetaData -import org.scalatest.{FreeSpec, Matchers} -import play.api.libs.json.JsBoolean import lib.TestContent +import org.scalatest.freespec.AnyFreeSpec +import org.scalatest.matchers.should.Matchers +import play.api.libs.json.JsBoolean -class ResolvedMetaDataTest extends FreeSpec with Matchers with TestContent { +class ResolvedMetaDataTest extends AnyFreeSpec with Matchers with TestContent { def tagWithId(id: String) = Tag( id = id, diff --git a/project/dependencies.scala b/project/dependencies.scala index 88dbc27b..0d2acb87 100644 --- a/project/dependencies.scala +++ b/project/dependencies.scala @@ -8,8 +8,8 @@ object Dependencies { val contentApi = "com.gu" %% "content-api-client" % capiVersion val contentApiDefault = "com.gu" %% "content-api-client-default" % capiVersion % Test val mockito = "org.mockito" % "mockito-all" % "1.10.19" % Test - val scalaTest = "org.scalatest" %% "scalatest" % "3.0.9" % Test - val specs2 = "org.specs2" %% "specs2-core" % "4.20.0" % Test - val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % "3.9.5" - val commercialShared = "com.gu" %% "commercial-shared" % "6.1.8" + val scalaTestMockito = "org.scalatestplus" %% "mockito-4-11" % "3.2.16.0" % Test + val scalaTest = "org.scalatest" %% "scalatest" % "3.2.15" % Test + val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % "3.9.2" + val commercialShared = "com.gu" %% "commercial-shared" % "6.1.6" }