Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ hs_err_pid*
/ibanity-java.iml
/.idea/
/target/

.vscode/
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public class FinancialInstitutionResponseApiModel {
private Instant timestamp;
private String requestUri;
private Integer statusCode;
private String responseId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public class FinancialInstitutionResponse {
private Instant timestamp;
private String requestUri;
private Integer statusCode;
private String responseId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down