From 1cf36a88cd3353df404cf30366d8053a1a1bac53 Mon Sep 17 00:00:00 2001 From: Thepworth95 <56401451+Thepworth95@users.noreply.github.com> Date: Tue, 31 Jan 2023 12:27:39 +0000 Subject: [PATCH] remove 404 and add empty response to penalties endpoint --- .../httpparsers/PenaltiesHttpParser.scala | 1 - .../endpoints/PenaltiesControllerISpec.scala | 27 -------- .../httpparsers/PenaltiesHttpParserSpec.scala | 65 ------------------- 3 files changed, 93 deletions(-) diff --git a/app/v1/connectors/httpparsers/PenaltiesHttpParser.scala b/app/v1/connectors/httpparsers/PenaltiesHttpParser.scala index 9ff12c3f..e98b0ad0 100644 --- a/app/v1/connectors/httpparsers/PenaltiesHttpParser.scala +++ b/app/v1/connectors/httpparsers/PenaltiesHttpParser.scala @@ -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 diff --git a/func/v1/endpoints/PenaltiesControllerISpec.scala b/func/v1/endpoints/PenaltiesControllerISpec.scala index 9d10e2c7..de6315be 100644 --- a/func/v1/endpoints/PenaltiesControllerISpec.scala +++ b/func/v1/endpoints/PenaltiesControllerISpec.scala @@ -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 { diff --git a/test/v1/connectors/httpparsers/PenaltiesHttpParserSpec.scala b/test/v1/connectors/httpparsers/PenaltiesHttpParserSpec.scala index 7ad04400..45350d6a 100644 --- a/test/v1/connectors/httpparsers/PenaltiesHttpParserSpec.scala +++ b/test/v1/connectors/httpparsers/PenaltiesHttpParserSpec.scala @@ -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 { @@ -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")))) - )) - ) - } } } } - }