Skip to content

Commit

Permalink
fix: Fixed name of Max-Retries header in closePayment (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsabacn authored Apr 4, 2023
1 parent d82d4ab commit e4202c4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class PaymentResource extends BasePaymentResource {
EventBus bus;

/**
* The value of the Max-Retry header to be sent in response to the closePayment API
* The value of the Max-Retries header to be sent in response to the closePayment API
*/
@ConfigProperty(name="paymentnotice.closepayment.max-retry", defaultValue = "3")
int closePaymentMaxRetry;
Expand Down Expand Up @@ -286,7 +286,7 @@ else if (error instanceof TimeoutException) {
responseBuilder
.location(URI.create(closePaymentLocationBaseURL + "/payments/" + closePaymentRequest.getTransactionId()))
.header("Retry-After", closePaymentRetryAfter)
.header("Max-Retry", closePaymentMaxRetry);
.header("Max-Retries", closePaymentMaxRetry);
}
else {
closePaymentResponse.setOutcome(Outcome.KO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ void testClosePayment_200_node200_OK() {
Assertions.assertEquals(Outcome.OK.name(), response.jsonPath().getString("outcome"));
Assertions.assertTrue(response.getHeader("Location") != null &&
response.getHeader("Location").endsWith("/" + closePaymentRequestOK.getTransactionId()));
Assertions.assertNotNull(response.getHeader("Retry-after"));
Assertions.assertNotNull(response.getHeader("Max-Retry"));
Assertions.assertNotNull(response.getHeader("Retry-After"));
Assertions.assertNotNull(response.getHeader("Max-Retries"));

//check of milRestService clients
ArgumentCaptor<String> captorRequestId = ArgumentCaptor.forClass(String.class);
Expand Down Expand Up @@ -180,8 +180,8 @@ void testClosePayment_200_node200_KO() {
Assertions.assertNull(response.jsonPath().getJsonObject("errors"));
Assertions.assertEquals(Outcome.KO.name(), response.jsonPath().getString("outcome"));
Assertions.assertNull(response.getHeader("Location"));
Assertions.assertNull(response.getHeader("Retry-after"));
Assertions.assertNull(response.getHeader("Max-Retry"));
Assertions.assertNull(response.getHeader("Retry-After"));
Assertions.assertNull(response.getHeader("Max-Retries"));

}

Expand Down Expand Up @@ -223,8 +223,8 @@ void testClosePayment_200_nodeError_KO(int statusCode) {
Assertions.assertNull(response.jsonPath().getJsonObject("errors"));
Assertions.assertEquals(Outcome.KO.name(), response.jsonPath().getString("outcome"));
Assertions.assertNull(response.getHeader("Location"));
Assertions.assertNull(response.getHeader("Retry-after"));
Assertions.assertNull(response.getHeader("Max-Retry"));
Assertions.assertNull(response.getHeader("Retry-After"));
Assertions.assertNull(response.getHeader("Max-Retries"));

}

Expand Down Expand Up @@ -267,8 +267,8 @@ void testClosePayment_200_nodeError_OK(int status) {
Assertions.assertEquals(Outcome.OK.name(), response.jsonPath().getString("outcome"));
Assertions.assertTrue(response.getHeader("Location") != null &&
response.getHeader("Location").endsWith("/" + closePaymentRequestOK.getTransactionId()));
Assertions.assertNotNull(response.getHeader("Retry-after"));
Assertions.assertNotNull(response.getHeader("Max-Retry"));
Assertions.assertNotNull(response.getHeader("Retry-After"));
Assertions.assertNotNull(response.getHeader("Max-Retries"));

}

Expand Down Expand Up @@ -382,8 +382,8 @@ void testClosePayment_500_otherCases() {
Assertions.assertTrue(response.jsonPath().getList("errors").contains(ErrorCode.ERROR_CALLING_NODE_REST_SERVICES));
Assertions.assertNull(response.jsonPath().getJsonObject("outcome"));
Assertions.assertNull(response.getHeader("Location"));
Assertions.assertNull(response.getHeader("Retry-after"));
Assertions.assertNull(response.getHeader("Max-Retry"));
Assertions.assertNull(response.getHeader("Retry-After"));
Assertions.assertNull(response.getHeader("Max-Retries"));

}

Expand Down Expand Up @@ -421,8 +421,8 @@ void testClosePayment_200_nodeTimeout() {
Assertions.assertNotNull(response.getHeader("Location"));
Assertions.assertTrue(response.getHeader("Location") != null &&
response.getHeader("Location").endsWith("/" + closePaymentRequestOK.getTransactionId()));
Assertions.assertNotNull(response.getHeader("Retry-after"));
Assertions.assertNotNull(response.getHeader("Max-Retry"));
Assertions.assertNotNull(response.getHeader("Retry-After"));
Assertions.assertNotNull(response.getHeader("Max-Retries"));

}

Expand All @@ -449,8 +449,8 @@ void testClosePayment_500_milError(ExceptionType exceptionType, String errorCode
Assertions.assertTrue(response.jsonPath().getList("errors").contains(errorCode));
Assertions.assertNull(response.jsonPath().getJsonObject("outcome"));
Assertions.assertNull(response.getHeader("Location"));
Assertions.assertNull(response.getHeader("Retry-after"));
Assertions.assertNull(response.getHeader("Max-Retry"));
Assertions.assertNull(response.getHeader("Retry-After"));
Assertions.assertNull(response.getHeader("Max-Retries"));

}

Expand Down Expand Up @@ -482,8 +482,8 @@ void testClosePayment_500_redisKo() {
Assertions.assertTrue(response.jsonPath().getList("errors").contains(ErrorCode.ERROR_STORING_DATA_INTO_REDIS));
Assertions.assertNull(response.jsonPath().getJsonObject("outcome"));
Assertions.assertNull(response.getHeader("Location"));
Assertions.assertNull(response.getHeader("Retry-after"));
Assertions.assertNull(response.getHeader("Max-Retry"));
Assertions.assertNull(response.getHeader("Retry-After"));
Assertions.assertNull(response.getHeader("Max-Retries"));

}

Expand Down Expand Up @@ -576,8 +576,8 @@ void testClosePaymentOK_200_nodeUnparsable() {
Assertions.assertNotNull(response.getHeader("Location"));
Assertions.assertTrue(response.getHeader("Location") != null &&
response.getHeader("Location").endsWith("/" + closePaymentRequestOK.getTransactionId()));
Assertions.assertNotNull(response.getHeader("Retry-after"));
Assertions.assertNotNull(response.getHeader("Max-Retry"));
Assertions.assertNotNull(response.getHeader("Retry-After"));
Assertions.assertNotNull(response.getHeader("Max-Retries"));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ void testClosePayment_200_node200_OK() {
Assertions.assertEquals(Outcome.OK.name(), response.jsonPath().getString("outcome"));
Assertions.assertTrue(response.getHeader("Location") != null &&
response.getHeader("Location").endsWith("/" + PaymentTestData.PAY_TID_NODE_OK));
Assertions.assertNotNull(response.getHeader("Retry-after"));
Assertions.assertNotNull(response.getHeader("Max-Retry"));
Assertions.assertNotNull(response.getHeader("Retry-After"));
Assertions.assertNotNull(response.getHeader("Max-Retries"));

}

Expand All @@ -128,8 +128,8 @@ void testClosePayment_200_node200_KO() {
Assertions.assertNull(response.jsonPath().getJsonObject("errors"));
Assertions.assertEquals(Outcome.KO.name(), response.jsonPath().getString("outcome"));
Assertions.assertNull(response.getHeader("Location"));
Assertions.assertNull(response.getHeader("Retry-after"));
Assertions.assertNull(response.getHeader("Max-Retry"));
Assertions.assertNull(response.getHeader("Retry-After"));
Assertions.assertNull(response.getHeader("Max-Retries"));

}

Expand Down Expand Up @@ -160,8 +160,8 @@ void testClosePayment_200_nodeError_KO(String paymentTransactionId) {
Assertions.assertNull(response.jsonPath().getJsonObject("errors"));
Assertions.assertEquals(Outcome.KO.name(), response.jsonPath().getString("outcome"));
Assertions.assertNull(response.getHeader("Location"));
Assertions.assertNull(response.getHeader("Retry-after"));
Assertions.assertNull(response.getHeader("Max-Retry"));
Assertions.assertNull(response.getHeader("Retry-After"));
Assertions.assertNull(response.getHeader("Max-Retries"));

}

Expand Down Expand Up @@ -195,8 +195,8 @@ void testClosePayment_200_nodeError_OK(String paymentTransactionId) {
Assertions.assertEquals(Outcome.OK.name(), response.jsonPath().getString("outcome"));
Assertions.assertTrue(response.getHeader("Location") != null &&
response.getHeader("Location").endsWith("/" + paymentTransactionId));
Assertions.assertNotNull(response.getHeader("Retry-after"));
Assertions.assertNotNull(response.getHeader("Max-Retry"));
Assertions.assertNotNull(response.getHeader("Retry-After"));
Assertions.assertNotNull(response.getHeader("Max-Retries"));

}

Expand Down Expand Up @@ -226,8 +226,8 @@ void testClosePayment_200_nodeTimeout() {
Assertions.assertNotNull(response.getHeader("Location"));
Assertions.assertTrue(response.getHeader("Location") != null &&
response.getHeader("Location").endsWith("/" + PaymentTestData.PAY_TID_NODE_TIMEOUT));
Assertions.assertNotNull(response.getHeader("Retry-after"));
Assertions.assertNotNull(response.getHeader("Max-Retry"));
Assertions.assertNotNull(response.getHeader("Retry-After"));
Assertions.assertNotNull(response.getHeader("Max-Retries"));

}

Expand Down
23 changes: 23 additions & 0 deletions src/test/postman/Payment_Notice_Service.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -9613,6 +9613,17 @@
" pm.expect(jsonData.outcome).to.eql(\"OK\");\r",
"});\r",
"\r",
"pm.test(\"Max-Retries header is present\", function () {\r",
" pm.expect(pm.response.to.have.header(\"Max-Retries\"));\r",
"});\r",
"\r",
"pm.test(\"Retry-After header is present\", function () {\r",
" pm.expect(pm.response.to.have.header(\"Retry-After\"));\r",
"});\r",
"\r",
"pm.test(\"Location header is present\", function () {\r",
" pm.expect(pm.response.to.have.header(\"Location\"));\r",
"});\r",
""
],
"type": "text/javascript"
Expand Down Expand Up @@ -10163,6 +10174,18 @@
" pm.expect(jsonData.outcome).to.eql(\"OK\");\r",
"});\r",
"\r",
"pm.test(\"Max-Retries header is present\", function () {\r",
" pm.expect(pm.response.to.have.header(\"Max-Retries\"));\r",
"});\r",
"\r",
"pm.test(\"Retry-After header is present\", function () {\r",
" pm.expect(pm.response.to.have.header(\"Retry-After\"));\r",
"});\r",
"\r",
"pm.test(\"Location header is present\", function () {\r",
" pm.expect(pm.response.to.have.header(\"Location\"));\r",
"});\r",
"\r",
""
],
"type": "text/javascript"
Expand Down

0 comments on commit e4202c4

Please sign in to comment.