Skip to content

Commit e255c06

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

13 files changed

Lines changed: 156 additions & 176 deletions

app/controllers/amend/WhatDoYouWantToAmendStandardController.scala

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package controllers.amend
1818

1919
import controllers.actions._
20-
import forms.WhatDoYouWantToAmendStandardFormProvider
20+
import forms.amend.WhatDoYouWantToAmendStandardFormProvider
2121
import javax.inject.Inject
2222
import models.Mode
2323
import navigation.Navigator
@@ -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/forms/WhatDoYouWantToAmendStandardFormProvider.scala renamed to app/forms/amend/WhatDoYouWantToAmendStandardFormProvider.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
package forms
17+
package forms.amend
1818

1919
import javax.inject.Inject
20-
2120
import forms.mappings.Mappings
2221
import play.api.data.Form
23-
import models.WhatDoYouWantToAmendStandard
22+
import models.amend.WhatDoYouWantToAmendStandard
2423

2524
class WhatDoYouWantToAmendStandardFormProvider @Inject() extends Mappings {
2625

app/models/WhatDoYouWantToAmendStandard.scala renamed to app/models/amend/WhatDoYouWantToAmendStandard.scala

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
package models
17+
package models.amend
1818

19+
import models.{Enumerable, WithName}
1920
import play.api.i18n.Messages
2021
import uk.gov.hmrc.govukfrontend.views.Aliases.Text
2122
import uk.gov.hmrc.govukfrontend.views.viewmodels.radios.RadioItem
@@ -25,19 +26,21 @@ sealed trait WhatDoYouWantToAmendStandard
2526
object WhatDoYouWantToAmendStandard extends Enumerable.Implicits {
2627

2728
case object AmendToNilReturn extends WithName("amendToNilReturn") with WhatDoYouWantToAmendStandard
28-
case object AmendPaymentOrSubcontractorDetails extends WithName("amendPaymentOrSubcontractorDetails") with WhatDoYouWantToAmendStandard
29+
case object AmendPaymentOrSubcontractorDetails
30+
extends WithName("amendPaymentOrSubcontractorDetails")
31+
with WhatDoYouWantToAmendStandard
2932

3033
val values: Seq[WhatDoYouWantToAmendStandard] = Seq(
31-
AmendToNilReturn, AmendPaymentOrSubcontractorDetails
34+
AmendToNilReturn,
35+
AmendPaymentOrSubcontractorDetails
3236
)
3337

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-
)
38+
def options(implicit messages: Messages): Seq[RadioItem] = values.zipWithIndex.map { case (value, index) =>
39+
RadioItem(
40+
content = Text(messages(s"amend.whatDoYouWantToAmendStandard.${value.toString}")),
41+
value = Some(value.toString),
42+
id = Some(s"value_$index")
43+
)
4144
}
4245

4346
implicit val enumerable: Enumerable[WhatDoYouWantToAmendStandard] =

app/pages/amend/WhatDoYouWantToAmendStandardPage.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package pages.amend
1818

19-
import models.WhatDoYouWantToAmendStandard
19+
import models.amend.WhatDoYouWantToAmendStandard
2020
import pages.QuestionPage
2121
import play.api.libs.json.JsPath
2222

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
}

app/views/amend/WhatDoYouWantToAmendStandardView.scala.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*@
1616

17+
@import models.amend.WhatDoYouWantToAmendStandard
18+
1719
@this(
1820
layout: templates.Layout,
1921
formHelper: FormWithCSRF,

test-utils/generators/ModelGenerators.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package generators
1818

19-
import models.WhatDoYouWantToAmendStandard
19+
import models.amend.WhatDoYouWantToAmendStandard
2020
import models.monthlyreturns.{Declaration, InactivityRequest}
2121
import org.scalacheck.{Arbitrary, Gen}
2222

test/controllers/amend/WhatDoYouWantToAmendStandardControllerSpec.scala

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
package controllers.amend
1818

1919
import base.SpecBase
20-
import forms.WhatDoYouWantToAmendStandardFormProvider
21-
import models.{NormalMode, WhatDoYouWantToAmendStandard, UserAnswers}
20+
import forms.amend.WhatDoYouWantToAmendStandardFormProvider
21+
import models.{NormalMode, UserAnswers}
22+
import models.amend.WhatDoYouWantToAmendStandard
2223
import navigation.{FakeNavigator, Navigator}
2324
import org.mockito.ArgumentMatchers.any
2425
import org.mockito.Mockito.when
@@ -40,7 +41,7 @@ class WhatDoYouWantToAmendStandardControllerSpec extends SpecBase with MockitoSu
4041
lazy val whatDoYouWantToAmendStandardRoute = routes.WhatDoYouWantToAmendStandardController.onPageLoad(NormalMode).url
4142

4243
val formProvider = new WhatDoYouWantToAmendStandardFormProvider()
43-
val form = formProvider()
44+
val form = formProvider()
4445

4546
"WhatDoYouWantToAmendStandard Controller" - {
4647

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

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

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

6771
val application = applicationBuilder(userAnswers = Some(userAnswers)).build()
6872

@@ -74,7 +78,10 @@ class WhatDoYouWantToAmendStandardControllerSpec extends SpecBase with MockitoSu
7478
val result = route(application, request).value
7579

7680
status(result) mustEqual OK
77-
contentAsString(result) mustEqual view(form.fill(WhatDoYouWantToAmendStandard.values.head), NormalMode)(request, messages(application)).toString
81+
contentAsString(result) mustEqual view(form.fill(WhatDoYouWantToAmendStandard.values.head), NormalMode)(
82+
request,
83+
messages(application)
84+
).toString
7885
}
7986
}
8087

test/forms/WhatDoYouWantToAmendStandardFormProviderSpec.scala

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package forms.amend
2+
3+
import forms.behaviours.OptionFieldBehaviours
4+
import models.amend.WhatDoYouWantToAmendStandard
5+
import play.api.data.FormError
6+
7+
class WhatDoYouWantToAmendStandardFormProviderSpec extends OptionFieldBehaviours {
8+
9+
val form = new WhatDoYouWantToAmendStandardFormProvider()()
10+
11+
".value" - {
12+
13+
val fieldName = "value"
14+
val requiredKey = "amend.whatDoYouWantToAmendStandard.error.required"
15+
16+
behave like optionsField[WhatDoYouWantToAmendStandard](
17+
form,
18+
fieldName,
19+
validValues = WhatDoYouWantToAmendStandard.values,
20+
invalidError = FormError(fieldName, "error.invalid")
21+
)
22+
23+
behave like mandatoryField(
24+
form,
25+
fieldName,
26+
requiredError = FormError(fieldName, requiredKey)
27+
)
28+
}
29+
}

0 commit comments

Comments
 (0)