diff --git a/src/test/java/com/onfido/integration/WorkflowRunOutputsTest.java b/src/test/java/com/onfido/integration/WorkflowRunOutputsTest.java index 5a7b154..28166f8 100644 --- a/src/test/java/com/onfido/integration/WorkflowRunOutputsTest.java +++ b/src/test/java/com/onfido/integration/WorkflowRunOutputsTest.java @@ -1,7 +1,5 @@ package com.onfido.integration; -import static com.onfido.model.WorkflowRun.StatusEnum.APPROVED; - import com.google.gson.Gson; import com.onfido.model.*; import java.io.FileReader; @@ -87,11 +85,11 @@ public void documentAndFacialSimilarityReportsAsOutputs() throws Exception { repeatRequestUntilStatusChanges( "findWorkflowRun", new UUID[] {workflowRunId}, - WorkflowRun.StatusEnum.APPROVED, + WorkflowRunStatus.APPROVED, 10, 1000); - Assertions.assertEquals(APPROVED, workflowRun.getStatus()); + Assertions.assertEquals(WorkflowRunStatus.APPROVED, workflowRun.getStatus()); Map workflowRunOutput = (Map) workflowRun.getOutput(); diff --git a/src/test/java/com/onfido/integration/WorkflowRunTest.java b/src/test/java/com/onfido/integration/WorkflowRunTest.java index 93e510c..ec2cccb 100644 --- a/src/test/java/com/onfido/integration/WorkflowRunTest.java +++ b/src/test/java/com/onfido/integration/WorkflowRunTest.java @@ -4,6 +4,7 @@ import com.onfido.model.TimelineFileReference; import com.onfido.model.WorkflowRun; import com.onfido.model.WorkflowRunBuilder; +import com.onfido.model.WorkflowRunStatus; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -48,8 +49,7 @@ public void createWorkflowRunWithCustomInputsTest() throws Exception { Assertions.assertEquals(workflowId, workflowRunWithCustomInputs.getWorkflowId()); Assertions.assertEquals(applicantId, workflowRunWithCustomInputs.getApplicantId()); - Assertions.assertEquals( - WorkflowRun.StatusEnum.APPROVED, workflowRunWithCustomInputs.getStatus()); + Assertions.assertEquals(WorkflowRunStatus.APPROVED, workflowRunWithCustomInputs.getStatus()); } @Test @@ -73,7 +73,7 @@ public void generateTimelineFileTest() throws Exception { UUID workflowRunId = createWorkflowRun(WORKFLOW_ID_TIMELINE, applicantId).getId(); repeatRequestUntilStatusChanges( - "findWorkflowRun", new UUID[] {workflowRunId}, WorkflowRun.StatusEnum.APPROVED, 10, 1000); + "findWorkflowRun", new UUID[] {workflowRunId}, WorkflowRunStatus.APPROVED, 10, 1000); TimelineFileReference workflowTimelineFileData = onfido.createTimelineFile(workflowRunId); Assertions.assertNotNull(workflowTimelineFileData.getWorkflowTimelineFileId()); @@ -85,7 +85,7 @@ public void findTimelineFileTest() throws Exception { UUID workflowRunId = createWorkflowRun(WORKFLOW_ID_TIMELINE, applicantId).getId(); repeatRequestUntilStatusChanges( - "findWorkflowRun", new UUID[] {workflowRunId}, WorkflowRun.StatusEnum.APPROVED, 10, 1000); + "findWorkflowRun", new UUID[] {workflowRunId}, WorkflowRunStatus.APPROVED, 10, 1000); UUID timelineFileId = onfido.createTimelineFile(workflowRunId).getWorkflowTimelineFileId(); FileTransfer download = diff --git a/src/test/java/com/onfido/webhooks/WebhookClassicEventVerifierTest.java b/src/test/java/com/onfido/webhooks/WebhookClassicEventVerifierTest.java index 78ca6e1..714fe96 100644 --- a/src/test/java/com/onfido/webhooks/WebhookClassicEventVerifierTest.java +++ b/src/test/java/com/onfido/webhooks/WebhookClassicEventVerifierTest.java @@ -4,8 +4,10 @@ import com.onfido.WebhookEventVerifier; import com.onfido.integration.TestBase; import com.onfido.model.WebhookEvent; +import com.onfido.model.WebhookEventObjectStatus; import com.onfido.model.WebhookEventPayload; import com.onfido.model.WebhookEventPayloadObject; +import com.onfido.model.WebhookEventResourceType; import com.onfido.model.WebhookEventType; import java.time.OffsetDateTime; import org.junit.jupiter.api.Assertions; @@ -26,13 +28,13 @@ public class WebhookClassicEventVerifierTest extends TestBase { .payload( new WebhookEventPayload() .action(WebhookEventType.CHECK_COMPLETED) - .resourceType("check") + .resourceType(WebhookEventResourceType.CHECK) ._object( new WebhookEventPayloadObject() .id("f2302f45-227d-413d-ad61-09ec077a086a") .href( "https://api.onfido.com/v3.6/checks/f2302f45-227d-413d-ad61-09ec077a086a") - .status("complete") + .status(WebhookEventObjectStatus.COMPLETE) .completedAtIso8601(OffsetDateTime.parse("2024-04-04T09:21:21Z")))); @Test diff --git a/src/test/java/com/onfido/webhooks/WebhookStudioEventVerifierTest.java b/src/test/java/com/onfido/webhooks/WebhookStudioEventVerifierTest.java index dc35609..fd0557e 100644 --- a/src/test/java/com/onfido/webhooks/WebhookStudioEventVerifierTest.java +++ b/src/test/java/com/onfido/webhooks/WebhookStudioEventVerifierTest.java @@ -4,10 +4,15 @@ import com.onfido.WebhookEventVerifier; import com.onfido.integration.TestBase; import com.onfido.model.WebhookEvent; +import com.onfido.model.WebhookEventObjectStatus; import com.onfido.model.WebhookEventPayload; import com.onfido.model.WebhookEventPayloadObject; +import com.onfido.model.WebhookEventPayloadResource; +import com.onfido.model.WebhookEventResourceType; import com.onfido.model.WebhookEventType; import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.UUID; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -27,16 +32,19 @@ public class WebhookStudioEventVerifierTest extends TestBase { private static final WebhookEventPayloadObject expectedObject = new WebhookEventPayloadObject() .id("profile_1eb92") - .status("started") + .status(WebhookEventObjectStatus.STARTED) .startedAtIso8601(OffsetDateTime.parse("2024-07-10T12:49:09Z")) .href( "https://api.eu.onfido.com/v3.6/workflow_runs/bc77c6e5-753a-4580-96a6-aaed3e5a8d19/tasks/profile_1eb92"); - private static final String expectedResource = - "{created_at=2024-07-10T12:49:09Z, id=profile_1eb92," - + " workflow_run_id=bc77c6e5-753a-4580-96a6-aaed3e5a8d19," - + " updated_at=2024-07-10T12:49:09Z, input={}, task_def_version=null," - + " task_def_id=profile_data, output=null}"; + private static final WebhookEventPayloadResource expectedResource = + new WebhookEventPayloadResource() + .createdAt(OffsetDateTime.parse("2024-07-10T12:49:09Z")) + .id("profile_1eb92") + .workflowRunId(UUID.fromString("bc77c6e5-753a-4580-96a6-aaed3e5a8d19")) + .updatedAt(OffsetDateTime.parse("2024-07-10T12:49:09Z")) + .input(new HashMap<>()) + .taskDefId("profile_data"); @Test public void validSignatureTest() throws Exception { @@ -46,11 +54,10 @@ public void validSignatureTest() throws Exception { WebhookEventPayload webhookPayload = event.getPayload(); Assertions.assertEquals(WebhookEventType.WORKFLOW_TASK_STARTED, webhookPayload.getAction()); - Assertions.assertEquals("workflow_task", webhookPayload.getResourceType()); + Assertions.assertEquals( + WebhookEventResourceType.WORKFLOW_TASK, webhookPayload.getResourceType()); Assertions.assertEquals(expectedObject, webhookPayload.getObject()); - - // TODO fix me once Resource accessors are made available - Assertions.assertEquals(webhookPayload.getResource().toString(), expectedResource); + Assertions.assertEquals(expectedResource, webhookPayload.getResource()); } @Test