Skip to content

Commit 9c4c994

Browse files
committed
[DTR-4543] Formatting fix
1 parent dacfee1 commit 9c4c994

7 files changed

Lines changed: 80 additions & 72 deletions

app/controllers/amend/WhatDoYouWantToAmendStandardController.scala

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,43 +30,43 @@ import views.html.amend.WhatDoYouWantToAmendStandardView
3030

3131
import scala.concurrent.{ExecutionContext, Future}
3232

33-
class WhatDoYouWantToAmendStandardController @Inject()(
34-
override val messagesApi: MessagesApi,
35-
sessionRepository: SessionRepository,
36-
navigator: Navigator,
37-
identify: IdentifierAction,
38-
getData: DataRetrievalAction,
39-
requireData: DataRequiredAction,
40-
formProvider: WhatDoYouWantToAmendStandardFormProvider,
41-
val controllerComponents: MessagesControllerComponents,
42-
view: WhatDoYouWantToAmendStandardView
43-
)(implicit ec: ExecutionContext) extends FrontendBaseController with I18nSupport {
33+
class WhatDoYouWantToAmendStandardController @Inject() (
34+
override val messagesApi: MessagesApi,
35+
sessionRepository: SessionRepository,
36+
navigator: Navigator,
37+
identify: IdentifierAction,
38+
getData: DataRetrievalAction,
39+
requireData: DataRequiredAction,
40+
formProvider: WhatDoYouWantToAmendStandardFormProvider,
41+
val controllerComponents: MessagesControllerComponents,
42+
view: WhatDoYouWantToAmendStandardView
43+
)(implicit ec: ExecutionContext)
44+
extends FrontendBaseController
45+
with I18nSupport {
4446

4547
val form = formProvider()
4648

47-
def onPageLoad(mode: Mode): Action[AnyContent] = (identify andThen getData andThen requireData) {
48-
implicit request =>
49+
def onPageLoad(mode: Mode): Action[AnyContent] = (identify andThen getData andThen requireData) { implicit request =>
4950

50-
val preparedForm = request.userAnswers.get(WhatDoYouWantToAmendStandardPage) match {
51-
case None => form
52-
case Some(value) => form.fill(value)
53-
}
51+
val preparedForm = request.userAnswers.get(WhatDoYouWantToAmendStandardPage) match {
52+
case None => form
53+
case Some(value) => form.fill(value)
54+
}
5455

55-
Ok(view(preparedForm, mode))
56+
Ok(view(preparedForm, mode))
5657
}
5758

5859
def onSubmit(mode: Mode): Action[AnyContent] = (identify andThen getData andThen requireData).async {
5960
implicit request =>
60-
61-
form.bindFromRequest().fold(
62-
formWithErrors =>
63-
Future.successful(BadRequest(view(formWithErrors, mode))),
64-
65-
value =>
66-
for {
67-
updatedAnswers <- Future.fromTry(request.userAnswers.set(WhatDoYouWantToAmendStandardPage, value))
68-
_ <- sessionRepository.set(updatedAnswers)
69-
} yield Redirect(navigator.nextPage(WhatDoYouWantToAmendStandardPage, mode, updatedAnswers))
70-
)
61+
form
62+
.bindFromRequest()
63+
.fold(
64+
formWithErrors => Future.successful(BadRequest(view(formWithErrors, mode))),
65+
value =>
66+
for {
67+
updatedAnswers <- Future.fromTry(request.userAnswers.set(WhatDoYouWantToAmendStandardPage, value))
68+
_ <- sessionRepository.set(updatedAnswers)
69+
} yield Redirect(navigator.nextPage(WhatDoYouWantToAmendStandardPage, mode, updatedAnswers))
70+
)
7171
}
7272
}

app/models/WhatDoYouWantToAmendStandard.scala

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,21 @@ sealed trait WhatDoYouWantToAmendStandard
2525
object WhatDoYouWantToAmendStandard extends Enumerable.Implicits {
2626

2727
case object AmendToNilReturn extends WithName("amendToNilReturn") with WhatDoYouWantToAmendStandard
28-
case object AmendPaymentOrSubcontractorDetails extends WithName("amendPaymentOrSubcontractorDetails") with WhatDoYouWantToAmendStandard
28+
case object AmendPaymentOrSubcontractorDetails
29+
extends WithName("amendPaymentOrSubcontractorDetails")
30+
with WhatDoYouWantToAmendStandard
2931

3032
val values: Seq[WhatDoYouWantToAmendStandard] = Seq(
31-
AmendToNilReturn, AmendPaymentOrSubcontractorDetails
33+
AmendToNilReturn,
34+
AmendPaymentOrSubcontractorDetails
3235
)
3336

34-
def options(implicit messages: Messages): Seq[RadioItem] = values.zipWithIndex.map {
35-
case (value, index) =>
36-
RadioItem(
37-
content = Text(messages(s"amend.whatDoYouWantToAmendStandard.${value.toString}")),
38-
value = Some(value.toString),
39-
id = Some(s"value_$index")
40-
)
37+
def options(implicit messages: Messages): Seq[RadioItem] = values.zipWithIndex.map { case (value, index) =>
38+
RadioItem(
39+
content = Text(messages(s"amend.whatDoYouWantToAmendStandard.${value.toString}")),
40+
value = Some(value.toString),
41+
id = Some(s"value_$index")
42+
)
4143
}
4244

4345
implicit val enumerable: Enumerable[WhatDoYouWantToAmendStandard] =

app/viewmodels/checkAnswers/amend/WhatDoYouWantToAmendStandardSummary.scala

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,24 @@ import uk.gov.hmrc.govukfrontend.views.viewmodels.summarylist.SummaryListRow
2626
import viewmodels.govuk.summarylist._
2727
import viewmodels.implicits._
2828

29-
object WhatDoYouWantToAmendStandardSummary {
29+
object WhatDoYouWantToAmendStandardSummary {
3030

3131
def row(answers: UserAnswers)(implicit messages: Messages): Option[SummaryListRow] =
32-
answers.get(WhatDoYouWantToAmendStandardPage).map {
33-
answer =>
32+
answers.get(WhatDoYouWantToAmendStandardPage).map { answer =>
3433

35-
val value = ValueViewModel(
36-
HtmlContent(
37-
HtmlFormat.escape(messages(s"amend.whatDoYouWantToAmendStandard.$answer"))
38-
)
34+
val value = ValueViewModel(
35+
HtmlContent(
36+
HtmlFormat.escape(messages(s"amend.whatDoYouWantToAmendStandard.$answer"))
3937
)
38+
)
4039

41-
SummaryListRowViewModel(
42-
key = "amend.whatDoYouWantToAmendStandard.checkYourAnswersLabel",
43-
value = value,
44-
actions = Seq(
45-
ActionItemViewModel("site.change", routes.WhatDoYouWantToAmendStandardController.onPageLoad(CheckMode).url)
46-
.withVisuallyHiddenText(messages("amend.whatDoYouWantToAmendStandard.change.hidden"))
47-
)
40+
SummaryListRowViewModel(
41+
key = "amend.whatDoYouWantToAmendStandard.checkYourAnswersLabel",
42+
value = value,
43+
actions = Seq(
44+
ActionItemViewModel("site.change", routes.WhatDoYouWantToAmendStandardController.onPageLoad(CheckMode).url)
45+
.withVisuallyHiddenText(messages("amend.whatDoYouWantToAmendStandard.change.hidden"))
4846
)
47+
)
4948
}
5049
}

test/controllers/amend/WhatDoYouWantToAmendStandardControllerSpec.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package controllers.amend
1818

1919
import base.SpecBase
2020
import forms.WhatDoYouWantToAmendStandardFormProvider
21-
import models.{NormalMode, WhatDoYouWantToAmendStandard, UserAnswers}
21+
import models.{NormalMode, UserAnswers, WhatDoYouWantToAmendStandard}
2222
import navigation.{FakeNavigator, Navigator}
2323
import org.mockito.ArgumentMatchers.any
2424
import org.mockito.Mockito.when
@@ -40,7 +40,7 @@ class WhatDoYouWantToAmendStandardControllerSpec extends SpecBase with MockitoSu
4040
lazy val whatDoYouWantToAmendStandardRoute = routes.WhatDoYouWantToAmendStandardController.onPageLoad(NormalMode).url
4141

4242
val formProvider = new WhatDoYouWantToAmendStandardFormProvider()
43-
val form = formProvider()
43+
val form = formProvider()
4444

4545
"WhatDoYouWantToAmendStandard Controller" - {
4646

@@ -62,7 +62,10 @@ class WhatDoYouWantToAmendStandardControllerSpec extends SpecBase with MockitoSu
6262

6363
"must populate the view correctly on a GET when the question has previously been answered" in {
6464

65-
val userAnswers = UserAnswers(userAnswersId).set(WhatDoYouWantToAmendStandardPage, WhatDoYouWantToAmendStandard.values.head).success.value
65+
val userAnswers = UserAnswers(userAnswersId)
66+
.set(WhatDoYouWantToAmendStandardPage, WhatDoYouWantToAmendStandard.values.head)
67+
.success
68+
.value
6669

6770
val application = applicationBuilder(userAnswers = Some(userAnswers)).build()
6871

@@ -74,7 +77,10 @@ class WhatDoYouWantToAmendStandardControllerSpec extends SpecBase with MockitoSu
7477
val result = route(application, request).value
7578

7679
status(result) mustEqual OK
77-
contentAsString(result) mustEqual view(form.fill(WhatDoYouWantToAmendStandard.values.head), NormalMode)(request, messages(application)).toString
80+
contentAsString(result) mustEqual view(form.fill(WhatDoYouWantToAmendStandard.values.head), NormalMode)(
81+
request,
82+
messages(application)
83+
).toString
7884
}
7985
}
8086

test/forms/WhatDoYouWantToAmendStandardFormProviderSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ class WhatDoYouWantToAmendStandardFormProviderSpec extends OptionFieldBehaviours
2626

2727
".value" - {
2828

29-
val fieldName = "value"
29+
val fieldName = "value"
3030
val requiredKey = "amend.whatDoYouWantToAmendStandard.error.required"
3131

3232
behave like optionsField[WhatDoYouWantToAmendStandard](
3333
form,
3434
fieldName,
35-
validValues = WhatDoYouWantToAmendStandard.values,
35+
validValues = WhatDoYouWantToAmendStandard.values,
3636
invalidError = FormError(fieldName, "error.invalid")
3737
)
3838

test/models/WhatDoYouWantToAmendStandardSpec.scala

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,41 @@ import org.scalatest.matchers.must.Matchers
2424
import org.scalatest.OptionValues
2525
import play.api.libs.json.{JsError, JsString, Json}
2626

27-
class WhatDoYouWantToAmendStandardSpec extends AnyFreeSpec with Matchers with ScalaCheckPropertyChecks with OptionValues {
27+
class WhatDoYouWantToAmendStandardSpec
28+
extends AnyFreeSpec
29+
with Matchers
30+
with ScalaCheckPropertyChecks
31+
with OptionValues {
2832

2933
"WhatDoYouWantToAmendStandard" - {
3034

3135
"must deserialise valid values" in {
3236

3337
val gen = Gen.oneOf(WhatDoYouWantToAmendStandard.values.toSeq)
3438

35-
forAll(gen) {
36-
whatDoYouWantToAmendStandard =>
37-
38-
JsString(whatDoYouWantToAmendStandard.toString).validate[WhatDoYouWantToAmendStandard].asOpt.value mustEqual whatDoYouWantToAmendStandard
39+
forAll(gen) { whatDoYouWantToAmendStandard =>
40+
JsString(whatDoYouWantToAmendStandard.toString)
41+
.validate[WhatDoYouWantToAmendStandard]
42+
.asOpt
43+
.value mustEqual whatDoYouWantToAmendStandard
3944
}
4045
}
4146

4247
"must fail to deserialise invalid values" in {
4348

4449
val gen = arbitrary[String] suchThat (!WhatDoYouWantToAmendStandard.values.map(_.toString).contains(_))
4550

46-
forAll(gen) {
47-
invalidValue =>
48-
49-
JsString(invalidValue).validate[WhatDoYouWantToAmendStandard] mustEqual JsError("error.invalid")
51+
forAll(gen) { invalidValue =>
52+
JsString(invalidValue).validate[WhatDoYouWantToAmendStandard] mustEqual JsError("error.invalid")
5053
}
5154
}
5255

5356
"must serialise" in {
5457

5558
val gen = Gen.oneOf(WhatDoYouWantToAmendStandard.values.toSeq)
5659

57-
forAll(gen) {
58-
whatDoYouWantToAmendStandard =>
59-
60-
Json.toJson(whatDoYouWantToAmendStandard) mustEqual JsString(whatDoYouWantToAmendStandard.toString)
60+
forAll(gen) { whatDoYouWantToAmendStandard =>
61+
Json.toJson(whatDoYouWantToAmendStandard) mustEqual JsString(whatDoYouWantToAmendStandard.toString)
6162
}
6263
}
6364
}

test/views/amend/WhatDoYouWantToAmendStandardViewSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class WhatDoYouWantToAmendStandardViewSpec extends SpecBase {
6262
val errorHtml = view(formWithErrors, NormalMode)
6363
val doc: Document = Jsoup.parse(errorHtml.toString)
6464

65-
doc.title must startWith(messages("error.title.prefix"))
65+
doc.title must startWith(messages("error.title.prefix"))
6666
doc.select(".govuk-error-summary").size() mustBe 1
6767
doc.text() must include(messages("amend.whatDoYouWantToAmendStandard.error.required"))
6868
}

0 commit comments

Comments
 (0)