From bdf232430c260903d3b31db6941068d33fc37e2f Mon Sep 17 00:00:00 2001 From: Kevin Strijbos Date: Thu, 17 Apr 2025 15:33:19 +0200 Subject: [PATCH 1/2] Add response ID field --- .gitignore | 2 + .../FinancialInstitutionResponseApiModel.java | 1 + .../client/mappers/IbanityErrorMapper.java | 1 + .../models/FinancialInstitutionResponse.java | 1 + .../handler/IbanityResponseHandlerTest.java | 50 +++++++++++++++++++ 5 files changed, 55 insertions(+) diff --git a/.gitignore b/.gitignore index c09aa5cb..2b0d9d19 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ hs_err_pid* /ibanity-java.iml /.idea/ /target/ + +.vscode/ \ No newline at end of file diff --git a/src/main/java/com/ibanity/apis/client/jsonapi/FinancialInstitutionResponseApiModel.java b/src/main/java/com/ibanity/apis/client/jsonapi/FinancialInstitutionResponseApiModel.java index 9c744924..765215cc 100644 --- a/src/main/java/com/ibanity/apis/client/jsonapi/FinancialInstitutionResponseApiModel.java +++ b/src/main/java/com/ibanity/apis/client/jsonapi/FinancialInstitutionResponseApiModel.java @@ -17,4 +17,5 @@ public class FinancialInstitutionResponseApiModel { private Instant timestamp; private String requestUri; private Integer statusCode; + private String responseId; } diff --git a/src/main/java/com/ibanity/apis/client/mappers/IbanityErrorMapper.java b/src/main/java/com/ibanity/apis/client/mappers/IbanityErrorMapper.java index 901a48c3..6adcd6dc 100644 --- a/src/main/java/com/ibanity/apis/client/mappers/IbanityErrorMapper.java +++ b/src/main/java/com/ibanity/apis/client/mappers/IbanityErrorMapper.java @@ -25,6 +25,7 @@ public static IbanityError map(IbanityErrorApiModel ibanityErrorApiModel) { .statusCode(financialInstitutionResponseApiModel.getStatusCode()) .body(parseBody(financialInstitutionResponseApiModel)) .requestId(financialInstitutionResponseApiModel.getRequestId()) + .responseId(financialInstitutionResponseApiModel.getResponseId()) .timestamp(financialInstitutionResponseApiModel.getTimestamp()) .build(); errorMetaBuilder.financialInstitutionResponse(financialInstitutionResponse); diff --git a/src/main/java/com/ibanity/apis/client/models/FinancialInstitutionResponse.java b/src/main/java/com/ibanity/apis/client/models/FinancialInstitutionResponse.java index 1c92ec6f..29518ade 100644 --- a/src/main/java/com/ibanity/apis/client/models/FinancialInstitutionResponse.java +++ b/src/main/java/com/ibanity/apis/client/models/FinancialInstitutionResponse.java @@ -17,4 +17,5 @@ public class FinancialInstitutionResponse { private Instant timestamp; private String requestUri; private Integer statusCode; + private String responseId; } diff --git a/src/test/java/com/ibanity/apis/client/http/handler/IbanityResponseHandlerTest.java b/src/test/java/com/ibanity/apis/client/http/handler/IbanityResponseHandlerTest.java index ea89ef3b..ee372de1 100644 --- a/src/test/java/com/ibanity/apis/client/http/handler/IbanityResponseHandlerTest.java +++ b/src/test/java/com/ibanity/apis/client/http/handler/IbanityResponseHandlerTest.java @@ -57,6 +57,25 @@ void handleResponse_whenServerError_thenThrowIbanityServerSideException() { assertThat(actual).isEqualToComparingFieldByFieldRecursively(new IbanityServerException(createExpectedErrorsWithJson(), 500, REQUEST_ID)); } + @Test + void handleResponse_whenServerErrorWithResponseID_thenThrowIbanityServiceSideExceptionWithResponseID() { + // language=JSON + String expected = errorPayloadWithResponseIdJson(); + + when(httpResponse.getEntity()).thenReturn(EntityBuilder.create().setText(expected).build()); + when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(dummyProtocolVersion(), 500, "")); + when(httpResponse.getFirstHeader(IBANITY_REQUEST_ID_HEADER)) + .thenReturn(new BasicHeader(IBANITY_REQUEST_ID_HEADER, REQUEST_ID)); + + IbanityServerException actual = assertThrows(IbanityServerException.class, + () -> ibanityResponseHandler.handleResponse(httpResponse)); + + actual.getErrors().forEach(error -> + assertThat(error.getMeta().getFinancialInstitutionResponse().getResponseId()) + .isEqualTo("gdhed515hrtzehg") + ); + } + @Test void handleResponse_whenResourceNotFound_thenThrowIbanityClientSideException() { //language=JSON @@ -160,6 +179,37 @@ private String errorPayloadWithJson() { "}"; } + private String errorPayloadWithResponseIdJson() { + //language=JSON + return "{\n" + + " \"errors\": [\n" + + " {\n" + + " \"code\": \"invalidCredentials\",\n" + + " \"detail\": \"Your credentials are invalid.\",\n" + + " \"meta\": {\n" + + " \"financialInstitutionResponse\": {\n" + + " \"statusCode\": 500,\n" + + " \"body\": {\n" + + " \"tppMessages\": [\n" + + " {\n" + + " \"category\": \"ERROR\",\n" + + " \"code\": \"NOT_FOUND\",\n" + + " \"text\": \"3.2 - Not Found\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"requestId\": \"354fwfwef4w684\",\n" + + " \"responseId\": \"gdhed515hrtzehg\",\n" + + " \"timestamp\": \"2019-05-09T09:18:00.000Z\",\n" + + " \"requestUri\": \"http://google.com\"\n" + + " }\n" + + " " + + "}\n" + + " }\n" + + " ]\n" + + "}"; + } + private ProtocolVersion dummyProtocolVersion() { return new ProtocolVersion("", 0, 0); } From 000c58d85e07be7aa25034f0cc1140fbebf6d856 Mon Sep 17 00:00:00 2001 From: Kevin Strijbos Date: Thu, 17 Apr 2025 15:38:29 +0200 Subject: [PATCH 2/2] Remove caching from build --- .github/workflows/coverage.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index dca91276..bd876e2f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -13,18 +13,6 @@ jobs: uses: actions/setup-java@v1 with: java-version: 20 - - name: Cache Maven packages - uses: actions/cache@v1 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - name: Cache SonarCloud packages - uses: actions/cache@v1 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - name: Build and analyze run: mvn -B verify -DskipTests=true -Dgpg.skip -Dmaven.javadoc.skip=true org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Pcoverage env: