Skip to content

Commit

Permalink
SASS-9593: Renamed Task Title object for json validation purposes (#59)
Browse files Browse the repository at this point in the history
* SASS-9593: Renamed Task Title object for json validation purposes

* SASS-9593: Renamed GiltEdged Task Title object for json validation purposes
  • Loading branch information
ansahdavid authored Sep 2, 2024
1 parent be838f3 commit d591ef2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
7 changes: 3 additions & 4 deletions app/models/tasklist/TaskTitle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ object TaskTitle extends Enum[TaskTitle] with PlayJsonEnum[TaskTitle] {
val values: IndexedSeq[TaskTitle] = findValues

// UK Interest
case object BankAndBuildingSocieties extends TaskTitle("BankAndBuildingSocietiesTitle")
case object BanksAndBuilding extends TaskTitle("BanksAndBuildingTitle")

case object TrustFundBond extends TaskTitle("TrustFundBondTitle")

case object GiltEdgedOrAccrued extends TaskTitle("GiltEdgedOrAccruedTitle")

}
case object GiltEdged extends TaskTitle("GiltEdgedTitle")
}
4 changes: 2 additions & 2 deletions app/services/CommonTaskListService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ class CommonTaskListService @Inject()(appConfig: AppConfig,
s"${appConfig.personalFrontendBaseUrl}/update-and-submit-income-tax-return/personal-income/$taxYear/interest/check-interest-from-securities"

val bankAndBuildingSocieties: Option[TaskListSectionItem] = interest.untaxedUkInterest.map(_ =>
TaskListSectionItem(TaskTitle.BankAndBuildingSocieties, TaskStatus.Completed, Some(bankAndBuildingUrl)))
TaskListSectionItem(TaskTitle.BanksAndBuilding, TaskStatus.Completed, Some(bankAndBuildingUrl)))

val trustFundBond: Option[TaskListSectionItem] = interest.taxedUkInterest.map(_ =>
TaskListSectionItem(TaskTitle.TrustFundBond, TaskStatus.Completed, Some(trustFundUrl)))

val giltEdgedOrAccrued: Option[TaskListSectionItem] = savings.securities.map(_ =>
TaskListSectionItem(TaskTitle.GiltEdgedOrAccrued, TaskStatus.Completed, Some(giltEdgeUrl)))
TaskListSectionItem(TaskTitle.GiltEdged, TaskStatus.Completed, Some(giltEdgeUrl)))

Seq[Option[TaskListSectionItem]](bankAndBuildingSocieties, trustFundBond, giltEdgedOrAccrued).flatten
}
Expand Down
16 changes: 8 additions & 8 deletions test/models/taskList/TaskTitleSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class TaskTitleSpec extends AnyFreeSpec with Matchers {

"must contain the correct values" in {
TaskTitle.values mustEqual Seq[TaskTitle](
BankAndBuildingSocieties,
BanksAndBuilding,
TrustFundBond,
GiltEdgedOrAccrued
GiltEdged
)
}

Expand All @@ -43,10 +43,10 @@ class TaskTitleSpec extends AnyFreeSpec with Matchers {
"BankAndBuildingSocieties" - {

"must parse to and from json" in {
val underTest = Json.toJson(BankAndBuildingSocieties)
val underTest = Json.toJson(BanksAndBuilding)

underTest.toString() mustBe s"\"$BankAndBuildingSocieties\""
underTest.validate[TaskTitle] mustBe JsSuccess(BankAndBuildingSocieties, JsPath())
underTest.toString() mustBe s"\"$BanksAndBuilding\""
underTest.validate[TaskTitle] mustBe JsSuccess(BanksAndBuilding, JsPath())
}
}

Expand All @@ -63,10 +63,10 @@ class TaskTitleSpec extends AnyFreeSpec with Matchers {
"GiltEdgedOrAccrued" - {

"must parse to and from json" in {
val underTest = Json.toJson(GiltEdgedOrAccrued)
val underTest = Json.toJson(GiltEdged)

underTest.toString() mustBe s"\"$GiltEdgedOrAccrued\""
underTest.validate[TaskTitle] mustBe JsSuccess(GiltEdgedOrAccrued, JsPath())
underTest.toString() mustBe s"\"$GiltEdged\""
underTest.validate[TaskTitle] mustBe JsSuccess(GiltEdged, JsPath())
}
}
}
4 changes: 2 additions & 2 deletions test/services/CommonTaskListServiceSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ class CommonTaskListServiceSpec extends TestSuite {
val fullTaskSection: TaskListSection =
TaskListSection(SectionTitle.InterestTitle,
Some(List(
TaskListSectionItem(TaskTitle.BankAndBuildingSocieties, TaskStatus.Completed,
TaskListSectionItem(TaskTitle.BanksAndBuilding, TaskStatus.Completed,
Some("http://localhost:9308/update-and-submit-income-tax-return/personal-income/1234/interest/check-interest")),
TaskListSectionItem(TaskTitle.TrustFundBond, TaskStatus.Completed,
Some("http://localhost:9308/update-and-submit-income-tax-return/personal-income/1234/interest/check-interest")),
TaskListSectionItem(TaskTitle.GiltEdgedOrAccrued, TaskStatus.Completed,
TaskListSectionItem(TaskTitle.GiltEdged, TaskStatus.Completed,
Some("http://localhost:9308/update-and-submit-income-tax-return/personal-income/1234/interest/check-interest-from-securities")),
))
)
Expand Down

0 comments on commit d591ef2

Please sign in to comment.