3
3
4
4
package com .azure .ai .formrecognizer ;
5
5
6
- import com .azure .ai .formrecognizer .implementation .models .AnalyzeResult ;
7
6
import com .azure .ai .formrecognizer .models .CustomFormModel ;
8
7
import com .azure .ai .formrecognizer .models .ErrorResponseException ;
9
8
import com .azure .ai .formrecognizer .models .FormContentType ;
20
19
21
20
import java .time .Duration ;
22
21
23
- import static com .azure .ai .formrecognizer .TestUtils .CUSTOM_FORM_DATA ;
24
22
import static com .azure .ai .formrecognizer .TestUtils .CUSTOM_FORM_FILE_LENGTH ;
25
- import static com .azure .ai .formrecognizer .TestUtils .CUSTOM_FORM_LABELED_DATA ;
23
+ import static com .azure .ai .formrecognizer .TestUtils .FORM_LOCAL_URL ;
26
24
import static com .azure .ai .formrecognizer .TestUtils .INVALID_SOURCE_URL_ERROR ;
27
25
import static com .azure .ai .formrecognizer .TestUtils .INVALID_URL ;
28
26
import static com .azure .ai .formrecognizer .TestUtils .LAYOUT_FILE_LENGTH ;
29
- import static com .azure .ai .formrecognizer .TestUtils .LAYOUT_FORM_DATA ;
27
+ import static com .azure .ai .formrecognizer .TestUtils .LAYOUT_LOCAL_URL ;
30
28
import static com .azure .ai .formrecognizer .TestUtils .RECEIPT_FILE_LENGTH ;
31
- import static com .azure .ai .formrecognizer .TestUtils .RECEIPT_FORM_DATA ;
32
29
import static com .azure .ai .formrecognizer .TestUtils .RECEIPT_LOCAL_URL ;
33
- import static com .azure .ai .formrecognizer .TestUtils .getAnalyzeRawResponse ;
34
30
import static com .azure .ai .formrecognizer .TestUtils .getReplayableBufferData ;
35
31
import static com .azure .ai .formrecognizer .implementation .Utility .toFluxByteBuffer ;
36
32
import static org .junit .jupiter .api .Assertions .assertEquals ;
@@ -67,7 +63,7 @@ void recognizeReceiptSourceUrl() {
67
63
SyncPoller <OperationResult , IterableStream <RecognizedReceipt >> syncPoller =
68
64
client .beginRecognizeReceiptsFromUrl (sourceUrl ).getSyncPoller ();
69
65
syncPoller .waitForCompletion ();
70
- validateReceiptResultData (syncPoller .getFinalResult (), getAnalyzeRawResponse ( RECEIPT_FORM_DATA ). getAnalyzeResult (), false );
66
+ validateReceiptResultData (syncPoller .getFinalResult (), false );
71
67
});
72
68
}
73
69
@@ -81,7 +77,7 @@ void recognizeReceiptSourceUrlTextDetails() {
81
77
SyncPoller <OperationResult , IterableStream <RecognizedReceipt >> syncPoller =
82
78
client .beginRecognizeReceiptsFromUrl (sourceUrl , includeTextDetails , null ).getSyncPoller ();
83
79
syncPoller .waitForCompletion ();
84
- validateReceiptResultData (syncPoller .getFinalResult (), getAnalyzeRawResponse ( RECEIPT_FORM_DATA ). getAnalyzeResult (), includeTextDetails );
80
+ validateReceiptResultData (syncPoller .getFinalResult (), includeTextDetails );
85
81
});
86
82
}
87
83
@@ -96,7 +92,7 @@ void recognizeReceiptData() {
96
92
FormContentType .IMAGE_JPEG , false ,
97
93
null ).getSyncPoller ();
98
94
syncPoller .waitForCompletion ();
99
- validateReceiptResultData (syncPoller .getFinalResult (), getAnalyzeRawResponse ( RECEIPT_FORM_DATA ). getAnalyzeResult (), false );
95
+ validateReceiptResultData (syncPoller .getFinalResult (), false );
100
96
});
101
97
}
102
98
@@ -120,7 +116,7 @@ void recognizeReceiptDataWithContentTypeAutoDetection() {
120
116
client .beginRecognizeReceipts (getReplayableBufferData (RECEIPT_LOCAL_URL ), RECEIPT_FILE_LENGTH , null ,
121
117
false , null ).getSyncPoller ();
122
118
syncPoller .waitForCompletion ();
123
- validateReceiptResultData (syncPoller .getFinalResult (), getAnalyzeRawResponse ( RECEIPT_FORM_DATA ). getAnalyzeResult (), false );
119
+ validateReceiptResultData (syncPoller .getFinalResult (), false );
124
120
}
125
121
126
122
/**
@@ -134,7 +130,7 @@ void recognizeReceiptDataTextDetails() {
134
130
FormContentType .IMAGE_JPEG , includeTextDetails ,
135
131
null ).getSyncPoller ();
136
132
syncPoller .waitForCompletion ();
137
- validateReceiptResultData (syncPoller .getFinalResult (), getAnalyzeRawResponse ( RECEIPT_FORM_DATA ). getAnalyzeResult (), true );
133
+ validateReceiptResultData (syncPoller .getFinalResult (), true );
138
134
});
139
135
}
140
136
@@ -160,7 +156,7 @@ void recognizeReceiptAsUSReceipt() {
160
156
syncPoller .waitForCompletion ();
161
157
syncPoller .getFinalResult ().forEach (recognizedReceipt ->
162
158
validateUSReceiptData (ReceiptExtensions .asUSReceipt (recognizedReceipt ),
163
- getAnalyzeRawResponse ( RECEIPT_FORM_DATA ). getAnalyzeResult (), includeTextDetails ));
159
+ includeTextDetails ));
164
160
});
165
161
}
166
162
@@ -174,8 +170,7 @@ void recognizeLayoutData() {
174
170
= client .beginRecognizeContent (toFluxByteBuffer (data ),
175
171
LAYOUT_FILE_LENGTH , FormContentType .IMAGE_JPEG , null ).getSyncPoller ();
176
172
syncPoller .waitForCompletion ();
177
- final AnalyzeResult rawResponse = getAnalyzeRawResponse (LAYOUT_FORM_DATA ).getAnalyzeResult ();
178
- validateLayoutDataResults (syncPoller .getFinalResult (), rawResponse .getReadResults (), rawResponse .getPageResults (), false );
173
+ validateLayoutDataResults (syncPoller .getFinalResult (), false );
179
174
});
180
175
}
181
176
@@ -204,11 +199,10 @@ void recognizeLayoutDataWithNullData() {
204
199
void recognizeLayoutDataWithContentTypeAutoDetection () {
205
200
layoutDataRunner ((data ) -> {
206
201
SyncPoller <OperationResult , IterableStream <FormPage >> syncPoller
207
- = client .beginRecognizeContent (toFluxByteBuffer ( data ),
202
+ = client .beginRecognizeContent (getReplayableBufferData ( LAYOUT_LOCAL_URL ),
208
203
LAYOUT_FILE_LENGTH , null , null ).getSyncPoller ();
209
204
syncPoller .waitForCompletion ();
210
- final AnalyzeResult rawResponse = getAnalyzeRawResponse (LAYOUT_FORM_DATA ).getAnalyzeResult ();
211
- validateLayoutDataResults (syncPoller .getFinalResult (), rawResponse .getReadResults (), rawResponse .getPageResults (), false );
205
+ validateLayoutDataResults (syncPoller .getFinalResult (), false );
212
206
});
213
207
}
214
208
@@ -221,8 +215,7 @@ void recognizeLayoutSourceUrl() {
221
215
SyncPoller <OperationResult , IterableStream <FormPage >> syncPoller
222
216
= client .beginRecognizeContentFromUrl (sourceUrl ).getSyncPoller ();
223
217
syncPoller .waitForCompletion ();
224
- final AnalyzeResult rawResponse = getAnalyzeRawResponse (LAYOUT_FORM_DATA ).getAnalyzeResult ();
225
- validateLayoutDataResults (syncPoller .getFinalResult (), rawResponse .getReadResults (), rawResponse .getPageResults (), false );
218
+ validateLayoutDataResults (syncPoller .getFinalResult (), false );
226
219
});
227
220
}
228
221
@@ -269,7 +262,7 @@ void recognizeCustomFormLabeledData() {
269
262
.getSyncPoller ();
270
263
syncPoller .waitForCompletion ();
271
264
validateRecognizedResult (syncPoller .getFinalResult (),
272
- getAnalyzeRawResponse ( CUSTOM_FORM_LABELED_DATA ). getAnalyzeResult (), true , true );
265
+ true , true );
273
266
}));
274
267
}
275
268
@@ -309,13 +302,13 @@ void recognizeCustomFormLabeledDataWithContentTypeAutoDetection() {
309
302
trainingPoller .waitForCompletion ();
310
303
311
304
SyncPoller <OperationResult , IterableStream <RecognizedForm >> syncPoller
312
- = client .beginRecognizeCustomForms (toFluxByteBuffer ( data ),
305
+ = client .beginRecognizeCustomForms (getReplayableBufferData ( FORM_LOCAL_URL ),
313
306
trainingPoller .getFinalResult ().getModelId (),
314
307
CUSTOM_FORM_FILE_LENGTH , null , true , null )
315
308
.getSyncPoller ();
316
309
syncPoller .waitForCompletion ();
317
310
validateRecognizedResult (syncPoller .getFinalResult (),
318
- getAnalyzeRawResponse ( CUSTOM_FORM_LABELED_DATA ). getAnalyzeResult (), true , true );
311
+ true , true );
319
312
}));
320
313
}
321
314
@@ -337,7 +330,7 @@ void recognizeCustomFormUnlabeledData() {
337
330
.getSyncPoller ();
338
331
syncPoller .waitForCompletion ();
339
332
validateRecognizedResult (syncPoller .getFinalResult (),
340
- getAnalyzeRawResponse ( CUSTOM_FORM_DATA ). getAnalyzeResult (), false , false );
333
+ false , false );
341
334
}));
342
335
}
343
336
}
0 commit comments