From b75468b37f3f6941a23e8bb172b4ee166c531881 Mon Sep 17 00:00:00 2001 From: Davide Vacca Date: Thu, 29 Jan 2026 13:58:20 +0100 Subject: [PATCH 1/2] feat: adapt tests for useSingleRequestParameter pattern Update all test files to use the new request builder pattern with .execute() calls. This change supports the useSingleRequestParameter OpenAPI Generator option which prevents breaking changes when adding optional parameters to API methods. Key changes: - Updated TestBase helper methods to call .execute() on API request objects - Fixed reflection-based helpers (repeatRequestUntilStatusChanges, etc.) - Updated all integration test files to use the new pattern - Modified API calls from direct invocation to builder pattern with .execute() Example: - Before: onfido.findApplicant(id) - After: onfido.findApplicant(id).execute() All 107 tests passing. --- src/test/java/com/onfido/OnfidoTest.java | 6 +- .../com/onfido/integration/AddressTest.java | 2 +- .../AdvancedElectronicSignatureTest.java | 8 +-- .../com/onfido/integration/ApplicantTest.java | 18 +++--- .../com/onfido/integration/CheckTest.java | 6 +- .../com/onfido/integration/DocumentTest.java | 14 ++--- .../onfido/integration/ExtractionTest.java | 2 +- .../com/onfido/integration/IdPhotoTest.java | 8 +-- .../com/onfido/integration/LivePhotoTest.java | 8 +-- .../com/onfido/integration/LiveVideoTest.java | 10 +-- .../onfido/integration/MotionCaptureTest.java | 10 +-- .../java/com/onfido/integration/PingTest.java | 2 +- .../QualifiedElectronicSignatureTest.java | 6 +- .../com/onfido/integration/ReportTest.java | 10 +-- .../com/onfido/integration/SdkTokenTest.java | 2 +- .../integration/SigningDocumentTest.java | 10 +-- .../com/onfido/integration/TasksTest.java | 10 +-- .../java/com/onfido/integration/TestBase.java | 61 +++++++++++-------- .../integration/WatchlistMonitorTest.java | 10 +-- .../com/onfido/integration/WebhookTest.java | 10 +-- .../integration/WorkflowRunOutputsTest.java | 10 +-- .../onfido/integration/WorkflowRunTest.java | 10 +-- 22 files changed, 124 insertions(+), 109 deletions(-) diff --git a/src/test/java/com/onfido/OnfidoTest.java b/src/test/java/com/onfido/OnfidoTest.java index 963b585a..b22a31ea 100644 --- a/src/test/java/com/onfido/OnfidoTest.java +++ b/src/test/java/com/onfido/OnfidoTest.java @@ -27,7 +27,8 @@ public void throwsExceptionForMissingApiToken() { ApiException.class, () -> new DefaultApi(apiClient) - .findApplicant(UUID.fromString("839d4812-7c49-4008-8d83-bbd7610f0fec")), + .findApplicant(UUID.fromString("839d4812-7c49-4008-8d83-bbd7610f0fec")) + .execute(), "Expected to throw, but it didn't"); assertTrue(thrown.getMessage().contains("authorization_error")); @@ -40,7 +41,8 @@ public void throwsExceptionForNullApiToken() { ApiException.class, () -> new DefaultApi(apiClient.setApiToken(null)) - .findApplicant(UUID.fromString("839d4812-7c49-4008-8d83-bbd7610f0fec")), + .findApplicant(UUID.fromString("839d4812-7c49-4008-8d83-bbd7610f0fec")) + .execute(), "Expected to throw, but it didn't"); assertTrue(thrown.getMessage().contains("authorization_error")); diff --git a/src/test/java/com/onfido/integration/AddressTest.java b/src/test/java/com/onfido/integration/AddressTest.java index d646e9dd..08b0e640 100644 --- a/src/test/java/com/onfido/integration/AddressTest.java +++ b/src/test/java/com/onfido/integration/AddressTest.java @@ -9,7 +9,7 @@ public class AddressTest extends TestBase { @Test public void pickTest() throws Exception { - List
addresses = onfido.findAddresses("S2 2DF").getAddresses(); + List
addresses = onfido.findAddresses("S2 2DF").execute().getAddresses(); Assertions.assertNotNull(addresses); Assertions.assertEquals("S2 2DF", addresses.get(0).getPostcode()); diff --git a/src/test/java/com/onfido/integration/AdvancedElectronicSignatureTest.java b/src/test/java/com/onfido/integration/AdvancedElectronicSignatureTest.java index c8919d55..966d621e 100644 --- a/src/test/java/com/onfido/integration/AdvancedElectronicSignatureTest.java +++ b/src/test/java/com/onfido/integration/AdvancedElectronicSignatureTest.java @@ -28,10 +28,10 @@ public void documentsTest() throws Exception { new WorkflowRunBuilder() .workflowId(workflowId) .applicantId(applicantId) - .customData(customData)); + .customData(customData)).execute(); UUID workflowRunId = workflowRun.getId(); - TaskItem task = onfido.listTasks(workflowRunId).get(1); + TaskItem task = onfido.listTasks(workflowRunId).execute().get(1); LinkedTreeMap output = (LinkedTreeMap) @@ -47,9 +47,9 @@ public void documentsTest() throws Exception { UUID receiptDocumentFileId = UUID.fromString((String) receiptDocument.get("id")); byte[] signedDocumentBytes = - onfido.downloadAesDocument(workflowRunId, signedDocumentFileId).getByteArray(); + onfido.downloadAesDocument(workflowRunId, signedDocumentFileId).execute().getByteArray(); byte[] receiptDocumentBytes = - onfido.downloadAesDocument(workflowRunId, receiptDocumentFileId).getByteArray(); + onfido.downloadAesDocument(workflowRunId, receiptDocumentFileId).execute().getByteArray(); Assertions.assertEquals("%PDF", new String(signedDocumentBytes, 0, 4)); Assertions.assertTrue(signedDocumentBytes.length > 0); diff --git a/src/test/java/com/onfido/integration/ApplicantTest.java b/src/test/java/com/onfido/integration/ApplicantTest.java index 494302ed..cec2b43d 100644 --- a/src/test/java/com/onfido/integration/ApplicantTest.java +++ b/src/test/java/com/onfido/integration/ApplicantTest.java @@ -25,7 +25,7 @@ public void setup() throws Exception { @AfterEach public void cleanUp() throws Exception { - onfido.deleteApplicant(applicant.getId()); + onfido.deleteApplicant(applicant.getId()).execute(); } @Test @@ -41,7 +41,7 @@ public void createApplicantTest() throws Exception { @Test public void findApplicantTest() throws Exception { Applicant applicant = createApplicant(); - Applicant lookupApplicant = onfido.findApplicant(applicant.getId()); + Applicant lookupApplicant = onfido.findApplicant(applicant.getId()).execute(); Assertions.assertEquals("First", lookupApplicant.getFirstName()); Assertions.assertEquals("Last", lookupApplicant.getLastName()); @@ -52,7 +52,7 @@ public void findApplicantTest() throws Exception { @Test public void updateApplicantTest() throws Exception { Applicant updatedApplicant = - onfido.updateApplicant(applicant.getId(), new ApplicantUpdater().firstName("Updated")); + onfido.updateApplicant(applicant.getId(), new ApplicantUpdater().firstName("Updated")).execute(); Assertions.assertEquals("Updated", updatedApplicant.getFirstName()); Assertions.assertEquals("Last", updatedApplicant.getLastName()); @@ -72,9 +72,9 @@ public void findApplicantConsentsTest() throws Exception { .name(ApplicantConsentName.PHONE_NUMBER_VERIFICATION) .granted(true)); - onfido.updateApplicant(applicant.getId(), new ApplicantUpdater().consents(consents)); + onfido.updateApplicant(applicant.getId(), new ApplicantUpdater().consents(consents)).execute(); - List actualConsents = onfido.findApplicantConsents(applicant.getId()); + List actualConsents = onfido.findApplicantConsents(applicant.getId()).execute(); Map expectedConsents = consents.stream() @@ -93,15 +93,15 @@ public void findApplicantConsentsTest() throws Exception { public void deleteApplicantTest() throws Exception { Applicant applicant = createApplicant(); - onfido.deleteApplicant(applicant.getId()); + onfido.deleteApplicant(applicant.getId()).execute(); } @Test public void restoreApplicantTest() throws Exception { Applicant applicant = createApplicant(); - onfido.deleteApplicant(applicant.getId()); - onfido.restoreApplicant(applicant.getId()); + onfido.deleteApplicant(applicant.getId()).execute(); + onfido.restoreApplicant(applicant.getId()).execute(); } @Test @@ -110,7 +110,7 @@ public void listApplicants() throws Exception { createApplicant("Applicant2"); List applicants = - onfido.listApplicants(1, 20, false).getApplicants().stream() + onfido.listApplicants().page(1).perPage(20).includeDeleted(false).execute().getApplicants().stream() .sorted(Comparator.comparing(Applicant::getFirstName)) .collect(Collectors.toList()); diff --git a/src/test/java/com/onfido/integration/CheckTest.java b/src/test/java/com/onfido/integration/CheckTest.java index 8f944229..9874b831 100644 --- a/src/test/java/com/onfido/integration/CheckTest.java +++ b/src/test/java/com/onfido/integration/CheckTest.java @@ -91,7 +91,7 @@ public void findCheckTest() throws Exception { document, new CheckBuilder().reportNames(Arrays.asList(ReportName.DOCUMENT))); - Check lookupCheck = onfido.findCheck(check.getId()); + Check lookupCheck = onfido.findCheck(check.getId()).execute(); Assertions.assertEquals(check.getApplicantId(), lookupCheck.getApplicantId()); @@ -103,7 +103,7 @@ public void listChecks() throws Exception { createCheck( applicant, document, new CheckBuilder().reportNames(Arrays.asList(ReportName.DOCUMENT))); - List checks = onfido.listChecks(applicant.getId()).getChecks(); + List checks = onfido.listChecks(applicant.getId()).execute().getChecks(); Assertions.assertEquals(applicant.getId(), checks.get(0).getApplicantId()); Assertions.assertEquals(1, checks.size()); @@ -130,7 +130,7 @@ public void downloadCheckTest() throws Exception { document, new CheckBuilder().reportNames(Arrays.asList(ReportName.DOCUMENT))); - FileTransfer download = onfido.downloadCheck(check.getId()); + FileTransfer download = onfido.downloadCheck(check.getId()).execute(); byte[] byteArray = download.getByteArray(); Assertions.assertEquals("application/pdf", download.getContentType()); diff --git a/src/test/java/com/onfido/integration/DocumentTest.java b/src/test/java/com/onfido/integration/DocumentTest.java index 37c6b8a2..6dbceb34 100644 --- a/src/test/java/com/onfido/integration/DocumentTest.java +++ b/src/test/java/com/onfido/integration/DocumentTest.java @@ -32,7 +32,7 @@ public void uploadDocumentTest() { @Test public void downloadDocumentTest() throws Exception { - FileTransfer download = onfido.downloadDocument(document.getId()); + FileTransfer download = onfido.downloadDocument(document.getId()).execute(); Assertions.assertEquals("image/png", download.getContentType()); Assertions.assertNotNull(download.getFilename()); @@ -42,7 +42,7 @@ public void downloadDocumentTest() throws Exception { @Test public void downloadErrorTest() { try { - onfido.downloadDocument(nonExistingId); + onfido.downloadDocument(nonExistingId).execute(); Assertions.fail(); } catch (ApiException ex) { Assertions.assertEquals(404, ex.getCode()); @@ -51,7 +51,7 @@ public void downloadErrorTest() { @Test public void findDocumentTest() throws Exception { - Document lookupDocument = onfido.findDocument(document.getId()); + Document lookupDocument = onfido.findDocument(document.getId()).execute(); Assertions.assertEquals("sample_driving_licence.png", lookupDocument.getFileName()); Assertions.assertNotNull(lookupDocument.toJson()); @@ -62,7 +62,7 @@ public void listDocumentsTest() throws Exception { uploadDocument(applicant, "another_sample_driving_licence.jpeg", DocumentTypes.UNKNOWN); List documents = - onfido.listDocuments(applicant.getId()).getDocuments().stream() + onfido.listDocuments(applicant.getId()).execute().getDocuments().stream() .sorted(Comparator.comparing(Document::getFileName)) .collect(Collectors.toList()); @@ -81,7 +81,7 @@ public void listDocumentsTest() throws Exception { @Test public void nullParamRequestTest() { try { - onfido.uploadDocument(null, null, null, "file.png", null, null, null, null); + onfido.uploadDocument(null, null, null).execute(); Assertions.fail(); } catch (ApiException ex) { Assertions.assertEquals(0, ex.getCode()); @@ -92,7 +92,7 @@ public void nullParamRequestTest() { public void downloadNfcFaceTest() throws Exception { Document nfcFace = uploadDocument(applicant, "nfc_data.json", DocumentTypes.PASSPORT); - FileTransfer download = onfido.downloadNfcFace(nfcFace.getId()); + FileTransfer download = onfido.downloadNfcFace(nfcFace.getId()).execute(); Assertions.assertEquals("image/png", download.getContentType()); Assertions.assertNotNull(download.getFilename()); @@ -102,7 +102,7 @@ public void downloadNfcFaceTest() throws Exception { @Test public void downloadNfcFaceNotFoundTest() { try { - onfido.downloadNfcFace(nonExistingId); + onfido.downloadNfcFace(nonExistingId).execute(); Assertions.fail(); } catch (ApiException ex) { Assertions.assertEquals(404, ex.getCode()); diff --git a/src/test/java/com/onfido/integration/ExtractionTest.java b/src/test/java/com/onfido/integration/ExtractionTest.java index af726f74..aa515bc2 100644 --- a/src/test/java/com/onfido/integration/ExtractionTest.java +++ b/src/test/java/com/onfido/integration/ExtractionTest.java @@ -29,7 +29,7 @@ public void performExtractionTest() throws Exception { Document document = uploadDocument(applicant, "sample_driving_licence.png", DocumentTypes.DRIVING_LICENCE); - Extraction extraction = onfido.extract(new ExtractRequest().documentId(document.getId())); + Extraction extraction = onfido.extract(new ExtractRequest().documentId(document.getId())).execute(); Assertions.assertEquals(document.getId(), extraction.getDocumentId()); diff --git a/src/test/java/com/onfido/integration/IdPhotoTest.java b/src/test/java/com/onfido/integration/IdPhotoTest.java index d7dba1c9..18833ff1 100644 --- a/src/test/java/com/onfido/integration/IdPhotoTest.java +++ b/src/test/java/com/onfido/integration/IdPhotoTest.java @@ -31,7 +31,7 @@ public void uploadIdPhotoTest() throws Exception { @Test public void downloadIdPhotoTest() throws Exception { - FileTransfer download = onfido.downloadIdPhoto(idPhoto.getId()); + FileTransfer download = onfido.downloadIdPhoto(idPhoto.getId()).execute(); Assertions.assertEquals("image/png", download.getContentType()); Assertions.assertTrue(download.getFilename() != null); @@ -41,7 +41,7 @@ public void downloadIdPhotoTest() throws Exception { @Test public void downloadErrorTest() throws Exception { try { - onfido.downloadIdPhoto(nonExistingId); + onfido.downloadIdPhoto(nonExistingId).execute(); Assertions.fail(); } catch (ApiException ex) { Assertions.assertEquals(404, ex.getCode()); @@ -50,7 +50,7 @@ public void downloadErrorTest() throws Exception { @Test public void findIdPhotoTest() throws Exception { - IdPhoto lookupIdPhoto = onfido.findIdPhoto(idPhoto.getId()); + IdPhoto lookupIdPhoto = onfido.findIdPhoto(idPhoto.getId()).execute(); Assertions.assertEquals(idPhoto.getId() + ".png", lookupIdPhoto.getFileName()); @@ -62,7 +62,7 @@ public void listIdPhotosTest() throws Exception { uploadIdPhoto(applicant, "another_sample_photo.png"); List idPhotos = - onfido.listIdPhotos(applicant.getId()).getIdPhotos().stream() + onfido.listIdPhotos(applicant.getId()).execute().getIdPhotos().stream() .sorted(Comparator.comparing(IdPhoto::getFileName)) .collect(Collectors.toList()); diff --git a/src/test/java/com/onfido/integration/LivePhotoTest.java b/src/test/java/com/onfido/integration/LivePhotoTest.java index 1d227442..2d0a31de 100644 --- a/src/test/java/com/onfido/integration/LivePhotoTest.java +++ b/src/test/java/com/onfido/integration/LivePhotoTest.java @@ -31,7 +31,7 @@ public void uploadLivePhotoTest() throws Exception { @Test public void downloadLivePhotoTest() throws Exception { - FileTransfer download = onfido.downloadLivePhoto(livePhoto.getId()); + FileTransfer download = onfido.downloadLivePhoto(livePhoto.getId()).execute(); Assertions.assertEquals("image/png", download.getContentType()); Assertions.assertEquals("sample_photo.png", download.getFilename()); @@ -41,7 +41,7 @@ public void downloadLivePhotoTest() throws Exception { @Test public void downloadErrorTest() throws Exception { try { - onfido.downloadLivePhoto(nonExistingId); + onfido.downloadLivePhoto(nonExistingId).execute(); Assertions.fail(); } catch (ApiException ex) { Assertions.assertEquals(404, ex.getCode()); @@ -50,7 +50,7 @@ public void downloadErrorTest() throws Exception { @Test public void findLivePhotoTest() throws Exception { - LivePhoto lookupLivePhoto = onfido.findLivePhoto(livePhoto.getId()); + LivePhoto lookupLivePhoto = onfido.findLivePhoto(livePhoto.getId()).execute(); Assertions.assertEquals("sample_photo.png", lookupLivePhoto.getFileName()); @@ -62,7 +62,7 @@ public void listLivePhotosTest() throws Exception { uploadLivePhoto(applicant, "another_sample_photo.png"); List livePhotos = - onfido.listLivePhotos(applicant.getId()).getLivePhotos().stream() + onfido.listLivePhotos(applicant.getId()).execute().getLivePhotos().stream() .sorted(Comparator.comparing(LivePhoto::getFileName)) .collect(Collectors.toList()); diff --git a/src/test/java/com/onfido/integration/LiveVideoTest.java b/src/test/java/com/onfido/integration/LiveVideoTest.java index 5c1bd435..5649a279 100644 --- a/src/test/java/com/onfido/integration/LiveVideoTest.java +++ b/src/test/java/com/onfido/integration/LiveVideoTest.java @@ -15,7 +15,7 @@ public class LiveVideoTest extends TestBase { @Test public void downloadLiveVideoTest() throws Exception { - FileTransfer download = onfido.downloadLiveVideo(sampleLiveVideoId1); + FileTransfer download = onfido.downloadLiveVideo(sampleLiveVideoId1).execute(); Assertions.assertEquals("video/quicktime", download.getContentType()); Assertions.assertEquals("video.mov", download.getFilename()); @@ -25,7 +25,7 @@ public void downloadLiveVideoTest() throws Exception { @Test public void downloadLiveVideoFrameTest() throws Exception { try { - FileTransfer download = onfido.downloadLiveVideoFrame(sampleLiveVideoId1); + FileTransfer download = onfido.downloadLiveVideoFrame(sampleLiveVideoId1).execute(); Assertions.assertEquals("image/jpeg", download.getContentType()); Assertions.assertTrue(download.getFilename() != null); @@ -40,7 +40,7 @@ public void downloadLiveVideoFrameTest() throws Exception { @Test public void downloadErrorTest() throws Exception { try { - onfido.downloadLiveVideo(nonExistingId); + onfido.downloadLiveVideo(nonExistingId).execute(); Assertions.fail(); } catch (ApiException ex) { Assertions.assertEquals(404, ex.getCode()); @@ -49,7 +49,7 @@ public void downloadErrorTest() throws Exception { @Test public void findLiveVideoTest() throws Exception { - LiveVideo liveVideo = onfido.findLiveVideo(sampleLiveVideoId1); + LiveVideo liveVideo = onfido.findLiveVideo(sampleLiveVideoId1).execute(); Assertions.assertEquals("video.mov", liveVideo.getFileName()); @@ -58,7 +58,7 @@ public void findLiveVideoTest() throws Exception { @Test public void listLiveVideosTest() throws Exception { - List liveVideos = onfido.listLiveVideos(sampleApplicantId).getLiveVideos(); + List liveVideos = onfido.listLiveVideos(sampleApplicantId).execute().getLiveVideos(); Assertions.assertEquals("video.mov", liveVideos.get(0).getFileName()); Assertions.assertEquals("video.mov", liveVideos.get(1).getFileName()); diff --git a/src/test/java/com/onfido/integration/MotionCaptureTest.java b/src/test/java/com/onfido/integration/MotionCaptureTest.java index 922fd302..80fc8f6b 100644 --- a/src/test/java/com/onfido/integration/MotionCaptureTest.java +++ b/src/test/java/com/onfido/integration/MotionCaptureTest.java @@ -15,7 +15,7 @@ public class MotionCaptureTest extends TestBase { @Test public void downloadMotionCaptureTest() throws Exception { - FileTransfer download = onfido.downloadMotionCapture(EXAMPLE_ID_1); + FileTransfer download = onfido.downloadMotionCapture(EXAMPLE_ID_1).execute(); Assertions.assertEquals("video/mp4", download.getContentType()); Assertions.assertTrue(download.getFilename() != null); @@ -25,7 +25,7 @@ public void downloadMotionCaptureTest() throws Exception { @Test public void downloadMotionCaptureFrameTest() throws Exception { try { - FileTransfer download = onfido.downloadMotionCaptureFrame(EXAMPLE_ID_1); + FileTransfer download = onfido.downloadMotionCaptureFrame(EXAMPLE_ID_1).execute(); byte[] byteArray = download.getByteArray(); Assertions.assertEquals("image/jpeg", download.getContentType()); @@ -43,7 +43,7 @@ public void downloadMotionCaptureFrameTest() throws Exception { @Test public void downloadErrorTest() throws Exception { try { - onfido.downloadMotionCapture(nonExistingId); + onfido.downloadMotionCapture(nonExistingId).execute(); Assertions.fail(); } catch (ApiException ex) { Assertions.assertEquals(404, ex.getCode()); @@ -54,7 +54,7 @@ public void downloadErrorTest() throws Exception { public void findMotionCaptureTest() throws Exception { String expectedFilename = EXAMPLE_ID_1 + ".mp4"; - MotionCapture motionCapture = onfido.findMotionCapture(EXAMPLE_ID_1); + MotionCapture motionCapture = onfido.findMotionCapture(EXAMPLE_ID_1).execute(); Assertions.assertEquals(expectedFilename, motionCapture.getFileName()); @@ -64,7 +64,7 @@ public void findMotionCaptureTest() throws Exception { @Test public void listMotionCapturesTest() throws Exception { List motionCaptures = - onfido.listMotionCaptures(sampleApplicantId).getMotionCaptures(); + onfido.listMotionCaptures(sampleApplicantId).execute().getMotionCaptures(); Assertions.assertEquals(2, motionCaptures.size()); diff --git a/src/test/java/com/onfido/integration/PingTest.java b/src/test/java/com/onfido/integration/PingTest.java index 796a541c..a94675ed 100644 --- a/src/test/java/com/onfido/integration/PingTest.java +++ b/src/test/java/com/onfido/integration/PingTest.java @@ -7,7 +7,7 @@ public class PingTest extends TestBase { @Test public void pingTest() throws Exception { - String response = onfido.ping(); + String response = onfido.ping().execute(); Assertions.assertEquals("OK", response); } diff --git a/src/test/java/com/onfido/integration/QualifiedElectronicSignatureTest.java b/src/test/java/com/onfido/integration/QualifiedElectronicSignatureTest.java index d7d6dbe5..0e8c9442 100644 --- a/src/test/java/com/onfido/integration/QualifiedElectronicSignatureTest.java +++ b/src/test/java/com/onfido/integration/QualifiedElectronicSignatureTest.java @@ -34,10 +34,10 @@ public void documentsTest() throws Exception { new WorkflowRunBuilder() .workflowId(workflowId) .applicantId(applicantId) - .customData(customData)); + .customData(customData)).execute(); UUID workflowRunId = workflowRun.getId(); - TaskItem task = onfido.listTasks(workflowRunId).get(1); + TaskItem task = onfido.listTasks(workflowRunId).execute().get(1); LinkedTreeMap output = (LinkedTreeMap) @@ -50,7 +50,7 @@ public void documentsTest() throws Exception { LinkedTreeMap signedDocument = (LinkedTreeMap) signedDocuments.get(0); UUID fileId = UUID.fromString((String) signedDocument.get("id")); - byte[] byteArray = onfido.downloadQesDocument(workflowRunId, fileId).getByteArray(); + byte[] byteArray = onfido.downloadQesDocument(workflowRunId, fileId).execute().getByteArray(); Assertions.assertEquals("%PDF", new String(byteArray, 0, 4)); Assertions.assertTrue(byteArray.length > 0); diff --git a/src/test/java/com/onfido/integration/ReportTest.java b/src/test/java/com/onfido/integration/ReportTest.java index 656cf854..05113e9a 100644 --- a/src/test/java/com/onfido/integration/ReportTest.java +++ b/src/test/java/com/onfido/integration/ReportTest.java @@ -91,7 +91,7 @@ public void findReportTest() throws Exception { @Test public void listReportsTest() throws Exception { - List reports = sortReports(onfido.listReports(check.getId()).getReports()); + List reports = sortReports(onfido.listReports(check.getId()).execute().getReports()); Assertions.assertEquals(ReportName.DOCUMENT, reports.get(0).getName()); Assertions.assertEquals(ReportName.IDENTITY_ENHANCED, reports.get(1).getName()); @@ -102,8 +102,8 @@ public void resumeReportTest() throws Exception { List reportIds = check.getReportIds(); if (reportIds != null) { - Report report = onfido.findReport(reportIds.get(0)); - onfido.resumeReport(report.getId()); + Report report = onfido.findReport(reportIds.get(0)).execute(); + onfido.resumeReport(report.getId()).execute(); } else { Assertions.fail(); } @@ -114,8 +114,8 @@ public void cancelReportTest() throws Exception { List reportIds = check.getReportIds(); if (reportIds != null) { - Report report = onfido.findReport(reportIds.get(0)); - onfido.cancelReport(report.getId()); + Report report = onfido.findReport(reportIds.get(0)).execute(); + onfido.cancelReport(report.getId()).execute(); } else { Assertions.fail(); } diff --git a/src/test/java/com/onfido/integration/SdkTokenTest.java b/src/test/java/com/onfido/integration/SdkTokenTest.java index 86090ce0..e9da90f4 100644 --- a/src/test/java/com/onfido/integration/SdkTokenTest.java +++ b/src/test/java/com/onfido/integration/SdkTokenTest.java @@ -16,7 +16,7 @@ public void generateTokenTest() throws Exception { onfido.generateSdkToken( new SdkTokenBuilder() .applicantId(applicant.getId()) - .referrer("https://*.example.com/example_page/*")); + .referrer("https://*.example.com/example_page/*")).execute(); Assertions.assertTrue(token.getToken().length() > 0); diff --git a/src/test/java/com/onfido/integration/SigningDocumentTest.java b/src/test/java/com/onfido/integration/SigningDocumentTest.java index cf3d6cdf..7c50ed19 100644 --- a/src/test/java/com/onfido/integration/SigningDocumentTest.java +++ b/src/test/java/com/onfido/integration/SigningDocumentTest.java @@ -32,7 +32,7 @@ public void uploadSigningDocumentTest() { @Test public void downloadSigningDocumentTest() throws Exception { - FileTransfer download = onfido.downloadSigningDocument(signingDocument.getId()); + FileTransfer download = onfido.downloadSigningDocument(signingDocument.getId()).execute(); Assertions.assertEquals("application/pdf", download.getContentType()); Assertions.assertNotNull(download.getFilename()); @@ -42,7 +42,7 @@ public void downloadSigningDocumentTest() throws Exception { @Test public void findSigningDocumentTest() throws Exception { - SigningDocument found = onfido.findSigningDocument(signingDocument.getId()); + SigningDocument found = onfido.findSigningDocument(signingDocument.getId()).execute(); Assertions.assertEquals(signingDocument.getId(), found.getId()); Assertions.assertEquals("sample_signing_document.pdf", found.getFileName()); @@ -55,7 +55,7 @@ public void findSigningDocumentTest() throws Exception { @Test public void listSigningDocumentsTest() throws Exception { List documents = - onfido.listSigningDocuments(applicant.getId()).getSigningDocuments(); + onfido.listSigningDocuments(applicant.getId()).execute().getSigningDocuments(); Assertions.assertNotNull(documents); Assertions.assertTrue( @@ -65,7 +65,7 @@ public void listSigningDocumentsTest() throws Exception { @Test public void uploadSigningDocumentNullParamsTest() { try { - onfido.uploadSigningDocument(null, null); + onfido.uploadSigningDocument(null, null).execute(); Assertions.fail(); } catch (ApiException ex) { Assertions.assertEquals(0, ex.getCode()); @@ -75,7 +75,7 @@ public void uploadSigningDocumentNullParamsTest() { @Test public void downloadSigningDocumentErrorTest() { try { - onfido.downloadSigningDocument(nonExistingId); + onfido.downloadSigningDocument(nonExistingId).execute(); Assertions.fail(); } catch (ApiException ex) { Assertions.assertEquals(404, ex.getCode()); diff --git a/src/test/java/com/onfido/integration/TasksTest.java b/src/test/java/com/onfido/integration/TasksTest.java index a554a632..5028b2bf 100644 --- a/src/test/java/com/onfido/integration/TasksTest.java +++ b/src/test/java/com/onfido/integration/TasksTest.java @@ -26,7 +26,7 @@ public void setup() throws Exception { @Test public void listTasks() throws Exception { - List tasks = onfido.listTasks(workflowRunId); + List tasks = onfido.listTasks(workflowRunId).execute(); Assertions.assertEquals(2, tasks.size()); @@ -36,9 +36,9 @@ public void listTasks() throws Exception { @Test public void findTask() throws Exception { - TaskItem lookupTask = onfido.listTasks(workflowRunId).get(0); + TaskItem lookupTask = onfido.listTasks(workflowRunId).execute().get(0); - Task task = onfido.findTask(workflowRunId, lookupTask.getId()); + Task task = onfido.findTask(workflowRunId, lookupTask.getId()).execute(); Assertions.assertEquals(lookupTask.getId(), task.getId()); Assertions.assertEquals(lookupTask.getTaskDefId(), task.getTaskDefId()); @@ -57,9 +57,9 @@ public void completeTask() throws Exception { CompleteTaskBuilder completeTaskBuilder = new CompleteTaskBuilder(); completeTaskBuilder.setData(new CompleteTaskDataBuilder(completeTaskBody)); - onfido.completeTask(workflowRunId, taskId, completeTaskBuilder); + onfido.completeTask(workflowRunId, taskId, completeTaskBuilder).execute(); - Task completedTask = onfido.findTask(workflowRunId, taskId); + Task completedTask = onfido.findTask(workflowRunId, taskId).execute(); Map taskOutput = (Map) completedTask.getOutput(); Assertions.assertEquals("First", taskOutput.get("first_name")); diff --git a/src/test/java/com/onfido/integration/TestBase.java b/src/test/java/com/onfido/integration/TestBase.java index 8a478055..50b09f22 100644 --- a/src/test/java/com/onfido/integration/TestBase.java +++ b/src/test/java/com/onfido/integration/TestBase.java @@ -65,7 +65,7 @@ public Applicant createApplicant(String first_name) Arrays.asList( new ApplicantConsentBuilder() .name(ApplicantConsentName.PRIVACY_NOTICES_READ) - .granted(true)))); + .granted(true)))).execute(); return applicant; } @@ -86,38 +86,43 @@ protected Document uploadDocument( return onfido.uploadDocument( document_type, applicant.getId(), - new FileTransfer(byteArray, filename), - null, - "front", - CountryCodes.USA, - null, - locationBuilder); + new FileTransfer(byteArray, filename)) + .side("front") + .issuingCountry(CountryCodes.USA) + .location(locationBuilder) + .execute(); } protected SigningDocument uploadSigningDocument(Applicant applicant, String filename) throws ApiException { return onfido.uploadSigningDocument( - applicant.getId(), new FileTransfer(new File("media/" + filename))); + applicant.getId(), new FileTransfer(new File("media/" + filename))).execute(); } protected LivePhoto uploadLivePhoto(Applicant applicant, String filename) throws Exception { - return onfido.uploadLivePhoto( - applicant.getId(), new FileTransfer(new File("media/" + filename)), true); + return onfido.uploadLivePhoto() + .applicantId(applicant.getId()) + ._file(new FileTransfer(new File("media/" + filename))) + .advancedValidation(true) + .execute(); } protected IdPhoto uploadIdPhoto(Applicant applicant, String filename) throws Exception { - return onfido.uploadIdPhoto(applicant.getId(), new FileTransfer(new File("media/" + filename))); + return onfido.uploadIdPhoto() + .applicantId(applicant.getId()) + ._file(new FileTransfer(new File("media/" + filename))) + .execute(); } protected Check createCheck(Applicant applicant, Document document, CheckBuilder checkBuilder) throws IOException, InterruptedException, ApiException { return onfido.createCheck( - checkBuilder.applicantId(applicant.getId()).documentIds(Arrays.asList(document.getId()))); + checkBuilder.applicantId(applicant.getId()).documentIds(Arrays.asList(document.getId()))).execute(); } protected WorkflowRun createWorkflowRun(UUID workflowId, UUID applicantId) throws Exception { return onfido.createWorkflowRun( - new WorkflowRunBuilder().workflowId(workflowId).applicantId(applicantId)); + new WorkflowRunBuilder().workflowId(workflowId).applicantId(applicantId)).execute(); } private boolean isAValidUuid(UUID uuid) { @@ -130,10 +135,10 @@ public void cleanUpApplicants() throws IOException, ApiException { return; } - for (Applicant applicant : onfido.listApplicants(1, 100, false).getApplicants()) { + for (Applicant applicant : onfido.listApplicants().page(1).perPage(100).includeDeleted(false).execute().getApplicants()) { if (!applicant.getId().equals(sampleApplicantId)) { try { - onfido.deleteApplicant(applicant.getId()); + onfido.deleteApplicant(applicant.getId()).execute(); } catch (ApiException e) { // Just ignore any failure during clean up } @@ -142,13 +147,13 @@ public void cleanUpApplicants() throws IOException, ApiException { } public void cleanUpWebhooks() throws IOException, ApiException { - for (Webhook webhook : onfido.listWebhooks().getWebhooks()) { - onfido.deleteWebhook(webhook.getId()); + for (Webhook webhook : onfido.listWebhooks().execute().getWebhooks()) { + onfido.deleteWebhook(webhook.getId()).execute(); } } public String getTaskIdByPartialId(UUID workflowRunId, String partialId) throws ApiException { - return onfido.listTasks(workflowRunId).stream() + return onfido.listTasks(workflowRunId).execute().stream() .filter((task) -> task.getTaskDefId().contains(partialId)) .collect(Collectors.toList()) .get(0) @@ -158,7 +163,7 @@ public String getTaskIdByPartialId(UUID workflowRunId, String partialId) throws public WatchlistMonitor createWatchlistMonitor( UUID applicantId, WatchlistMonitorBuilder.ReportNameEnum reportName) throws ApiException { return onfido.createWatchlistMonitor( - new WatchlistMonitorBuilder().applicantId(applicantId).reportName(reportName)); + new WatchlistMonitorBuilder().applicantId(applicantId).reportName(reportName)).execute(); } private Method getMethod(String methodName, Object[] params) throws NoSuchMethodException { @@ -177,7 +182,9 @@ public Object repeatRequestUntilStatusChanges( InterruptedException, InvocationTargetException { Method method = getMethod(methodName, params); - Object instance = method.invoke(onfido, params); + Object request = method.invoke(onfido, params); + Method executeMethod = request.getClass().getMethod("execute"); + Object instance = executeMethod.invoke(request); int iteration = 0; Method getStatusMethod = instance.getClass().getMethod("getStatus"); @@ -189,7 +196,8 @@ public Object repeatRequestUntilStatusChanges( iteration += 1; Thread.sleep(sleepTime); - instance = method.invoke(onfido, params); + request = method.invoke(onfido, params); + instance = executeMethod.invoke(request); } return instance; } @@ -201,7 +209,9 @@ public Task repeatRequestUntilTaskOutputChanges( InterruptedException, InvocationTargetException { Method method = getMethod(methodName, params); - Task instance = (Task) method.invoke(onfido, params); + Object request = method.invoke(onfido, params); + Method executeMethod = request.getClass().getMethod("execute"); + Task instance = (Task) executeMethod.invoke(request); int iteration = 0; @@ -212,7 +222,8 @@ public Task repeatRequestUntilTaskOutputChanges( iteration += 1; Thread.sleep(sleepTime); - instance = (Task) method.invoke(onfido, params); + request = method.invoke(onfido, params); + instance = (Task) executeMethod.invoke(request); } return instance; } @@ -226,7 +237,9 @@ public Object repeatRequestUntilHttpCodeChanges( while (iteration <= maxRetries) { try { - instance = method.invoke(onfido, params); + Object request = method.invoke(onfido, params); + Method executeMethod = request.getClass().getMethod("execute"); + instance = executeMethod.invoke(request); break; } catch (InvocationTargetException e) { Thread.sleep(sleepTime); diff --git a/src/test/java/com/onfido/integration/WatchlistMonitorTest.java b/src/test/java/com/onfido/integration/WatchlistMonitorTest.java index 4c629dc5..42d6139f 100644 --- a/src/test/java/com/onfido/integration/WatchlistMonitorTest.java +++ b/src/test/java/com/onfido/integration/WatchlistMonitorTest.java @@ -36,7 +36,7 @@ public void createWatchlistAmlMonitor() throws Exception { public void listWatchlistMonitors() throws Exception { createWatchlistMonitor(applicantId, WatchlistMonitorBuilder.ReportNameEnum.STANDARD); - WatchlistMonitorsList listOfMonitors = onfido.listWatchlistMonitors(applicantId, false); + WatchlistMonitorsList listOfMonitors = onfido.listWatchlistMonitors(applicantId).includeDeleted(false).execute(); Assertions.assertFalse(listOfMonitors.getMonitors().isEmpty()); } @@ -46,7 +46,7 @@ public void findWatchlistMonitor() throws Exception { createWatchlistMonitor(applicantId, WatchlistMonitorBuilder.ReportNameEnum.STANDARD) .getId(); - WatchlistMonitor monitor = onfido.findWatchlistMonitor(monitorId); + WatchlistMonitor monitor = onfido.findWatchlistMonitor(monitorId).execute(); Assertions.assertEquals(monitorId, monitor.getId()); } @@ -56,7 +56,7 @@ public void deleteWatchlistMonitor() throws Exception { createWatchlistMonitor(applicantId, WatchlistMonitorBuilder.ReportNameEnum.STANDARD) .getId(); - onfido.deleteWatchlistMonitor(monitorId); + onfido.deleteWatchlistMonitor(monitorId).execute(); } @Test @@ -65,7 +65,7 @@ public void listWatchlistMonitorMatches() throws Exception { createWatchlistMonitor(applicantId, WatchlistMonitorBuilder.ReportNameEnum.STANDARD) .getId(); - WatchlistMonitorMatchesList matches = onfido.listWatchlistMonitorMatches(monitorId); + WatchlistMonitorMatchesList matches = onfido.listWatchlistMonitorMatches(monitorId).execute(); Assertions.assertTrue(matches.getMatches().isEmpty()); } @@ -75,6 +75,6 @@ public void forceReportCreation() throws Exception { createWatchlistMonitor(applicantId, WatchlistMonitorBuilder.ReportNameEnum.STANDARD) .getId(); - onfido.forceReportCreationFromWatchlistMonitor(monitorId); + onfido.forceReportCreationFromWatchlistMonitor(monitorId).execute(); } } diff --git a/src/test/java/com/onfido/integration/WebhookTest.java b/src/test/java/com/onfido/integration/WebhookTest.java index a17f460c..bb9ea5e4 100644 --- a/src/test/java/com/onfido/integration/WebhookTest.java +++ b/src/test/java/com/onfido/integration/WebhookTest.java @@ -30,7 +30,7 @@ public void tearDown() throws Exception { } private Webhook createWebhook(String url) throws Exception { - return onfido.createWebhook(new WebhookBuilder().url(url)); + return onfido.createWebhook(new WebhookBuilder().url(url)).execute(); } @Test @@ -42,7 +42,7 @@ public void createWebhookTest() throws Exception { @Test public void findWebhookTest() throws Exception { - Webhook lookupWebhook = onfido.findWebhook(webhook.getId()); + Webhook lookupWebhook = onfido.findWebhook(webhook.getId()).execute(); Assertions.assertEquals("https://example.com/webhook", lookupWebhook.getUrl()); @@ -53,7 +53,7 @@ public void findWebhookTest() throws Exception { public void updateWebhookTest() throws Exception { Webhook updatedWebhook = onfido.updateWebhook( - webhook.getId(), new WebhookUpdater().url("https://example.com/webhook/updated")); + webhook.getId(), new WebhookUpdater().url("https://example.com/webhook/updated")).execute(); Assertions.assertEquals("https://example.com/webhook/updated", updatedWebhook.getUrl()); @@ -62,7 +62,7 @@ public void updateWebhookTest() throws Exception { @Test public void deleteWebhookTest() throws Exception { - onfido.deleteWebhook(webhook.getId()); + onfido.deleteWebhook(webhook.getId()).execute(); } @Test @@ -71,7 +71,7 @@ public void listWebhooksTest() throws Exception { createWebhook("https://example.com/secondWebhook"); List webhooks = - onfido.listWebhooks().getWebhooks().stream() + onfido.listWebhooks().execute().getWebhooks().stream() .sorted(Comparator.comparing(Webhook::getUrl)) .collect(Collectors.toList()); diff --git a/src/test/java/com/onfido/integration/WorkflowRunOutputsTest.java b/src/test/java/com/onfido/integration/WorkflowRunOutputsTest.java index 43a252e9..65ebf8f4 100644 --- a/src/test/java/com/onfido/integration/WorkflowRunOutputsTest.java +++ b/src/test/java/com/onfido/integration/WorkflowRunOutputsTest.java @@ -29,8 +29,8 @@ public void profileDataCaptureAsOutput() throws Exception { CompleteTaskBuilder completeTaskBuilder = new CompleteTaskBuilder(); completeTaskBuilder.setData(new CompleteTaskDataBuilder(gson.fromJson(reader, Object.class))); - onfido.completeTask(workflowRunId, taskId, completeTaskBuilder); - WorkflowRun workflowRun = onfido.findWorkflowRun(workflowRunId); + onfido.completeTask(workflowRunId, taskId, completeTaskBuilder).execute(); + WorkflowRun workflowRun = onfido.findWorkflowRun(workflowRunId).execute(); Map output = (Map) workflowRun.getOutput(); Assertions.assertEquals( @@ -51,7 +51,7 @@ public void documentAndFacialSimilarityReportsAsOutputs() throws Exception { CompleteTaskBuilder completeProfileDataTaskBuilder = new CompleteTaskBuilder(); completeProfileDataTaskBuilder.setData( new CompleteTaskDataBuilder(completeProfileDataTaskBody)); - onfido.completeTask(workflowRunId, profileDataTaskId, completeProfileDataTaskBuilder); + onfido.completeTask(workflowRunId, profileDataTaskId, completeProfileDataTaskBuilder).execute(); String documentCaptureTaskId = getTaskIdByPartialId(workflowRunId, "document_photo"); Document document = @@ -65,7 +65,7 @@ public void documentAndFacialSimilarityReportsAsOutputs() throws Exception { completeDocumentCaptureTaskBodyArray.add(completeDocumentCaptureTaskBody); completeDocumentCaptureTaskBuilder.setData( new CompleteTaskDataBuilder(completeDocumentCaptureTaskBodyArray)); - onfido.completeTask(workflowRunId, documentCaptureTaskId, completeDocumentCaptureTaskBuilder); + onfido.completeTask(workflowRunId, documentCaptureTaskId, completeDocumentCaptureTaskBuilder).execute(); String photoCaptureTaskId = getTaskIdByPartialId(workflowRunId, "face_photo"); LivePhoto livePhoto = uploadLivePhoto(applicant, "sample_photo.png"); @@ -78,7 +78,7 @@ public void documentAndFacialSimilarityReportsAsOutputs() throws Exception { completeLivePhotoCaptureTaskBodyArray.add(completeLivePhotoCaptureTaskBody); completeLivePhotoCaptureTaskBuilder.setData( new CompleteTaskDataBuilder(completeLivePhotoCaptureTaskBodyArray)); - onfido.completeTask(workflowRunId, photoCaptureTaskId, completeLivePhotoCaptureTaskBuilder); + onfido.completeTask(workflowRunId, photoCaptureTaskId, completeLivePhotoCaptureTaskBuilder).execute(); // wait for workflow run to finish WorkflowRun workflowRun = diff --git a/src/test/java/com/onfido/integration/WorkflowRunTest.java b/src/test/java/com/onfido/integration/WorkflowRunTest.java index 4e9920da..e15ba60c 100644 --- a/src/test/java/com/onfido/integration/WorkflowRunTest.java +++ b/src/test/java/com/onfido/integration/WorkflowRunTest.java @@ -51,7 +51,7 @@ public void createWorkflowRunWithCustomInputsTest() throws Exception { new WorkflowRunBuilder() .workflowId(workflowId) .applicantId(applicantId) - .customData(customData)); + .customData(customData)).execute(); Assertions.assertEquals(workflowId, workflowRunWithCustomInputs.getWorkflowId()); Assertions.assertEquals(applicantId, workflowRunWithCustomInputs.getApplicantId()); @@ -62,7 +62,7 @@ public void createWorkflowRunWithCustomInputsTest() throws Exception { @Test public void findWorkflowRunTest() throws Exception { - WorkflowRun lookupWorkflowRun = onfido.findWorkflowRun(workflowRunId); + WorkflowRun lookupWorkflowRun = onfido.findWorkflowRun(workflowRunId).execute(); Assertions.assertEquals(WORKFLOW_ID, lookupWorkflowRun.getWorkflowId()); Assertions.assertEquals(applicantId, lookupWorkflowRun.getApplicantId()); @@ -72,7 +72,7 @@ public void findWorkflowRunTest() throws Exception { @Test public void evidenceWorkflowRunTest() throws Exception { - byte[] byteArray = onfido.downloadSignedEvidenceFile(workflowRunId).getByteArray(); + byte[] byteArray = onfido.downloadSignedEvidenceFile(workflowRunId).execute().getByteArray(); Assertions.assertEquals("%PDF", new String(byteArray, 0, 4)); Assertions.assertTrue(byteArray.length > 0); @@ -88,7 +88,7 @@ public void generateTimelineFileTest() throws Exception { WorkflowRunStatus.APPROVED, MAX_RETRIES, SLEEP_TIME); - TimelineFileReference workflowTimelineFileData = onfido.createTimelineFile(workflowRunId); + TimelineFileReference workflowTimelineFileData = onfido.createTimelineFile(workflowRunId).execute(); Assertions.assertNotNull(workflowTimelineFileData.getWorkflowTimelineFileId()); Assertions.assertNotNull(workflowTimelineFileData.getHref()); @@ -106,7 +106,7 @@ public void findTimelineFileTest() throws Exception { WorkflowRunStatus.APPROVED, MAX_RETRIES, SLEEP_TIME); - UUID timelineFileId = onfido.createTimelineFile(workflowRunId).getWorkflowTimelineFileId(); + UUID timelineFileId = onfido.createTimelineFile(workflowRunId).execute().getWorkflowTimelineFileId(); FileTransfer download = (FileTransfer) From 7de7fc967c273eaa9c29acb98d29b216887d86ae Mon Sep 17 00:00:00 2001 From: Davide Vacca Date: Thu, 29 Jan 2026 14:05:56 +0100 Subject: [PATCH 2/2] docs: update migration guide for 7.x breaking changes Add migration section documenting the transition from 6.x to 7.x, explaining the new request builder pattern with .execute() calls and fluent API for optional parameters. This pattern change prevents future breaking changes when new optional parameters are added to API methods. --- MIGRATION.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/MIGRATION.md b/MIGRATION.md index e081f97e..33e7046f 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -6,6 +6,33 @@ major versions of the client library. It covers changes in core resources, other endpoints, and the OpenAPI generator, ensuring a smooth transition between versions. +## Upgrading from 6.x to 7.x + +### API Method Invocation + +- All API methods now return request builder objects requiring `.execute()` call +- Optional parameters are set via fluent setter methods instead of method parameters +- This change prevents breaking changes when new optional parameters are added + +Example migration: +```java +// Before (6.x) +Applicant applicant = onfido.findApplicant(applicantId); +List runs = onfido.listWorkflowRuns(applicantId, status, page, perPage); + +// After (7.x) +Applicant applicant = onfido.findApplicant(applicantId).execute(); +List runs = onfido.listWorkflowRuns() + .applicantId(applicantId) + .status(status) + .page(page) + .perPage(perPage) + .execute(); +``` + +Note: Some list methods return wrapper objects (e.g., `ChecksList`) with +accessor methods like `getChecks()` to retrieve the actual list. + ## Upgrading from 5.x to 6.x ### Core Resources