diff --git a/common/app/views/support/HtmlCleaner.scala b/common/app/views/support/HtmlCleaner.scala
index 3832f443f795..1198dd5f4064 100644
--- a/common/app/views/support/HtmlCleaner.scala
+++ b/common/app/views/support/HtmlCleaner.scala
@@ -23,7 +23,7 @@ import services.SkimLinksCache
import views.html.fragments.affiliateLinksDisclaimer
import views.support.Commercial.isAdFree
-import scala.collection.JavaConverters._
+import scala.jdk.CollectionConverters._
import scala.collection.mutable
import scala.util.Try
diff --git a/common/app/views/support/JavaScriptPage.scala b/common/app/views/support/JavaScriptPage.scala
index fcf56959e074..547d71408530 100644
--- a/common/app/views/support/JavaScriptPage.scala
+++ b/common/app/views/support/JavaScriptPage.scala
@@ -26,7 +26,7 @@ object JavaScriptPage {
CamelCase.fromHyphenated(key.split('.').lastOption.getOrElse(""))
}
- val config = (Configuration.javascript.config ++ pageData).mapValues(JsString.apply)
+ val config = (Configuration.javascript.config ++ pageData).view.mapValues(JsString.apply).toMap
val sponsorshipType = for {
commercial <- page.metadata.commercial
branding <- commercial.branding(edition)
@@ -100,5 +100,5 @@ object JavaScriptPage {
("brazeApiKey", JsString(Configuration.braze.apiKey)),
("ipsosTag", JsString(ipsos)),
) ++ commercialBundleUrl
- }
+ }.toMap
}
diff --git a/common/app/views/support/MinuteCleaner.scala b/common/app/views/support/MinuteCleaner.scala
index 4b7ee9219928..96cdd50a0aec 100644
--- a/common/app/views/support/MinuteCleaner.scala
+++ b/common/app/views/support/MinuteCleaner.scala
@@ -1,7 +1,7 @@
package views.support
import org.jsoup.nodes.{Document, Element}
-import scala.collection.JavaConverters._
+import scala.jdk.CollectionConverters._
case class TimestampCleaner(article: model.Article) extends HtmlCleaner {
override def clean(document: Document): Document = {
diff --git a/common/app/views/support/WitnessCleaner.scala b/common/app/views/support/WitnessCleaner.scala
index 13eb38bb36e2..fc2c3922469a 100644
--- a/common/app/views/support/WitnessCleaner.scala
+++ b/common/app/views/support/WitnessCleaner.scala
@@ -1,7 +1,7 @@
package views.support
import org.jsoup.nodes.{Element, Document}
-import scala.collection.JavaConverters._
+import scala.jdk.CollectionConverters._
object WitnessCleaner extends HtmlCleaner {
override def clean(document: Document): Document = {
diff --git a/common/app/views/support/cleaner/CmpParamCleaner.scala b/common/app/views/support/cleaner/CmpParamCleaner.scala
index d8780745f8cf..2fab1fde7aa0 100644
--- a/common/app/views/support/cleaner/CmpParamCleaner.scala
+++ b/common/app/views/support/cleaner/CmpParamCleaner.scala
@@ -3,7 +3,7 @@ package views.support.cleaner
import org.jsoup.nodes.{Document, Element}
import views.support.HtmlCleaner
-import scala.collection.JavaConverters._
+import scala.jdk.CollectionConverters._
object CmpParamCleaner extends HtmlCleaner {
override def clean(document: Document): Document = {
diff --git a/common/app/views/support/cleaner/VideoEmbedCleaner.scala b/common/app/views/support/cleaner/VideoEmbedCleaner.scala
index 979abc790c53..3da00a6b9467 100644
--- a/common/app/views/support/cleaner/VideoEmbedCleaner.scala
+++ b/common/app/views/support/cleaner/VideoEmbedCleaner.scala
@@ -6,7 +6,7 @@ import model.{Article, DotcomContentType, ShareLinks, VideoElement}
import org.jsoup.nodes.{Document, Element}
import views.support.{HtmlCleaner, Item640}
-import scala.collection.JavaConverters._
+import scala.jdk.CollectionConverters._
/*
* maxEmbedHeight: 812px - full height on an iPhone X
diff --git a/common/app/views/support/package.scala b/common/app/views/support/package.scala
index 27caae7ee829..e4233f485bb2 100644
--- a/common/app/views/support/package.scala
+++ b/common/app/views/support/package.scala
@@ -18,7 +18,7 @@ import play.api.mvc.{RequestHeader, Result}
import play.twirl.api.Html
import layout.slices.ContainerDefinition
-import scala.collection.JavaConverters._
+import scala.jdk.CollectionConverters._
/**
* Encapsulates previous and next urls
diff --git a/common/test/common/ExperimentsTest.scala b/common/test/common/ExperimentsTest.scala
index 06ababdc40af..46a7e92d7dae 100644
--- a/common/test/common/ExperimentsTest.scala
+++ b/common/test/common/ExperimentsTest.scala
@@ -11,7 +11,7 @@ import play.api.mvc.RequestHeader
class ExperimentsTest extends AnyFlatSpec with Matchers {
- conf.switches.Switches.ServerSideExperiments.switchOn
+ conf.switches.Switches.ServerSideExperiments.switchOn()
"Experiments" should "not share participation group" in {
ActiveExperiments.allExperiments.size should be(ActiveExperiments.allExperiments.map(_.participationGroup).size)
@@ -176,9 +176,9 @@ class ExperimentsTest extends AnyFlatSpec with Matchers {
trait EnabledExperiments {
def apply[T](block: => T): T = {
- TestCases.experiments.foreach(_.switch.switchOn)
+ TestCases.experiments.foreach(_.switch.switchOn())
val result = block
- TestCases.experiments.foreach(_.switch.switchOff)
+ TestCases.experiments.foreach(_.switch.switchOff())
result
}
}
diff --git a/common/test/common/ModelOrResultTest.scala b/common/test/common/ModelOrResultTest.scala
index 805df639ed5c..d86ed43102b3 100644
--- a/common/test/common/ModelOrResultTest.scala
+++ b/common/test/common/ModelOrResultTest.scala
@@ -94,7 +94,7 @@ class ModelOrResultTest extends AnyFlatSpec with Matchers with WithTestExecution
ModelOrResult(
item = None,
response = stubResponse.copy(content = Some(testArticle)),
- ).right.get
+ ).toOption.get
}
status(notFound) should be(200)
@@ -106,7 +106,7 @@ class ModelOrResultTest extends AnyFlatSpec with Matchers with WithTestExecution
ModelOrResult(
item = None,
response = stubResponse.copy(content = Some(testVideo)),
- ).right.get
+ ).toOption.get
}
status(notFound) should be(200)
@@ -118,7 +118,7 @@ class ModelOrResultTest extends AnyFlatSpec with Matchers with WithTestExecution
ModelOrResult(
item = None,
response = stubResponse.copy(content = Some(testGallery)),
- ).right.get
+ ).toOption.get
}
status(notFound) should be(200)
@@ -130,7 +130,7 @@ class ModelOrResultTest extends AnyFlatSpec with Matchers with WithTestExecution
ModelOrResult(
item = None,
response = stubResponse.copy(content = Some(testAudio)),
- ).right.get
+ ).toOption.get
}
status(notFound) should be(200)
@@ -142,7 +142,7 @@ class ModelOrResultTest extends AnyFlatSpec with Matchers with WithTestExecution
ModelOrResult(
item = None,
response = stubResponse.copy(content = Some(testContent)),
- ).right.get
+ ).toOption.get
}
status(notFound) should be(404)
@@ -153,7 +153,7 @@ class ModelOrResultTest extends AnyFlatSpec with Matchers with WithTestExecution
ModelOrResult(
item = None,
response = stubResponse.copy(tag = Some(articleTag)),
- ).right.get
+ ).toOption.get
}
status(notFound) should be(200)
@@ -167,7 +167,7 @@ class ModelOrResultTest extends AnyFlatSpec with Matchers with WithTestExecution
ModelOrResult(
item = None,
response = stubResponse.copy(section = Some(testSection)),
- ).right.get
+ ).toOption.get
}
status(notFound) should be(200)
diff --git a/common/test/common/TagLinkerTest.scala b/common/test/common/TagLinkerTest.scala
index 711564795d3c..9c851f60a1c5 100644
--- a/common/test/common/TagLinkerTest.scala
+++ b/common/test/common/TagLinkerTest.scala
@@ -16,7 +16,7 @@ import org.scalatestplus.play.guice.GuiceOneAppPerSuite
import play.api.test.FakeRequest
import views.support.TagLinker
-import scala.collection.JavaConverters._
+import scala.jdk.CollectionConverters._
class TagLinkerTest extends AnyFlatSpec with Matchers with GuiceOneAppPerSuite {
diff --git a/common/test/common/TrailsToShowcaseTest.scala b/common/test/common/TrailsToShowcaseTest.scala
index 1f04af327646..d1f2005bd391 100644
--- a/common/test/common/TrailsToShowcaseTest.scala
+++ b/common/test/common/TrailsToShowcaseTest.scala
@@ -14,7 +14,7 @@ import org.scalatest.matchers.should.Matchers
import play.api.test.FakeRequest
import java.time.ZoneOffset
-import scala.collection.JavaConverters._
+import scala.jdk.CollectionConverters._
import scala.xml.{Node, XML}
class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
@@ -439,7 +439,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase.asSingleStoryPanel(withSupportingContent)
outcome.left.toOption.isEmpty should be(true)
- val singleStoryRelatedArticlesPanel = outcome.right.get
+ val singleStoryRelatedArticlesPanel = outcome.toOption.get
singleStoryRelatedArticlesPanel.articleGroup.nonEmpty shouldBe (true)
singleStoryRelatedArticlesPanel.articleGroup.get.role shouldBe ("RELATED_CONTENT")
singleStoryRelatedArticlesPanel.articleGroup.get.articles.size shouldBe (2)
@@ -482,9 +482,9 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase.asSingleStoryPanel(withInvalidSupportingContent)
- outcome.left.toOption.nonEmpty should be(true)
- outcome.left.get.contains(s"The headline '$longerThan54' is longer than 54 characters") should be(true)
- outcome.left.get.contains(s"Kicker text '$longerThan54' is longer than 42 characters") should be(true)
+ outcome.swap.toOption.nonEmpty should be(true)
+ outcome.swap.contains(s"The headline '$longerThan54' is longer than 54 characters") should be(true)
+ outcome.swap.contains(s"Kicker text '$longerThan54' is longer than 42 characters") should be(true)
}
"TrailToShowcase" should "reject related articles panels with incorrect number of articles" in {
@@ -506,8 +506,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase.asSingleStoryPanel(withoutEnoughSupportingContent)
- outcome.left.toOption.nonEmpty should be(true)
- outcome.left.get.contains("Could not find 2 valid related article trails") should be(true)
+ outcome.swap.toOption.nonEmpty should be(true)
+ outcome.swap.contains("Could not find 2 valid related article trails") should be(true)
}
"TrailToShowcase" can "encode single story panel bullet lists from trailtext lines" in {
@@ -575,8 +575,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase.asSingleStoryPanel(bulletedContent)
- outcome.right.toOption should be(None)
- outcome.left.get.contains("Trail text is not formatted as a bullet list") shouldBe (true)
+ outcome.toOption should be(None)
+ outcome.swap.toOption.get.contains("Trail text is not formatted as a bullet list") shouldBe (true)
}
"TrailToShowcase" should "reject bullet lists with less than 2 items" in {
@@ -595,8 +595,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase.asSingleStoryPanel(bulletedContent)
- outcome.right.toOption should be(None)
- outcome.left.get.contains("Need at least 2 valid bullet list items") shouldBe (true)
+ outcome.toOption should be(None)
+ outcome.swap.contains("Need at least 2 valid bullet list items") shouldBe (true)
}
"TrailToShowcase" should "trim single story bullets to 3 at most" in {
@@ -684,7 +684,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
"rundown-container-id",
Some(collectionLastUpdated),
)
- .right
+ .toOption
.get
recentlyEditedRundownPanelMadeWithUnchangingContent.updated should be(collectionLastUpdated)
@@ -708,7 +708,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel = TrailsToShowcase
.asRundownPanel(Seq(trail, anotherTrail, anotherTrail), "rundown-container-id")
- .right
+ .toOption
.get
rundownPanel.`type` should be("RUNDOWN")
@@ -752,7 +752,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
)
val rundownPanel = TrailsToShowcase
.asRundownPanel(Seq(trail, anotherTrail, anotherTrail), "rundown-container-id")
- .right
+ .toOption
.get
val entry = TrailsToShowcase.asSyndEntry(rundownPanel)
@@ -801,9 +801,9 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase
.asRundownPanel(Seq(firstTrail, anotherTrail, anotherTrail), "rundown-container-id")
- outcome.right.get.panelTitle should be("My rundown panel title")
- outcome.right.get.articleGroup.articles.head.title should be("My headline")
- outcome.right.get.articleGroup.articles.head.overline should be(Some("A Kicker"))
+ outcome.toOption.get.panelTitle should be("My rundown panel title")
+ outcome.toOption.get.articleGroup.articles.head.title should be("My headline")
+ outcome.toOption.get.articleGroup.articles.head.overline should be(Some("A Kicker"))
}
"TrailToShowcase" should "infer the mandatory Rundown panel title from a pipe delimit in the first trail's headline" in {
@@ -825,8 +825,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase
.asRundownPanel(Seq(firstTrail, anotherTrail, anotherTrail), "rundown-container-id")
- outcome.right.get.panelTitle should be("My rundown panel title")
- outcome.right.get.articleGroup.articles.head.title should be("My headline")
+ outcome.toOption.get.panelTitle should be("My rundown panel title")
+ outcome.toOption.get.articleGroup.articles.head.title should be("My headline")
}
"TrailToShowcase" should "allow panel titles with pipes in them" in {
@@ -849,8 +849,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase
.asRundownPanel(Seq(firstTrail, anotherTrail, anotherTrail), "rundown-container-id")
- outcome.right.get.panelTitle should be("Evening briefing | Tuesday 28 September")
- outcome.right.get.articleGroup.articles.head.title should be(
+ outcome.toOption.get.panelTitle should be("Evening briefing | Tuesday 28 September")
+ outcome.toOption.get.articleGroup.articles.head.title should be(
"PM meets with Liberal MPs worried Coalition will appease Nats",
)
}
@@ -874,8 +874,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase
.asRundownPanel(Seq(firstTrail, anotherTrail, anotherTrail), "rundown-container-id")
- outcome.right.toOption should be(None)
- outcome.left.get.contains(
+ outcome.toOption should be(None)
+ outcome.swap.contains(
"Could not find a panel title in the first trail headline 'My headline but I've forgotten the rundown panel title'",
) should be(true)
}
@@ -891,7 +891,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel = TrailsToShowcase
.asRundownPanel(Seq(withByline, withByline, withByline), "rundown-container-id")
- .right
+ .toOption
.get
val firstItemInArticleGroup = rundownPanel.articleGroup.articles.head
@@ -909,7 +909,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel = TrailsToShowcase
.asRundownPanel(Seq(withKicker, withKicker, withKicker), "rundown-container-id")
- .right
+ .toOption
.get
val firstItemInArticleGroup = rundownPanel.articleGroup.articles.head
@@ -928,7 +928,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel = TrailsToShowcase
.asRundownPanel(Seq(withAuthorAndKicker, withAuthorAndKicker, withAuthorAndKicker), "rundown-container-id")
- .right
+ .toOption
.get
val firstItemInArticleGroup = rundownPanel.articleGroup.articles.head
@@ -955,7 +955,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel = TrailsToShowcase
.asRundownPanel(Seq(withAuthorAndKicker, withAuthorAndKicker, withMissingKicker), "rundown-container-id")
- .right
+ .toOption
.get
rundownPanel.articleGroup.articles.forall(_.author.nonEmpty) should be(true)
@@ -981,8 +981,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel = TrailsToShowcase
.asRundownPanel(Seq(withKicker, withKicker, withAuthor), "rundown-container-id")
- rundownPanel.right.toOption should be(None)
- rundownPanel.left.get should be(Seq("Rundown trails need to have all Kickers or all Bylines"))
+ rundownPanel.toOption should be(None)
+ rundownPanel.swap should be(Seq("Rundown trails need to have all Kickers or all Bylines"))
}
"TrailToShowcase" can "rundown panels articles should prefer replaced images over content trail image" in {
@@ -997,7 +997,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel = TrailsToShowcase
.asRundownPanel(Seq(withReplacedImage, withReplacedImage, withReplacedImage), "rundown-id")
- .right
+ .toOption
.get
rundownPanel.articleGroup.articles.head.imageUrl shouldBe Some("http://localhost/replaced-image.jpg")
@@ -1013,7 +1013,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel = TrailsToShowcase
.asRundownPanel(Seq(content, content, content), "rundown-container-id")
- .right
+ .toOption
.get
rundownPanel.articleGroup.articles.head.updated shouldBe (wayBackWhen)
@@ -1030,8 +1030,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase.asSingleStoryPanel(content)
- outcome.right.get.title should be("US Open winner could become Britain’s first billion-dollar sport star")
- outcome.right.get.panelTitle should be(Some("Meteoric rise"))
+ outcome.toOption.get.title should be("US Open winner could become Britain’s first billion-dollar sport star")
+ outcome.toOption.get.panelTitle should be(Some("Meteoric rise"))
}
"TrailToShowcase validation" should "reject single panel g:overlines longer than 30 characters" in {
@@ -1048,8 +1048,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase.asSingleStoryPanel(content)
- outcome.right.toOption should be(None)
- outcome.left.get.contains(s"Kicker text '${longerThan30}' is longer than 30 characters") shouldBe (true)
+ outcome.toOption should be(None)
+ outcome.swap.contains(s"Kicker text '${longerThan30}' is longer than 30 characters") shouldBe (true)
}
"TrailToShowcase validation" should "reject single panels with titles longer than 86 characters" in {
@@ -1066,8 +1066,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase.asSingleStoryPanel(withLongTitle)
- outcome.right.toOption should be(None)
- outcome.left.get.contains(s"The headline '$longerThan86' is longer than 86 characters") shouldBe (true)
+ outcome.toOption should be(None)
+ outcome.swap.contains(s"The headline '$longerThan86' is longer than 86 characters") shouldBe (true)
}
"TrailToShowcase validation" should "omit single panel author fields longer than 42 characters" in {
@@ -1084,7 +1084,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase.asSingleStoryPanel(withLongByline)
- outcome.right.get.author should be(None)
+ outcome.toOption.get.author should be(None)
//outcome.left.get.contains("Author was too long and was dropped") shouldBe(true)
}
@@ -1096,8 +1096,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase.asSingleStoryPanel(withNoImage)
- outcome.right.toOption should be(None)
- outcome.left.get.contains("No image available") shouldBe (true)
+ outcome.toOption should be(None)
+ outcome.swap.contains("No image available") shouldBe (true)
}
"TrailToShowcase validation" should "reject single panels with images smaller than 640x320" in {
@@ -1109,8 +1109,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase.asSingleStoryPanel(withTooSmallImage)
- outcome.right.toOption should be(None)
- outcome.left.get.contains("Could not find image bigger than the minimum required size: 640x320") shouldBe (true)
+ outcome.toOption should be(None)
+ outcome.swap.contains("Could not find image bigger than the minimum required size: 640x320") shouldBe (true)
}
"TrailToShowcase validation" should "reject rundown panels with less than 3 valid articles" in {
@@ -1133,8 +1133,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel =
TrailsToShowcase.asRundownPanel(Seq(valid, valid, notValid), "rundown-container-id")
- rundownPanel.right.toOption should be(None)
- rundownPanel.left.get.head should be("Could not find 3 valid rundown trails")
+ rundownPanel.toOption should be(None)
+ rundownPanel.swap.toOption.get.head should be("Could not find 3 valid rundown trails")
}
"TrailToShowcase validation" should "trim rundown panels to 3 articles if too many are supplied" in {
@@ -1148,7 +1148,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel = TrailsToShowcase
.asRundownPanel(Seq(content, content, content, content), "rundown-container-id")
- .right
+ .toOption
.get
rundownPanel.articleGroup.articles.size should be(3)
@@ -1170,7 +1170,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel = TrailsToShowcase.asRundownPanel(Seq(trail, anotherTrail), "rundown-container-id")
rundownPanel.toOption shouldBe (None)
- rundownPanel.left.get.contains(s"The panel title '$longerThan74' is longer than 74 characters") shouldBe (true)
+ rundownPanel.swap.contains(s"The panel title '$longerThan74' is longer than 74 characters") shouldBe (true)
}
"TrailToShowcase validation" should "reject rundown panel article kickers longer than 30 characters" in {
@@ -1188,7 +1188,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
.asRundownPanel(Seq(withTooLongKicker, withTooLongKicker, withTooLongKicker), "rundown-container-id")
outcome.toOption should be(None)
- outcome.left.get.contains(s"Kicker text '${longerThan30}' is longer than 30 characters") should be(true)
+ outcome.swap.contains(s"Kicker text '${longerThan30}' is longer than 30 characters") should be(true)
}
"TrailToShowcase validation" should "reject rundown panel articles with titles longer than 64 characters" in {
@@ -1208,7 +1208,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
)
rundownPanel.toOption should be(None)
- rundownPanel.left.get.contains(s"The headline '$longerThan64' is longer than 64 characters") should be(true)
+ rundownPanel.swap.contains(s"The headline '$longerThan64' is longer than 64 characters") should be(true)
}
"TrailToShowcase validation" should "reject rundown articles with images smaller than 1200x900" in {
@@ -1222,7 +1222,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
.asRundownPanel(Seq(withTooSmallImage, withTooSmallImage, withTooSmallImage), "rundown-container-id")
rundownPanel.toOption should be(None)
- rundownPanel.left.get.contains("Could not find image bigger than the minimum required size: 1200x900") should be(
+ rundownPanel.swap.contains("Could not find image bigger than the minimum required size: 1200x900") should be(
true,
)
}
@@ -1245,7 +1245,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel = TrailsToShowcase
.asRundownPanel(Seq(withKicker, withKicker, withoutKicker), "rundown-container-id")
- .right
+ .toOption
.get
rundownPanel.articleGroup.articles.size should be(3)
@@ -1269,8 +1269,8 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val outcome = TrailsToShowcase
.asRundownPanel(Seq(withAuthor, withAuthor, withoutAuthor), "rundown-container-id")
- outcome.right.toOption should be(None)
- outcome.left.get.contains("Rundown trails need to have all Kickers or all Bylines") should be(true)
+ outcome.toOption should be(None)
+ outcome.swap.contains("Rundown trails need to have all Kickers or all Bylines") should be(true)
}
"TrailToShowcase validation" should "choose kickers over authors" in {
@@ -1285,7 +1285,7 @@ class TrailsToShowcaseTest extends AnyFlatSpec with Matchers {
val rundownPanel = TrailsToShowcase
.asRundownPanel(Seq(withAuthorAndKicker, withAuthorAndKicker, withAuthorAndKicker), "rundown-container-id")
- .right
+ .toOption
.get
rundownPanel.articleGroup.articles.size should be(3)
diff --git a/common/test/common/commercial/hosted/ColourTest.scala b/common/test/common/commercial/hosted/ColourTest.scala
index 29030e8e56d9..dd983deb2d4b 100644
--- a/common/test/common/commercial/hosted/ColourTest.scala
+++ b/common/test/common/commercial/hosted/ColourTest.scala
@@ -11,36 +11,36 @@ class ColourTest extends AnyFlatSpec with Matchers {
"isDark" should "be true for Zootropolis green" in {
val zootropolisColour = Colour("#2ec869")
- zootropolisColour shouldBe 'dark
+ zootropolisColour shouldBe Symbol("dark")
}
it should "be false for a bright colour e.g Renault Yellow" in {
val renaultColour = Colour("#ffc421")
- renaultColour should not be 'dark
+ renaultColour should not be Symbol("dark")
}
it should "be true for a dark colour" in {
val brown = Colour("#6f5200")
- brown shouldBe 'dark
+ brown shouldBe Symbol("dark")
}
it should "be false for white" in {
val white = Colour("#ffffff")
- white should not be 'dark
+ white should not be Symbol("dark")
}
it should "be true for black" in {
val black = Colour("#000000")
- black shouldBe 'dark
+ black shouldBe Symbol("dark")
}
it should "be true for Visit Britain colour" in {
val visitBritainColour = Colour("#E41F13")
- visitBritainColour shouldBe 'dark
+ visitBritainColour shouldBe Symbol("dark")
}
it should "be true for Chester Zoo colour" in {
val chesterZooColour = Colour("#E31B22")
- chesterZooColour shouldBe 'dark
+ chesterZooColour shouldBe Symbol("dark")
}
}
diff --git a/common/test/common/dfp/GuLineItemTest.scala b/common/test/common/dfp/GuLineItemTest.scala
index 36fcc5c2bab7..f579b67c90c9 100644
--- a/common/test/common/dfp/GuLineItemTest.scala
+++ b/common/test/common/dfp/GuLineItemTest.scala
@@ -53,36 +53,36 @@ class GuLineItemTest extends AnyFlatSpec with Matchers {
"isSuitableForTopAboveNavSlot" should
"be true for a line item that meets all the rules" in {
- lineItem() shouldBe 'suitableForTopAboveNavSlot
+ lineItem() shouldBe Symbol("suitableForTopAboveNavSlot")
}
it should
"be true for a line item that has relevant creative targeting" in {
val creativePlaceholders =
Seq(GuCreativePlaceholder(leaderboardSize, targeting = Some(defaultTargeting)))
- lineItem(creativePlaceholders = creativePlaceholders) shouldBe 'suitableForTopAboveNavSlot
+ lineItem(creativePlaceholders = creativePlaceholders) shouldBe Symbol("suitableForTopAboveNavSlot")
}
it should "be false for a section front targeted indirectly" in {
val target = targeting(Seq(GuAdUnit("id", Seq("theguardian.com"), GuAdUnit.ACTIVE)))
- lineItem(targeting = target) should not be 'suitableForTopAboveNavSlot
+ lineItem(targeting = target) should not be Symbol("suitableForTopAboveNavSlot")
}
it should "be false for an untargeted section front" in {
val target = targeting(Seq(GuAdUnit("id", Seq("theguardian.com", "politics"), GuAdUnit.ACTIVE)))
- lineItem(targeting = target) should not be 'suitableForTopAboveNavSlot
+ lineItem(targeting = target) should not be Symbol("suitableForTopAboveNavSlot")
}
it should "be false for a front whose section is targeted but front not targeted directly" in {
val target = targeting(Seq(GuAdUnit("id", Seq("theguardian.com", "business"), GuAdUnit.ACTIVE)))
- lineItem(targeting = target) should not be 'suitableForTopAboveNavSlot
+ lineItem(targeting = target) should not be Symbol("suitableForTopAboveNavSlot")
}
it should "be false for a CPM campaign" in {
- lineItem(costType = "CPM") should not be 'suitableForTopAboveNavSlot
+ lineItem(costType = "CPM") should not be Symbol("suitableForTopAboveNavSlot")
}
it should "be false for a completed campaign" in {
- lineItem(endTime = Some(now.minusDays(1))) should not be 'suitableForTopAboveNavSlot
+ lineItem(endTime = Some(now.minusDays(1))) should not be Symbol("suitableForTopAboveNavSlot")
}
}
diff --git a/common/test/conf/CachedHealthCheckTest.scala b/common/test/conf/CachedHealthCheckTest.scala
index 58609b0516a3..c8db040ad3f7 100644
--- a/common/test/conf/CachedHealthCheckTest.scala
+++ b/common/test/conf/CachedHealthCheckTest.scala
@@ -64,7 +64,7 @@ import scala.util.Random
val controller = new MockController(Helpers.stubControllerComponents())
// Populate the cache and wait for it to finish
- whenReady(controller.runChecks) { _ =>
+ whenReady(controller.runChecks()) { _ =>
// Call the /_healthcheck endpoint on this controller
val healthCheckRequest = FakeRequest(method = "GET", path = "/_healthcheck")
val response = call(controller.healthCheck(), healthCheckRequest)
@@ -110,7 +110,7 @@ import scala.util.Random
}
"results which are never expiring" should {
"200" in {
- val resultDate = DateTime.now.minus(scala.util.Random.nextLong) // random date in the past
+ val resultDate = DateTime.now.minus(scala.util.Random.nextLong()) // random date in the past
val mockResults = List(mockResult(200, resultDate, None))
getHealthCheck(mockResults, HealthCheckPolicy.All) { response =>
status(response) should be(200)
diff --git a/common/test/conf/audio/FlagshipFrontContainerSpec.scala b/common/test/conf/audio/FlagshipFrontContainerSpec.scala
index a77fc7db62bc..b25c143a4681 100644
--- a/common/test/conf/audio/FlagshipFrontContainerSpec.scala
+++ b/common/test/conf/audio/FlagshipFrontContainerSpec.scala
@@ -11,7 +11,7 @@ class FlagshipFrontContainerSpec extends AnyFlatSpec with Matchers with BeforeAn
private val formatter =
DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm").withZone(FlagshipFrontContainer.londonTimezone)
- override def beforeAll: Unit = {
+ override def beforeAll(): Unit = {
FlagshipFrontContainerSwitch.switchOn()
}
diff --git a/common/test/model/ContentTest.scala b/common/test/model/ContentTest.scala
index c326c4ad94d4..9dc51e2fd67f 100644
--- a/common/test/model/ContentTest.scala
+++ b/common/test/model/ContentTest.scala
@@ -60,7 +60,7 @@ class ContentTest
elements = Some(elements),
)
- val trail: ContentType = Content(content)
+ val trail: model.ContentType = Content(content)
trail.fields.linkText should be("Some article")
trail.metadata.url should be("/foo/2012/jan/07/bar")
@@ -162,7 +162,7 @@ class ContentTest
it should "returns the correct shortUrlId (gu.com)" in {
- def contentWithShortUrl(shortUrl: String): ContentType =
+ def contentWithShortUrl(shortUrl: String): model.ContentType =
Content(article.copy(fields = Some(ContentFields(shortUrl = Some(shortUrl)))))
contentWithShortUrl("http://gu.com/p/3r1b5").fields.shortUrlId should be("/p/3r1b5")
@@ -171,7 +171,7 @@ class ContentTest
it should "returns the correct shortUrlId (www.theguardian.com)" in {
- def contentWithShortUrl(shortUrl: String): ContentType =
+ def contentWithShortUrl(shortUrl: String): model.ContentType =
Content(article.copy(fields = Some(ContentFields(shortUrl = Some(shortUrl)))))
contentWithShortUrl("http://www.theguardian.com/p/3r1b5").fields.shortUrlId should be("/p/3r1b5")
@@ -282,7 +282,7 @@ class ContentTest
contentType: String,
elements: List[ApiElement],
maybeByline: Option[String] = None,
- ): ContentType = {
+ ): model.ContentType = {
Content(contentApi(contentType, elements, maybeByline))
}
diff --git a/common/test/renderers/DotcomRenderingServiceTest.scala b/common/test/renderers/DotcomRenderingServiceTest.scala
index eb9226629235..7e3d2f4477c9 100644
--- a/common/test/renderers/DotcomRenderingServiceTest.scala
+++ b/common/test/renderers/DotcomRenderingServiceTest.scala
@@ -28,7 +28,7 @@ import org.scalatest.flatspec.AnyFlatSpec
val dotcomRenderingService = DotcomRenderingService()
val articleUrl = "politics/2021/oct/07/coronavirus-report-warned-of-impact-on-uk-four-years-before-pandemic"
- val post = PrivateMethod[Future[Result]]('post)
+ val post = PrivateMethod[Future[Result]](Symbol("post"))
val request = TestRequest()
private val wsMock = mock[WSClient]
private val wsResponseMock = mock[WSResponse]
diff --git a/common/test/services/IndexPageTest.scala b/common/test/services/IndexPageTest.scala
index 202cf8c8b0b1..62e61cf6b2fb 100644
--- a/common/test/services/IndexPageTest.scala
+++ b/common/test/services/IndexPageTest.scala
@@ -35,7 +35,7 @@ import scala.concurrent.Future
item.section.map(section =>
IndexPage(
page = Section.make(section),
- contents = item.results.getOrElse(Nil).map(IndexPageItem(_)),
+ contents = item.results.getOrElse(Nil).map(IndexPageItem(_)).toSeq,
tags = Tags(Nil),
date = DateTime.now,
tzOverride = None,
diff --git a/common/test/views/support/TemplatesTest.scala b/common/test/views/support/TemplatesTest.scala
index f818ff68647d..fda99ed8deff 100644
--- a/common/test/views/support/TemplatesTest.scala
+++ b/common/test/views/support/TemplatesTest.scala
@@ -18,7 +18,7 @@ import play.api.test.FakeRequest
import test.TestRequest
import org.scalatestplus.play.guice.GuiceOneAppPerSuite
-import scala.collection.JavaConverters._
+import scala.jdk.CollectionConverters._
import scala.xml.XML
class TemplatesTest extends AnyFlatSpec with Matchers with GuiceOneAppPerSuite {
diff --git a/discussion/app/controllers/CommentsController.scala b/discussion/app/controllers/CommentsController.scala
index 7ebba0a5fe0b..8659c45c4b11 100644
--- a/discussion/app/controllers/CommentsController.scala
+++ b/discussion/app/controllers/CommentsController.scala
@@ -126,41 +126,43 @@ class CommentsController(
csrfCheck {
Action.async { implicit request =>
val scGuU = request.cookies.get("SC_GU_U")
- userForm.bindFromRequest.fold(
- formWithErrors =>
- Future.successful(
- BadRequest(views.html.discussionComments.reportComment(commentId, reportAbusePage, formWithErrors)),
- ),
- userData => {
- discussionApi
- .postAbuseReport(userData, scGuU)
- .map {
- case success if success.status == 200 =>
- NoCache(Redirect(routes.CommentsController.reportAbuseThankYou(commentId)))
- case error =>
- InternalServerError(
- views.html.discussionComments.reportComment(
- commentId,
- reportAbusePage,
- userForm.fill(userData),
- errorMessage = Some(ReportAbuseFormValidation.genericErrorMessage),
- ),
- )
- }
- .recover({
- case NonFatal(e) =>
- InternalServerError(
- views.html.discussionComments.reportComment(
- commentId,
- reportAbusePage,
- userForm.fill(userData),
- errorMessage = Some(ReportAbuseFormValidation.genericErrorMessage),
- ),
- )
- })
-
- },
- )
+ userForm
+ .bindFromRequest()
+ .fold(
+ formWithErrors =>
+ Future.successful(
+ BadRequest(views.html.discussionComments.reportComment(commentId, reportAbusePage, formWithErrors)),
+ ),
+ userData => {
+ discussionApi
+ .postAbuseReport(userData, scGuU)
+ .map {
+ case success if success.status == 200 =>
+ NoCache(Redirect(routes.CommentsController.reportAbuseThankYou(commentId)))
+ case error =>
+ InternalServerError(
+ views.html.discussionComments.reportComment(
+ commentId,
+ reportAbusePage,
+ userForm.fill(userData),
+ errorMessage = Some(ReportAbuseFormValidation.genericErrorMessage),
+ ),
+ )
+ }
+ .recover({
+ case NonFatal(e) =>
+ InternalServerError(
+ views.html.discussionComments.reportComment(
+ commentId,
+ reportAbusePage,
+ userForm.fill(userData),
+ errorMessage = Some(ReportAbuseFormValidation.genericErrorMessage),
+ ),
+ )
+ })
+
+ },
+ )
}
}
diff --git a/discussion/app/discussion/api/DiscussionApi.scala b/discussion/app/discussion/api/DiscussionApi.scala
index b1287730cbb0..404e179e50e2 100644
--- a/discussion/app/discussion/api/DiscussionApi.scala
+++ b/discussion/app/discussion/api/DiscussionApi.scala
@@ -253,9 +253,7 @@ object AuthHeaders {
val all = Set(guIdToken, cookie)
def filterHeaders(headers: Headers): Map[String, String] =
- headers.toSimpleMap filterKeys {
- all.contains
- }
+ headers.toSimpleMap.view.filterKeys(all.contains).toMap
}
case class DiscussionParams(
diff --git a/discussion/app/discussion/model/Comment.scala b/discussion/app/discussion/model/Comment.scala
index f6bbc830c782..0ee0b923cebc 100644
--- a/discussion/app/discussion/model/Comment.scala
+++ b/discussion/app/discussion/model/Comment.scala
@@ -81,7 +81,7 @@ object Comment extends implicits.Dates {
(json \\ "responses").headOption map {
_.asInstanceOf[JsArray].value map { Comment(_, None, discussionOpt) }
} getOrElse Nil
- }
+ }.toSeq
}
case class ResponseTo(displayName: String, commentId: String)
diff --git a/discussion/app/discussion/model/DiscussionKey.scala b/discussion/app/discussion/model/DiscussionKey.scala
index 444d3663ed9b..f28d6eebff92 100644
--- a/discussion/app/discussion/model/DiscussionKey.scala
+++ b/discussion/app/discussion/model/DiscussionKey.scala
@@ -18,7 +18,7 @@ object DiscussionKey {
new PathBindable[DiscussionKey] {
override def bind(key: String, value: String): Either[String, DiscussionKey] = {
for {
- keyAsString <- stringBinder.bind(key, value).right
+ keyAsString <- stringBinder.bind(key, value)
} yield DiscussionKey(keyAsString)
}
diff --git a/discussion/app/discussion/model/comments.scala b/discussion/app/discussion/model/comments.scala
index 7e5be6b6f908..f00d13f92681 100644
--- a/discussion/app/discussion/model/comments.scala
+++ b/discussion/app/discussion/model/comments.scala
@@ -28,7 +28,7 @@ object DiscussionComments {
val comments = (json \ "discussion" \ "comments").as[JsArray].value map { Comment(_, None, Some(discussion)) }
DiscussionComments(
discussion = discussion,
- comments = comments,
+ comments = comments.toSeq,
pagination = DiscussionPagination(json),
commentCount = (json \ "discussion" \ "commentCount").asOpt[Int] getOrElse 0,
topLevelCommentCount = (json \ "discussion" \ "topLevelCommentCount").asOpt[Int] getOrElse 0,
@@ -53,7 +53,7 @@ object ProfileComments {
val comments = (json \ "comments").as[JsArray].value map { Comment(_, Some(profile), None) }
ProfileComments(
profile = profile,
- comments = comments,
+ comments = comments.toSeq,
pagination = DiscussionPagination(json),
)
}
@@ -65,7 +65,7 @@ object ProfileReplies {
}
ProfileComments(
profile = Profile(json),
- comments = comments,
+ comments = comments.toSeq,
pagination = DiscussionPagination(json),
)
}
@@ -84,7 +84,7 @@ object ProfileDiscussions {
val discussion = Discussion(d)
DiscussionComments(
discussion = discussion,
- comments = (d \ "comments").as[JsArray].value.map { Comment(_, Some(profile), Some(discussion)) },
+ comments = (d \ "comments").as[JsArray].value.map { Comment(_, Some(profile), Some(discussion)) }.toSeq,
pagination = DiscussionPagination(json),
commentCount = 0,
topLevelCommentCount = 0,
@@ -96,7 +96,7 @@ object ProfileDiscussions {
}
ProfileDiscussions(
profile = profile,
- discussions = discussions,
+ discussions = discussions.toIndexedSeq,
DiscussionPagination(json),
)
}
diff --git a/discussion/app/views/fragments/reportCommentForm.scala.html b/discussion/app/views/fragments/reportCommentForm.scala.html
index c341304bfc92..2b661975d31d 100644
--- a/discussion/app/views/fragments/reportCommentForm.scala.html
+++ b/discussion/app/views/fragments/reportCommentForm.scala.html
@@ -11,7 +11,7 @@
userForm.error("email"),
userForm.error("reason")
) { case (emailInput: Option[String], categoryError: Option[FormError], emailError: Option[FormError], reasonError: Option[FormError]) =>
- @helper.form(controllers.routes.CommentsController.reportAbuseSubmission(commentId), 'class -> "form") {
+ @helper.form(controllers.routes.CommentsController.reportAbuseSubmission(commentId), Symbol("class") -> "form") {
@helper.CSRF.formField