|
6 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
7 | 7 | import pl.akmf.ksef.sdk.api.builders.batch.OpenBatchSessionRequestBuilder; |
8 | 8 | import pl.akmf.ksef.sdk.api.services.DefaultCryptographyService; |
9 | | -import pl.akmf.ksef.sdk.client.ExceptionDetails; |
10 | 9 | import pl.akmf.ksef.sdk.client.model.ApiException; |
11 | | -import pl.akmf.ksef.sdk.client.model.ExceptionResponse; |
12 | 10 | import pl.akmf.ksef.sdk.client.model.UpoVersion; |
| 11 | +import pl.akmf.ksef.sdk.client.model.exceptions.BadRequestApiError; |
| 12 | +import pl.akmf.ksef.sdk.client.model.exceptions.BadRequestApiException; |
| 13 | +import pl.akmf.ksef.sdk.client.model.exceptions.BadRequestProblemDetails; |
13 | 14 | import pl.akmf.ksef.sdk.client.model.session.EncryptionData; |
14 | 15 | import pl.akmf.ksef.sdk.client.model.session.EncryptionInfo; |
15 | 16 | import pl.akmf.ksef.sdk.client.model.session.FileMetadata; |
@@ -187,12 +188,13 @@ void shouldThrowWhileSendWithExceededTotalPackageSize() throws JAXBException, IO |
187 | 188 | // API KSeF powinno odrzucić żądanie ze względu na przekroczony limit fileSize |
188 | 189 | ApiException apiException = assertThrows(ApiException.class, () -> |
189 | 190 | ksefClient.openBatchSession(request, UpoVersion.UPO_4_3, accessToken)); |
190 | | - ExceptionResponse exceptionResponse = apiException.getExceptionResponse(); |
191 | | - Assertions.assertFalse(exceptionResponse.getException().getExceptionDetailList().isEmpty()); |
192 | | - ExceptionDetails details = exceptionResponse.getException().getExceptionDetailList().getFirst(); |
193 | | - Assertions.assertEquals(21405, details.getExceptionCode()); |
194 | | - Assertions.assertEquals("Błąd walidacji danych wejściowych.", details.getExceptionDescription()); |
195 | | - Assertions.assertEquals("'fileSize' must be less than or equal to '5000000000'.", details.getDetails().getFirst()); |
| 191 | + BadRequestApiException badRequestApiException = (BadRequestApiException) apiException; |
| 192 | + BadRequestProblemDetails exceptionResponse = badRequestApiException.getBadRequestProblemDetails(); |
| 193 | + Assertions.assertFalse(exceptionResponse.getErrors().isEmpty()); |
| 194 | + BadRequestApiError error = exceptionResponse.getErrors().getFirst(); |
| 195 | + Assertions.assertEquals(21405, error.getCode()); |
| 196 | + Assertions.assertEquals("Błąd walidacji danych wejściowych.", error.getDescription()); |
| 197 | + Assertions.assertEquals("'fileSize' must be less than or equal to '5000000000'.", error.getDetails().getFirst()); |
196 | 198 | } |
197 | 199 |
|
198 | 200 | // Weryfikuje odrzucenie paczki przekraczającej limit rozmiaru 100 MiB (przed szyfrowaniem). |
@@ -287,12 +289,13 @@ void shouldThrowWhileCloseSessionWithoutAllParts() throws JAXBException, IOExcep |
287 | 289 |
|
288 | 290 | ApiException apiException = assertThrows(ApiException.class, () -> |
289 | 291 | closeSession(sessionReferenceNumber, accessToken)); |
290 | | - ExceptionResponse exceptionResponse = apiException.getExceptionResponse(); |
291 | | - Assertions.assertFalse(exceptionResponse.getException().getExceptionDetailList().isEmpty()); |
292 | | - ExceptionDetails details = exceptionResponse.getException().getExceptionDetailList().getFirst(); |
293 | | - Assertions.assertEquals(21205, details.getExceptionCode()); |
294 | | - Assertions.assertEquals("Pakiet nie może być pusty.", details.getExceptionDescription()); |
295 | | - Assertions.assertEquals("Nie przesłano zadeklarowanej '2' części pliku.", details.getDetails().getFirst()); |
| 292 | + BadRequestApiException badRequestApiException = (BadRequestApiException) apiException; |
| 293 | + BadRequestProblemDetails exceptionResponse = badRequestApiException.getBadRequestProblemDetails(); |
| 294 | + Assertions.assertFalse(exceptionResponse.getErrors().isEmpty()); |
| 295 | + BadRequestApiError error = exceptionResponse.getErrors().getFirst(); |
| 296 | + Assertions.assertEquals(21205, error.getCode()); |
| 297 | + Assertions.assertEquals("Pakiet nie może być pusty.", error.getDescription()); |
| 298 | + Assertions.assertEquals("Nie przesłano zadeklarowanej '2' części pliku.", error.getDetails().getFirst()); |
296 | 299 | } |
297 | 300 |
|
298 | 301 | // Weryfikuje odrzucenie paczki z liczbą części przekraczającą maksymalny limit 50. |
@@ -325,12 +328,13 @@ void shouldThrowWhileSendWithExceededPartCount() throws JAXBException, IOExcepti |
325 | 328 | // API KSeF odrzuca żądanie z przekroczoną liczbą części |
326 | 329 | ApiException apiException = assertThrows(ApiException.class, () -> |
327 | 330 | ksefClient.openBatchSession(request, UpoVersion.UPO_4_3, accessToken)); |
328 | | - ExceptionResponse exceptionResponse = apiException.getExceptionResponse(); |
329 | | - Assertions.assertFalse(exceptionResponse.getException().getExceptionDetailList().isEmpty()); |
330 | | - ExceptionDetails details = exceptionResponse.getException().getExceptionDetailList().getFirst(); |
331 | | - Assertions.assertEquals(21161, details.getExceptionCode()); |
332 | | - Assertions.assertEquals("Przekroczono dozwoloną liczbę części pakietów.", details.getExceptionDescription()); |
333 | | - Assertions.assertEquals("Liczba części pliku musi być mniejsza lub równa niż 50.", details.getDetails().getFirst()); |
| 331 | + BadRequestApiException badRequestApiException = (BadRequestApiException) apiException; |
| 332 | + BadRequestProblemDetails exceptionResponse = badRequestApiException.getBadRequestProblemDetails(); |
| 333 | + Assertions.assertFalse(exceptionResponse.getErrors().isEmpty()); |
| 334 | + BadRequestApiError error = exceptionResponse.getErrors().getFirst(); |
| 335 | + Assertions.assertEquals(21161, error.getCode()); |
| 336 | + Assertions.assertEquals("Przekroczono dozwoloną liczbę części pakietów.", error.getDescription()); |
| 337 | + Assertions.assertEquals("Liczba części pliku musi być mniejsza lub równa niż 50.", error.getDetails().getFirst()); |
334 | 338 | } |
335 | 339 |
|
336 | 340 | // Weryfikuje wykrycie nieprawidłowo zaszyfrowanego klucza symetrycznego. |
|
0 commit comments