@@ -90,41 +90,55 @@ void asyncPredict_whenEmpty_mustHaveValidProperties() throws IOException {
9090 class CompletePrediction {
9191
9292 @ Test
93- @ DisplayName ("all properties must be valid" )
94- void asyncPredict_whenComplete_mustHaveValidProperties () throws IOException {
93+ @ DisplayName ("every exposed property must be valid and consistent " )
94+ void asyncPredict_whenComplete_mustExposeAllProperties () throws IOException {
9595 InferenceResponse response = loadFromResource ("v2/products/financial_document/complete.json" );
96- InferenceFields fields = response .getInference ().getResult ().getFields ();
96+ Inference inf = response .getInference ();
97+ assertNotNull (inf , "Inference must not be null" );
98+ assertEquals ("12345678-1234-1234-1234-123456789abc" , inf .getId (), "Inference ID mismatch" );
9799
98- assertEquals (21 , fields .size (), "Expected 21 fields" );
100+ InferenceResultModel model = inf .getModel ();
101+ assertNotNull (model , "Model must not be null" );
102+ assertEquals ("12345678-1234-1234-1234-123456789abc" , model .getId (), "Model ID mismatch" );
103+
104+ InferenceResultFile file = inf .getFile ();
105+ assertNotNull (file , "File must not be null" );
106+ assertEquals ("complete.jpg" , file .getName (), "File name mismatch" );
107+ assertNull (file .getAlias (), "File alias must be null for this payload" );
108+
109+ InferenceFields fields = inf .getResult ().getFields ();
110+ assertEquals (21 , fields .size (), "Expected 21 fields in the payload" );
111+
112+ SimpleField date = fields .get ("date" ).getSimpleField ();
113+ assertEquals ("2019-11-02" , date .getValue (), "'date' value mismatch" );
99114
100115 DynamicField taxes = fields .get ("taxes" );
101116 assertNotNull (taxes , "'taxes' field must exist" );
102117 ListField taxesList = taxes .getListField ();
103118 assertNotNull (taxesList , "'taxes' must be a ListField" );
104119 assertEquals (1 , taxesList .getItems ().size (), "'taxes' list must contain exactly one item" );
105- assertNotNull (taxes .toString (), "'taxes' toString() must not be null" );
106-
107120 ObjectField taxItemObj = taxesList .getItems ().get (0 ).getObjectField ();
108121 assertNotNull (taxItemObj , "First item of 'taxes' must be an ObjectField" );
109122 assertEquals (3 , taxItemObj .getFields ().size (), "Tax ObjectField must contain 3 sub-fields" );
110- assertEquals (
111- 31.5 ,
112- taxItemObj .getFields ().get ("base" ).getSimpleField ().getValue (),
113- "'taxes.base' value mismatch"
114- );
123+ SimpleField baseTax = taxItemObj .getFields ().get ("base" ).getSimpleField ();
124+ assertEquals (31.5 , baseTax .getValue (), "'taxes.base' value mismatch" );
125+ assertNotNull (taxes .toString (), "'taxes'.toString() must not be null" );
115126
116127 DynamicField supplierAddress = fields .get ("supplier_address" );
117128 assertNotNull (supplierAddress , "'supplier_address' field must exist" );
118-
119129 ObjectField supplierObj = supplierAddress .getObjectField ();
120130 assertNotNull (supplierObj , "'supplier_address' must be an ObjectField" );
121-
122131 DynamicField country = supplierObj .getFields ().get ("country" );
123132 assertNotNull (country , "'supplier_address.country' must exist" );
124- assertEquals ("USA" , country .getSimpleField ().getValue ());
125- assertEquals ("USA" , country .toString ());
126-
133+ assertEquals ("USA" , country .getSimpleField ().getValue (), "Country mismatch" );
134+ assertEquals ("USA" , country .toString (), "'country'.toString() mismatch" );
127135 assertNotNull (supplierAddress .toString (), "'supplier_address'.toString() must not be null" );
136+
137+ ObjectField customerAddr = fields .get ("customer_address" ).getObjectField ();
138+ SimpleField city = customerAddr .getFields ().get ("city" ).getSimpleField ();
139+ assertEquals ("New York" , city .getValue (), "City mismatch" );
140+
141+ assertNull (inf .getResult ().getOptions (), "Options must be null" );
128142 }
129143 }
130144
@@ -206,45 +220,6 @@ void rawTexts_mustBeAccessible() throws IOException {
206220 }
207221 }
208222
209- @ Nested
210- @ DisplayName ("complete.json – full inference response" )
211- class FullInference {
212- @ Test
213- @ DisplayName ("complete financial-document JSON must round-trip correctly" )
214- void fullInferenceResponse_mustExposeEveryProperty () throws IOException {
215- InferenceResponse resp = loadFromResource ("v2/products/financial_document/complete.json" );
216-
217- Inference inf = resp .getInference ();
218- assertNotNull (inf );
219- assertEquals ("12345678-1234-1234-1234-123456789abc" , inf .getId ());
220-
221- InferenceFields f = inf .getResult ().getFields ();
222-
223- SimpleField date = f .get ("date" ).getSimpleField ();
224- assertEquals ("2019-11-02" , date .getValue ());
225-
226- ListField taxes = f .get ("taxes" ).getListField ();
227- ObjectField firstTax = taxes .getItems ().get (0 ).getObjectField ();
228- SimpleField baseTax = firstTax .getFields ().get ("base" ).getSimpleField ();
229- assertEquals (31.5 , baseTax .getValue ());
230-
231- ObjectField customerAddr = f .get ("customer_address" ).getObjectField ();
232- SimpleField city = customerAddr .getFields ().get ("city" ).getSimpleField ();
233- assertEquals ("New York" , city .getValue ());
234-
235- InferenceResultModel model = inf .getModel ();
236- assertNotNull (model );
237- assertEquals ("12345678-1234-1234-1234-123456789abc" , model .getId ());
238-
239- InferenceResultFile file = inf .getFile ();
240- assertNotNull (file );
241- assertEquals ("complete.jpg" , file .getName ());
242- assertNull (file .getAlias ());
243-
244- assertNull (inf .getResult ().getOptions ());
245- }
246- }
247-
248223 @ Nested
249224 @ DisplayName ("rst display" )
250225 class RstDisplay {
0 commit comments