Skip to content

Commit

Permalink
Merge pull request #987 from hmrc/DL-9601
Browse files Browse the repository at this point in the history
[DL-9601] - Remove 404 and add empty response to penalties endpoint
  • Loading branch information
derickdamoah authored Feb 1, 2023
2 parents d86dbe8 + 1cf36a8 commit fab5a09
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 93 deletions.
1 change: 0 additions & 1 deletion app/v1/connectors/httpparsers/PenaltiesHttpParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ object PenaltiesHttpParser extends Logging {
val mtdErrorsConvert = penaltiesErrors.failures.map{ error =>
(error.code) match {
case ("INVALID_IDVALUE") => PenaltiesInvalidIdValue
case ("NO_DATA_FOUND") => PenaltiesNotDataFound
case ("INVALID_REGIME") => DownstreamError
case ("INVALID_IDTYPE") => DownstreamError
case ("INVALID_DATELIMIT") => DownstreamError
Expand Down
27 changes: 0 additions & 27 deletions func/v1/endpoints/PenaltiesControllerISpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,33 +127,6 @@ class PenaltiesControllerISpec extends IntegrationBaseSpec {
}
}

"VRN is not found" must {

"return 404" in new Test {

val errorBody: JsValue = Json.parse(
"""
|{
|"failures": [{
| "code":"NO_DATA_FOUND",
| "reason":"Some Reason"
|}]
|}
|""".stripMargin)

override def setupStubs(): StubMapping = {
AuditStub.audit()
AuthStub.authorised()
PenaltiesStub.onError(PenaltiesStub.GET, PenaltiesConstants.penaltiesURl(), NOT_FOUND, errorBody)
}

val response: WSResponse = await(request.get())
response.status shouldBe NOT_FOUND
response.json shouldBe Json.toJson(PenaltiesNotDataFound)
response.header("Content-Type") shouldBe Some("application/json")
}
}

"unexpected error" must {

"return 500" in new Test {
Expand Down
65 changes: 0 additions & 65 deletions test/v1/connectors/httpparsers/PenaltiesHttpParserSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,33 +118,6 @@ class PenaltiesHttpParserSpec extends UnitSpec {
}
}

"response is NOT_FOUND (404)" must {

"return Left(VrnNotFound)" in {

val error = Json.parse(
"""
|{
|"failures": [{
|"code":"NO_DATA_FOUND",
|"reason":"Submission has not passed validation. Invalid parameter idType."
|}]
|}
|""".stripMargin)

val result = PenaltiesHttpReads.read("", "",
HttpResponse(
status = Status.NOT_FOUND,
json = error,
headers = Map(
"CorrelationId" -> Seq(PenaltiesConstants.correlationId)
)
)
)
result shouldBe Left(PenaltiesConstants.errorWrapper(PenaltiesNotDataFound))
}
}

"response is INTERNAL_SERVER_ERROR (500)" must {

"return Left(UnexpectedFailure)" in {
Expand Down Expand Up @@ -203,45 +176,7 @@ class PenaltiesHttpParserSpec extends UnitSpec {
)
result shouldBe Left(PenaltiesConstants.errorWrapper(MtdError("INTERNAL_SERVER_ERROR", "An internal server error occurred")))
}

"return 400 when multiple errors occur including a 400 only" in {

val status = Status.BAD_REQUEST

val error = Json.parse(
"""
|{
|"failures": [{
|"code":"INVALID_IDVALUE",
|"reason":"Something went wrong"
|},
|{
|"code":"NO_DATA_FOUND",
|"reason":"Submission has not passed validation. Invalid parameter idNumber."
|}]
|}
|""".stripMargin)

val result = PenaltiesHttpReads.read("", "",
HttpResponse(
status = status,
json = error,
headers = Map(
"CorrelationId" -> Seq(PenaltiesConstants.correlationId)
)
)
)

result shouldBe Left(PenaltiesConstants.errorWrapper(
MtdError("INVALID_REQUEST", "Invalid request penalties",
Some(Json.toJson(Seq(
MtdError("VRN_INVALID", "The provided VRN is invalid."),
MtdError("MATCHING_RESOURCE_NOT_FOUND", "No penalties could be found in the last 24 months"))))
))
)
}
}
}
}

}

0 comments on commit fab5a09

Please sign in to comment.