|
| 1 | +/* |
| 2 | + * Copyright 2026 HM Revenue & Customs |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +//package uk.gov.hmrc.formpproxy.sdlt.DONOTDELETE |
| 18 | +// |
| 19 | +//import org.scalatest.BeforeAndAfterEach |
| 20 | +//import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures} |
| 21 | +//import org.scalatest.matchers.must.Matchers |
| 22 | +//import org.scalatest.wordspec.AnyWordSpec |
| 23 | +//import org.scalatestplus.play.guice.GuiceOneAppPerSuite |
| 24 | +//import play.api.db.{DBApi, Database} |
| 25 | +//import uk.gov.hmrc.formpproxy.sdlt.models.GetReturnRecordsRequest |
| 26 | +//import uk.gov.hmrc.formpproxy.sdlt.repositories.SdltFormpRepository |
| 27 | +// |
| 28 | +//class GetReturnsOrderingIntegrationSpec |
| 29 | +// extends AnyWordSpec |
| 30 | +// with Matchers |
| 31 | +// with ScalaFutures |
| 32 | +// with IntegrationPatience |
| 33 | +// with GuiceOneAppPerSuite |
| 34 | +// with BeforeAndAfterEach { |
| 35 | +// |
| 36 | +// private def db: Database = |
| 37 | +// app.injector.instanceOf[DBApi].database("sdlt") |
| 38 | +// |
| 39 | +// private lazy val repo = app.injector.instanceOf[SdltFormpRepository] |
| 40 | +// |
| 41 | +// override protected def beforeEach(): Unit = { |
| 42 | +// super.beforeEach() |
| 43 | +// cleanupTestReturns() |
| 44 | +// setupTestReturns() |
| 45 | +// } |
| 46 | +// |
| 47 | +// "getReturns" should { |
| 48 | +// |
| 49 | +// "returns correct number of IN-PROGRESS returns ordered by last update date DESC" in { |
| 50 | +// val request = GetReturnRecordsRequest( |
| 51 | +// storn = "STN001", |
| 52 | +// status = None, |
| 53 | +// deletionFlag = false, |
| 54 | +// pageType = Some("IN-PROGRESS"), |
| 55 | +// pageNumber = None |
| 56 | +// ) |
| 57 | +// |
| 58 | +// val result = repo.sdltGetReturns(request).futureValue |
| 59 | +// |
| 60 | +// result.returnSummaryList.length mustBe 6 |
| 61 | +// result.returnSummaryList.map(_.returnReference) mustBe Seq("5", "6", "4", "1", "2", "3") |
| 62 | +// } |
| 63 | +// |
| 64 | +// "returns correct number of SUBMITTED returns ordered by submitted date DESC" in { |
| 65 | +// val request = GetReturnRecordsRequest( |
| 66 | +// storn = "STN001", |
| 67 | +// status = None, |
| 68 | +// deletionFlag = false, |
| 69 | +// pageType = Some("SUBMITTED"), |
| 70 | +// pageNumber = None |
| 71 | +// ) |
| 72 | +// |
| 73 | +// val result = repo.sdltGetReturns(request).futureValue |
| 74 | +// |
| 75 | +// result.returnSummaryList.length mustBe 3 |
| 76 | +// result.returnSummaryList.map(_.returnReference) mustBe Seq("8", "9", "7") |
| 77 | +// } |
| 78 | +// |
| 79 | +// "returns correct number of DUE-FOR-DELETION returns ordered by purge date ASC" in { |
| 80 | +// val request = GetReturnRecordsRequest( |
| 81 | +// storn = "STN001", |
| 82 | +// status = None, |
| 83 | +// deletionFlag = true, |
| 84 | +// pageType = Some("IN-PROGRESS"), |
| 85 | +// pageNumber = None |
| 86 | +// ) |
| 87 | +// |
| 88 | +// val result = repo.sdltGetReturns(request).futureValue |
| 89 | +// |
| 90 | +// result.returnSummaryList.length mustBe 3 |
| 91 | +// result.returnSummaryList.map(_.returnReference) mustBe Seq("4", "6", "5") |
| 92 | +// } |
| 93 | +// } |
| 94 | +// |
| 95 | +// private def setupTestReturns(): Unit = { |
| 96 | +// db.withConnection { conn => |
| 97 | +// val orgStatement = conn.prepareStatement( |
| 98 | +// """ |
| 99 | +// |INSERT INTO SDLT_FILE_DATA.SDLT_ORGANISATION (STORN, CREATE_DATE, LAST_UPDATE_DATE) |
| 100 | +// |VALUES (?, SYSDATE, SYSDATE)""".stripMargin |
| 101 | +// ) |
| 102 | +// |
| 103 | +// orgStatement.setString(1, "STN001") |
| 104 | +// orgStatement.execute() |
| 105 | +// orgStatement.close() |
| 106 | +// |
| 107 | +// val returnStatement = conn.prepareStatement( |
| 108 | +// """ |
| 109 | +// |INSERT INTO SDLT_FILE_DATA.RETURN (RETURN_ID, STORN, PURCHASER_COUNTER, VENDOR_COUNTER, LAND_COUNTER, PURGE_DATE, RETURN_RESOURCE_REF, STATUS, CREATE_DATE, LAST_UPDATE_DATE) |
| 110 | +// |VALUES (?, 'STN001', 1, 1, 1, TO_DATE(?, 'YYYY-MM-DD'), ?, ?, TO_DATE(?, 'YYYY-MM-DD'), TO_DATE(?, 'YYYY-MM-DD')) |
| 111 | +// |""".stripMargin |
| 112 | +// ) |
| 113 | +// |
| 114 | +// val returnTestData = Seq( |
| 115 | +// (1000001L, "2027-01-01", 1L, "STARTED", "2026-02-15", "2026-02-15"), // IN-PROGRESS |
| 116 | +// (1000002L, "2027-01-01", 2L, "ACCEPTED", "2026-02-10", "2026-02-10"), |
| 117 | +// (1000003L, "2027-01-01", 3L, "ACCEPTED", "2026-02-15", "2026-02-05"), |
| 118 | +// (1000004L, "2026-02-21", 4L, "STARTED", "2026-02-20", "2026-02-20"), // DUE-FOR-DELETION |
| 119 | +// (1000005L, "2026-03-01", 5L, "ACCEPTED", "2026-02-28", "2026-02-28"), |
| 120 | +// (1000006L, "2026-02-26", 6L, "STARTED", "2026-02-25", "2026-02-25"), |
| 121 | +// (1000007L, "2027-01-01", 7L, "SUBMITTED", "2026-02-08", "2026-02-08"), // SUBMITTED |
| 122 | +// (1000008L, "2027-01-01", 8L, "SUBMITTED", "2026-02-18", "2026-02-18"), |
| 123 | +// (1000009L, "2027-01-01", 9L, "SUBMITTED", "2026-02-13", "2026-02-13") |
| 124 | +// ) |
| 125 | +// |
| 126 | +// returnTestData.foreach { case (returnId, purgeDate, resourceRef, status, createdDate, lastUpdateDate) => |
| 127 | +// returnStatement.setLong(1, returnId) |
| 128 | +// returnStatement.setString(2, purgeDate) |
| 129 | +// returnStatement.setLong(3, resourceRef) |
| 130 | +// returnStatement.setString(4, status) |
| 131 | +// returnStatement.setString(5, createdDate) |
| 132 | +// returnStatement.setString(6, lastUpdateDate) |
| 133 | +// returnStatement.addBatch() |
| 134 | +// } |
| 135 | +// returnStatement.executeBatch() |
| 136 | +// returnStatement.close() |
| 137 | +// |
| 138 | +// val submissionStatement = conn.prepareStatement( |
| 139 | +// """ |
| 140 | +// |INSERT INTO SDLT_FILE_DATA.SUBMISSION (SUBMISSION_ID, RETURN_ID, STORN, SUBMITTED_DATE, CREATE_DATE, LAST_UPDATE_DATE) |
| 141 | +// |VALUES (?, ?, 'STN001', TO_DATE(?, 'YYYY-MM-DD'), TO_DATE(?, 'YYYY-MM-DD'), TO_DATE(?, 'YYYY-MM-DD')) |
| 142 | +// |""".stripMargin |
| 143 | +// ) |
| 144 | +// |
| 145 | +// val submissionTestData = Seq( |
| 146 | +// (2000001L, 1000007L, "2026-02-08", "2026-02-08", "2026-02-08"), |
| 147 | +// (2000002L, 1000008L, "2026-02-18", "2026-02-18", "2026-02-18"), |
| 148 | +// (2000003L, 1000009L, "2026-02-13", "2026-02-13", "2026-02-13") |
| 149 | +// ) |
| 150 | +// |
| 151 | +// submissionTestData.foreach { case (submissionId, returnId, submittedDate, createdDate, lastUpdateDate) => |
| 152 | +// submissionStatement.setLong(1, submissionId) |
| 153 | +// submissionStatement.setLong(2, returnId) |
| 154 | +// submissionStatement.setString(3, submittedDate) |
| 155 | +// submissionStatement.setString(4, createdDate) |
| 156 | +// submissionStatement.setString(5, lastUpdateDate) |
| 157 | +// submissionStatement.addBatch() |
| 158 | +// } |
| 159 | +// submissionStatement.executeBatch() |
| 160 | +// submissionStatement.close() |
| 161 | +// } |
| 162 | +// } |
| 163 | +// |
| 164 | +// private def cleanupTestReturns(): Unit = { |
| 165 | +// db.withConnection { conn => |
| 166 | +// val cleanupSubmissionsStatement = conn.prepareStatement( |
| 167 | +// """ |
| 168 | +// |DELETE FROM SDLT_FILE_DATA.SUBMISSION |
| 169 | +// |WHERE STORN = 'STN001' |
| 170 | +// |""".stripMargin |
| 171 | +// ) |
| 172 | +// cleanupSubmissionsStatement.execute() |
| 173 | +// cleanupSubmissionsStatement.close() |
| 174 | +// |
| 175 | +// val cleanupReturnsStatement = conn.prepareStatement( |
| 176 | +// """ |
| 177 | +// |DELETE FROM SDLT_FILE_DATA.RETURN |
| 178 | +// |WHERE STORN = 'STN001' |
| 179 | +// |""".stripMargin |
| 180 | +// ) |
| 181 | +// cleanupReturnsStatement.execute() |
| 182 | +// cleanupReturnsStatement.close() |
| 183 | +// |
| 184 | +// val cleanupOrgStatement = conn.prepareStatement( |
| 185 | +// """ |
| 186 | +// |DELETE FROM SDLT_FILE_DATA.SDLT_ORGANISATION |
| 187 | +// |WHERE STORN = 'STN001' |
| 188 | +// |""".stripMargin |
| 189 | +// ) |
| 190 | +// cleanupOrgStatement.execute() |
| 191 | +// cleanupOrgStatement.close() |
| 192 | +// } |
| 193 | +// } |
| 194 | +//} |
0 commit comments