Skip to content

Commit

Permalink
[MTDSA-9636] Create Marriage Allowance Alignment (#70)
Browse files Browse the repository at this point in the history
* [MTDSA-9636] Create Marriage Allowance Alignment

* [MTDSA-9636] Create Marriage Allowance Alignment Controller and GovTest Scenario

* [MTDSA-9636] Comments Addressed
  • Loading branch information
Nboaram authored Aug 17, 2021
1 parent 37f6111 commit 170a7ea
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 8 deletions.
17 changes: 12 additions & 5 deletions app/v1/controllers/CreateMarriageAllowanceController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,18 @@ class CreateMarriageAllowanceController @Inject()(val authService: EnrolmentsAut

private def errorResult(errorWrapper: ErrorWrapper) = {
(errorWrapper.error: @unchecked) match {
case BadRequestError | NinoFormatError | PartnerFirstNameFormatError | PartnerSurnameFormatError | PartnerNinoFormatError |
PartnerDoBFormatError | MtdErrorWithCustomMessage(RuleIncorrectOrEmptyBodyError.code) =>
BadRequest(Json.toJson(errorWrapper))
case RuleDeceasedRecipientError | RuleActiveMarriageAllowanceClaimError => Forbidden(Json.toJson(errorWrapper))
case DownstreamError => InternalServerError(Json.toJson(errorWrapper))
case BadRequestError |
NinoFormatError |
PartnerFirstNameFormatError |
PartnerSurnameFormatError |
PartnerNinoFormatError |
PartnerDoBFormatError |
MtdErrorWithCustomMessage(RuleIncorrectOrEmptyBodyError.code)
=> BadRequest(Json.toJson(errorWrapper))
case RuleDeceasedRecipientError |
RuleInvalidRequestError |
RuleActiveMarriageAllowanceClaimError => Forbidden(Json.toJson(errorWrapper))
case DownstreamError => InternalServerError(Json.toJson(errorWrapper))
}
}

Expand Down
5 changes: 5 additions & 0 deletions app/v1/models/errors/mtdErrors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ object RuleActiveMarriageAllowanceClaimError extends MtdError(
message = "Marriage Allowance has already been transferred to a spouse or civil partner"
)

object RuleInvalidRequestError extends MtdError(
code = "RULE_INVALID_REQUEST",
message = "The NINO supplied is invalid"
)

//Standard Errors
object NotFoundError extends MtdError(
code = "MATCHING_RESOURCE_NOT_FOUND",
Expand Down
2 changes: 1 addition & 1 deletion app/v1/services/CreateMarriageAllowanceService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CreateMarriageAllowanceService @Inject()(connector: CreateMarriageAllowanc
"END_DATE_CODE_NOT_FOUND" -> DownstreamError,
"INVALID_CORRELATIONID" -> DownstreamError,
"INVALID_PAYLOAD" -> DownstreamError,
"NINO_OR_TRN_NOT_FOUND" -> DownstreamError,
"NINO_OR_TRN_NOT_FOUND" -> RuleInvalidRequestError,
"INVALID_ACTUAL_END_DATE" -> DownstreamError,
"INVALID_PARTICIPANT_END_DATE" -> DownstreamError,
"INVALID_PARTICIPANT_START_DATE" -> DownstreamError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class CreateMarriageAllowanceControllerISpec extends IntegrationBaseSpec {
(BAD_REQUEST, "INVALID_PAYLOAD", INTERNAL_SERVER_ERROR, DownstreamError),
(BAD_REQUEST, "INVALID_CORRELATIONID", INTERNAL_SERVER_ERROR, DownstreamError),
(NOT_FOUND, "END_DATE_CODE_NOT_FOUND", INTERNAL_SERVER_ERROR, DownstreamError),
(NOT_FOUND, "NINO_OR_TRN_NOT_FOUND", INTERNAL_SERVER_ERROR, DownstreamError),
(NOT_FOUND, "NINO_OR_TRN_NOT_FOUND", FORBIDDEN, RuleInvalidRequestError),
(UNPROCESSABLE_ENTITY, "INVALID_ACTUAL_END_DATE", INTERNAL_SERVER_ERROR, DownstreamError),
(UNPROCESSABLE_ENTITY, "INVALID_PARTICIPANT_END_DATE", INTERNAL_SERVER_ERROR, DownstreamError),
(UNPROCESSABLE_ENTITY, "INVALID_PARTICIPANT_START_DATE", INTERNAL_SERVER_ERROR, DownstreamError),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ is:
- errors.ruleActiveMarriageAllowanceClaim
- errors.clientOrAgentNotAuthorised
- errors.incorrectOrEmptyBody
- errors.ruleInvalidRequest

displayName: Create Marriage Allowance
description: "This endpoint allows the customer to transfer up to £1,260 of their personal allowance to their spouse or civil partner. A National Insurance Number must be provided."
Expand Down
11 changes: 11 additions & 0 deletions resources/public/api/conf/1.0/errors.raml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ traits:
description: 'The specified tax year is not supported. That is, the tax year specified is before the minimum tax year value.'
value:
code: RULE_TAX_YEAR_NOT_SUPPORTED
ruleInvalidRequest:
responses:
403:
body:
application/json:
type: types.errorResponse
examples:
ruleInvalidRequest:
description: 'The request cannot be made as the current NINO supplied is invalid.'
value:
code: RULE_INVALID_REQUEST
ruleTaxYearRangeInvalid:
responses:
400:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@
<td><p>CLAIM_ALREADY_EXISTS</p></td>
<td><p>Simulates the scenario in which a Marriage Allowance claim already exists for the supplied NINO. </p></td>
</tr>
<tr>
<td><p>INVALID_REQUEST</p></td>
<td><p>Simulates the scenario in which a request cannot be made as the current NINO supplied is invalid.</p></td>
</tr>
</tbody>
</table>
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class CreateMarriageAllowanceControllerSpec
(NinoFormatError, BAD_REQUEST),
(RuleDeceasedRecipientError, FORBIDDEN),
(RuleActiveMarriageAllowanceClaimError, FORBIDDEN),
(RuleInvalidRequestError, FORBIDDEN),
(DownstreamError, INTERNAL_SERVER_ERROR)
)

Expand Down
2 changes: 1 addition & 1 deletion test/v1/services/CreateMarriageAllowanceServiceSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CreateMarriageAllowanceServiceSpec extends ServiceSpec {
("END_DATE_CODE_NOT_FOUND", DownstreamError),
("INVALID_CORRELATIONID", DownstreamError),
("INVALID_PAYLOAD", DownstreamError),
("NINO_OR_TRN_NOT_FOUND", DownstreamError),
("NINO_OR_TRN_NOT_FOUND", RuleInvalidRequestError),
("INVALID_ACTUAL_END_DATE", DownstreamError),
("INVALID_PARTICIPANT_END_DATE", DownstreamError),
("INVALID_PARTICIPANT_START_DATE", DownstreamError),
Expand Down

0 comments on commit 170a7ea

Please sign in to comment.