@@ -30,6 +30,7 @@ public class WorkflowTest {
3030 PdfOperation pdfOperation ;
3131
3232 private ObjectMapper objectMapper ;
33+
3334 @ BeforeEach
3435 public void setUp () {
3536 mindeeApi = Mockito .mock (MindeeApi .class );
@@ -50,10 +51,11 @@ void givenAWorkflowMockFileShouldReturnAValidWorkflowObject()
5051 workflowResponse .setExecution (new Execution ());
5152 workflowResponse .setApiRequest (null );
5253 when (
53- mindeeApi .executeWorkflowPost (
54- Mockito .any (),
55- Mockito .any (),
56- Mockito .any ()))
54+ mindeeApi .executeWorkflowPost (
55+ Mockito .any (),
56+ Mockito .any (),
57+ Mockito .any ()
58+ ))
5759 .thenReturn (workflowResponse );
5860
5961 WorkflowResponse <GeneratedV1 > execution = client .executeWorkflow (
@@ -72,35 +74,72 @@ void sendingADocumentToAnExecutionShouldDeserializeResponseCorrectly() throws IO
7274 WorkflowResponse .Default mockResponse =
7375 objectMapper .readValue (jsonFile , WorkflowResponse .Default .class );
7476
75- // Mock the executeWorkflow method
7677 when (mockedClient .executeWorkflow (Mockito .anyString (), Mockito .any (LocalInputSource .class )))
7778 .thenReturn (mockResponse );
7879
79- // Test execution
80- String workflowId = "workflow-id" ;
81- String filePath = "src/test/resources/file_types/pdf/blank_1.pdf" ;
80+ String workflowId = "07ebf237-ff27-4eee-b6a2-425df4a5cca6" ;
81+ String filePath = "src/test/resources/products/financial_document/default_sample.jpg" ;
8282 LocalInputSource inputSource = new LocalInputSource (filePath );
8383
8484 WorkflowResponse <GeneratedV1 > response = mockedClient .executeWorkflow (workflowId , inputSource );
8585
86- // Assertions
8786 Assertions .assertNotNull (response );
8887 Assertions .assertNotNull (response .getApiRequest ());
8988 Assertions .assertNull (response .getExecution ().getBatchName ());
9089 Assertions .assertNull (response .getExecution ().getCreatedAt ());
9190 Assertions .assertNull (response .getExecution ().getFile ().getAlias ());
9291 Assertions .assertEquals ("default_sample.jpg" , response .getExecution ().getFile ().getName ());
93- Assertions .assertEquals ("8c75c035-e083-4e77-ba3b-7c3598bd1d8a" , response .getExecution ().getId ());
94- Assertions .assertNull (response .getExecution ().getInference ());
95- Assertions .assertEquals ("medium" , response .getExecution ().getPriority ());
96- Assertions .assertNull (response .getExecution ().getReviewedAt ());
97- Assertions .assertNull (response .getExecution ().getReviewedPrediction ());
98- Assertions .assertEquals ("processing" , response .getExecution ().getStatus ());
99- Assertions .assertEquals ("manual" , response .getExecution ().getType ());
100- Assertions .assertEquals ("2024-11-13T13:02:31.699190" , response .getExecution ().getUploadedAt ().toString ());
101- Assertions .assertEquals ("07ebf237-ff27-4eee-b6a2-425df4a5cca6" , response .getExecution ().getWorkflowId ());
102-
103- // Verify that executeWorkflow was called with the correct parameters
92+ Assertions .assertEquals (
93+ "8c75c035-e083-4e77-ba3b-7c3598bd1d8a" , response .getExecution ().getId ());
94+ Assertions .assertNull (response .getExecution ().getInference ());
95+ Assertions .assertEquals ("medium" , response .getExecution ().getPriority ());
96+ Assertions .assertNull (response .getExecution ().getReviewedAt ());
97+ Assertions .assertNull (response .getExecution ().getReviewedPrediction ());
98+ Assertions .assertEquals ("processing" , response .getExecution ().getStatus ());
99+ Assertions .assertEquals ("manual" , response .getExecution ().getType ());
100+ Assertions .assertEquals (
101+ "2024-11-13T13:02:31.699190" , response .getExecution ().getUploadedAt ().toString ());
102+ Assertions .assertEquals (
103+ workflowId , response .getExecution ().getWorkflowId ());
104+
105+ Mockito .verify (mockedClient ).executeWorkflow (workflowId , inputSource );
106+ }
107+
108+
109+ @ Test
110+ void sendingADocumentToAnExecutionWithPriorityAndAliasShouldDeserializeResponseCorrectly () throws IOException {
111+ File jsonFile = new File ("src/test/resources/workflows/success_low_priority.json" );
112+ WorkflowResponse .Default mockResponse =
113+ objectMapper .readValue (jsonFile , WorkflowResponse .Default .class );
114+
115+ when (mockedClient .executeWorkflow (Mockito .anyString (), Mockito .any (LocalInputSource .class )))
116+ .thenReturn (mockResponse );
117+
118+ String workflowId = "07ebf237-ff27-4eee-b6a2-425df4a5cca6" ;
119+ String filePath = "src/test/resources/products/financial_document/default_sample.jpg" ;
120+ LocalInputSource inputSource = new LocalInputSource (filePath );
121+
122+ WorkflowResponse <GeneratedV1 > response = mockedClient .executeWorkflow (workflowId , inputSource );
123+
124+ Assertions .assertNotNull (response );
125+ Assertions .assertNotNull (response .getApiRequest ());
126+ Assertions .assertNull (response .getExecution ().getBatchName ());
127+ Assertions .assertNull (response .getExecution ().getCreatedAt ());
128+ Assertions .assertEquals ("low-priority-sample-test" , response .getExecution ().getFile ().getAlias ());
129+ Assertions .assertEquals ("default_sample.jpg" , response .getExecution ().getFile ().getName ());
130+ Assertions .assertEquals (
131+ "b743e123-e18c-4b62-8a07-811a4f72afd3" , response .getExecution ().getId ());
132+ Assertions .assertNull (response .getExecution ().getInference ());
133+ Assertions .assertEquals ("low" , response .getExecution ().getPriority ());
134+ Assertions .assertNull (response .getExecution ().getReviewedAt ());
135+ Assertions .assertNull (response .getExecution ().getReviewedPrediction ());
136+ Assertions .assertEquals ("processing" , response .getExecution ().getStatus ());
137+ Assertions .assertEquals ("manual" , response .getExecution ().getType ());
138+ Assertions .assertEquals (
139+ "2024-11-13T13:17:01.315179" , response .getExecution ().getUploadedAt ().toString ());
140+ Assertions .assertEquals (
141+ workflowId , response .getExecution ().getWorkflowId ());
142+
104143 Mockito .verify (mockedClient ).executeWorkflow (workflowId , inputSource );
105144 }
106145
0 commit comments