Skip to content

Commit

Permalink
Add downloadEvidenceFolder test
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelfteixeira committed Jan 7, 2025
1 parent 4772366 commit ea71955
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/test/java/com/onfido/integration/WorkflowRunTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
import com.onfido.model.WorkflowRun;
import com.onfido.model.WorkflowRunBuilder;
import com.onfido.model.WorkflowRunStatus;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.zip.ZipFile;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -18,7 +23,7 @@ public class WorkflowRunTest extends TestBase {
private UUID workflowRunId;

static final UUID WORKFLOW_ID = UUID.fromString("e8c921eb-0495-44fe-b655-bcdcaffdafe5");
static final UUID WORKFLOW_ID_TIMELINE = UUID.fromString("221f9d24-cf72-4762-ac4a-01bf3ccc09dd");
static final UUID WORKFLOW_ID_AUTO_APPROVE = UUID.fromString("221f9d24-cf72-4762-ac4a-01bf3ccc09dd");

@BeforeEach
public void setup() throws Exception {
Expand Down Expand Up @@ -76,7 +81,7 @@ public void evidenceWorkflowRunTest() throws Exception {

@Test
public void generateTimelineFileTest() throws Exception {
UUID workflowRunId = createWorkflowRun(WORKFLOW_ID_TIMELINE, applicantId).getId();
UUID workflowRunId = createWorkflowRun(WORKFLOW_ID_AUTO_APPROVE, applicantId).getId();

repeatRequestUntilStatusChanges(
"findWorkflowRun", new UUID[] {workflowRunId}, WorkflowRunStatus.APPROVED, 10, 1000);
Expand All @@ -90,7 +95,7 @@ public void generateTimelineFileTest() throws Exception {

@Test
public void findTimelineFileTest() throws Exception {
UUID workflowRunId = createWorkflowRun(WORKFLOW_ID_TIMELINE, applicantId).getId();
UUID workflowRunId = createWorkflowRun(WORKFLOW_ID_AUTO_APPROVE, applicantId).getId();

repeatRequestUntilStatusChanges(
"findWorkflowRun", new UUID[] {workflowRunId}, WorkflowRunStatus.APPROVED, 10, 1000);
Expand All @@ -106,4 +111,21 @@ public void findTimelineFileTest() throws Exception {
Assertions.assertEquals("%PDF", new String(byteArray, 0, 4));
Assertions.assertTrue(byteArray.length > 0);
}

@Test
public void downloadEvidenceFolderTest() throws Exception {
UUID workflowRunId = createWorkflowRun(WORKFLOW_ID_AUTO_APPROVE, applicantId).getId();

repeatRequestUntilStatusChanges(
"findWorkflowRun", new UUID[] {workflowRunId}, WorkflowRunStatus.APPROVED, 10, 1000);

byte[] byteArray = onfido.downloadEvidenceFolder(workflowRunId).getByteArray();

Path path = Files.createTempFile("evidence-folder", ".zip");
path.toFile().deleteOnExit();
Files.write(path, byteArray);

Assertions.assertDoesNotThrow(() -> new ZipFile(path.toFile()));
Assertions.assertTrue(byteArray.length > 0);
}
}

0 comments on commit ea71955

Please sign in to comment.