33import com .mindee .http .MindeeHttpExceptionV2 ;
44import com .mindee .input .LocalInputSource ;
55import com .mindee .input .URLInputSource ;
6+ import com .mindee .parsing .v2 .Inference ;
67import com .mindee .parsing .v2 .InferenceActiveOptions ;
8+ import com .mindee .parsing .v2 .InferenceFile ;
79import com .mindee .parsing .v2 .InferenceResponse ;
10+ import com .mindee .parsing .v2 .InferenceResult ;
11+ import com .mindee .parsing .v2 .RawText ;
12+ import com .mindee .parsing .v2 .field .InferenceFields ;
13+ import com .mindee .parsing .v2 .field .SimpleField ;
814import java .io .File ;
915import java .io .IOException ;
1016import org .junit .jupiter .api .*;
@@ -34,6 +40,9 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep
3440 InferenceParameters params = InferenceParameters
3541 .builder (modelId )
3642 .rag (false )
43+ .rawText (true )
44+ .polygon (null )
45+ .confidence (null )
3746 .alias ("java-integration-test" )
3847 .pollingOptions (
3948 AsyncPollingOptions .builder ()
@@ -45,24 +54,33 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep
4554 .build ();
4655
4756 InferenceResponse response = mindeeClient .enqueueAndGetInference (source , params );
48-
4957 assertNotNull (response );
50- assertNotNull (response .getInference ());
51-
52- assertNotNull (response .getInference ().getFile ());
53- assertEquals ("multipage_cut-2.pdf" , response .getInference ().getFile ().getName ());
58+ Inference inference = response .getInference ();
59+ assertNotNull (inference );
5460
55- assertNotNull (response .getInference ().getModel ());
56- assertEquals (modelId , response .getInference ().getModel ().getId ());
61+ InferenceFile file = inference .getFile ();
62+ assertNotNull (file );
63+ assertEquals ("multipage_cut-2.pdf" , file .getName ());
64+ assertEquals (2 , file .getPageCount ());
5765
58- assertNotNull (response .getInference ().getResult ());
66+ assertNotNull (inference .getModel ());
67+ assertEquals (modelId , inference .getModel ().getId ());
5968
60- InferenceActiveOptions activeOptions = response . getInference () .getActiveOptions ();
69+ InferenceActiveOptions activeOptions = inference .getActiveOptions ();
6170 assertNotNull (activeOptions );
6271 assertFalse (activeOptions .getRag ());
63- assertFalse (activeOptions .getRawText ());
72+ assertTrue (activeOptions .getRawText ());
6473 assertFalse (activeOptions .getPolygon ());
6574 assertFalse (activeOptions .getConfidence ());
75+
76+ InferenceResult result = inference .getResult ();
77+ assertNotNull (result );
78+
79+ RawText rawText = result .getRawText ();
80+ assertEquals (2 , rawText .getPages ().size ());
81+
82+ InferenceFields fields = result .getFields ();
83+ assertNotNull (fields );
6684 }
6785
6886 @ Test
@@ -71,35 +89,44 @@ void parseFile_filledSinglePage_mustSucceed() throws IOException, InterruptedExc
7189 LocalInputSource source = new LocalInputSource (
7290 new File ("src/test/resources/products/financial_document/default_sample.jpg" ));
7391
74- InferenceParameters options = InferenceParameters
92+ InferenceParameters params = InferenceParameters
7593 .builder (modelId )
7694 .rag (false )
7795 .alias ("java-integration-test" )
7896 .build ();
7997
80- InferenceResponse response = mindeeClient .enqueueAndGetInference (source , options );
81-
98+ InferenceResponse response = mindeeClient .enqueueAndGetInference (source , params );
8299 assertNotNull (response );
83- assertNotNull (response .getInference ());
100+ Inference inference = response .getInference ();
101+ assertNotNull (inference );
84102
85- assertNotNull (response .getInference ().getFile ());
86- assertEquals ("default_sample.jpg" , response .getInference ().getFile ().getName ());
87-
88- assertNotNull (response .getInference ().getModel ());
89- assertEquals (modelId , response .getInference ().getModel ().getId ());
90-
91- assertNotNull (response .getInference ().getResult ());
92- assertNotNull (response .getInference ().getResult ().getFields ());
93- assertNotNull (response .getInference ().getResult ().getFields ().get ("supplier_name" ));
94- assertEquals (
95- "John Smith" ,
96- response .getInference ()
97- .getResult ()
98- .getFields ()
99- .get ("supplier_name" )
100- .getSimpleField ()
101- .getValue ()
102- );
103+ InferenceFile file = inference .getFile ();
104+ assertNotNull (file );
105+ assertEquals ("default_sample.jpg" , file .getName ());
106+ assertEquals (1 , file .getPageCount ());
107+
108+ assertNotNull (inference .getModel ());
109+ assertEquals (modelId , inference .getModel ().getId ());
110+
111+ InferenceActiveOptions activeOptions = inference .getActiveOptions ();
112+ assertNotNull (activeOptions );
113+ assertFalse (activeOptions .getRag ());
114+ assertFalse (activeOptions .getRawText ());
115+ assertFalse (activeOptions .getPolygon ());
116+ assertFalse (activeOptions .getConfidence ());
117+
118+ InferenceResult result = inference .getResult ();
119+ assertNotNull (result );
120+
121+ RawText rawText = result .getRawText ();
122+ assertNull (rawText );
123+
124+ InferenceFields fields = result .getFields ();
125+ assertNotNull (fields );
126+
127+ SimpleField supplierName = fields .getSimpleField ("supplier_name" );
128+ assertNotNull (supplierName );
129+ assertEquals ("John Smith" , supplierName .getStringValue ());
103130 }
104131
105132
0 commit comments