42
42
import static com .azure .ai .formrecognizer .TestUtils .DISPLAY_NAME_WITH_ARGUMENTS ;
43
43
import static org .junit .jupiter .api .Assertions .assertEquals ;
44
44
import static org .junit .jupiter .api .Assertions .assertNotNull ;
45
- import static org .junit .jupiter .api .Assertions .assertThrows ;
46
45
import static org .junit .jupiter .api .Assertions .assertTrue ;
47
46
import static org .junit .jupiter .api .Assertions .fail ;
48
47
@@ -140,11 +139,12 @@ public void deleteModelValidModelIdWithResponse(HttpClient httpClient,
140
139
@ MethodSource ("com.azure.ai.formrecognizer.TestUtils#getTestParameters" )
141
140
public void copyAuthorization (HttpClient httpClient , DocumentAnalysisServiceVersion serviceVersion ) {
142
141
client = getDocumentModelAdminAsyncClient (httpClient , serviceVersion );
143
- StepVerifier .create (client .getCopyAuthorization ())
144
- .assertNext (DocumentModelAdministrationClientTestBase ::validateCopyAuthorizationResult )
142
+ String modelId = "java_copy_model_test" ;
143
+ StepVerifier .create (client .getCopyAuthorizationWithResponse (new CopyAuthorizationOptions ().setModelId (modelId )))
144
+ .assertNext (response -> validateCopyAuthorizationResult (response .getValue ()))
145
145
.verifyComplete ();
146
146
147
- StepVerifier .create (client .deleteModel ("java_copy_model_test" )).verifyComplete ();
147
+ StepVerifier .create (client .deleteModel (modelId )).verifyComplete ();
148
148
}
149
149
150
150
/**
@@ -157,15 +157,15 @@ public void beginCreateComposedModel(HttpClient httpClient, DocumentAnalysisServ
157
157
client = getDocumentModelAdminAsyncClient (httpClient , serviceVersion );
158
158
buildModelRunner ((trainingFilesUrl ) -> {
159
159
SyncPoller <DocumentOperationResult , DocumentModel > syncPoller1 =
160
- client .beginBuildModel (trainingFilesUrl , DocumentBuildMode .TEMPLATE
161
- )
160
+ client .beginBuildModel (trainingFilesUrl , DocumentBuildMode .TEMPLATE ,
161
+ new BuildModelOptions (). setModelId ( "async_component_model_1" ) )
162
162
.setPollInterval (durationTestMode ).getSyncPoller ();
163
163
syncPoller1 .waitForCompletion ();
164
164
DocumentModel createdModel1 = syncPoller1 .getFinalResult ();
165
165
166
166
SyncPoller <DocumentOperationResult , DocumentModel > syncPoller2 =
167
- client .beginBuildModel (trainingFilesUrl , DocumentBuildMode .TEMPLATE
168
- )
167
+ client .beginBuildModel (trainingFilesUrl , DocumentBuildMode .TEMPLATE ,
168
+ new BuildModelOptions (). setModelId ( "async_component_model_2" ) )
169
169
.setPollInterval (durationTestMode ).getSyncPoller ();
170
170
syncPoller2 .waitForCompletion ();
171
171
DocumentModel createdModel2 = syncPoller2 .getFinalResult ();
@@ -335,15 +335,14 @@ public void beginBuildModelFailsWithInvalidPrefix(HttpClient httpClient, Documen
335
335
client = getDocumentModelAdminAsyncClient (httpClient , serviceVersion );
336
336
337
337
buildModelRunner ((trainingFilesUrl ) -> {
338
- HttpResponseException httpResponseException = assertThrows (HttpResponseException .class ,
339
- () -> client .beginBuildModel (trainingFilesUrl , DocumentBuildMode .TEMPLATE ,
340
- new BuildModelOptions ().setPrefix ("subfolder" ))
341
- .setPollInterval (durationTestMode )
342
- .getSyncPoller ()
343
- .getFinalResult ());
344
-
345
- ResponseError responseError = (ResponseError ) httpResponseException .getValue ();
346
- Assertions .assertEquals ("InvalidRequest" , responseError .getCode ());
338
+ StepVerifier .create (client .beginBuildModel (trainingFilesUrl , DocumentBuildMode .TEMPLATE ,
339
+ new BuildModelOptions ().setPrefix ("invalidPrefix" ))
340
+ .setPollInterval (durationTestMode ))
341
+ .verifyErrorSatisfies (throwable -> {
342
+ assertEquals (HttpResponseException .class , throwable .getClass ());
343
+ final ResponseError responseError = (ResponseError ) ((HttpResponseException ) throwable ).getValue ();
344
+ assertEquals ("InvalidRequest" , responseError .getCode ());
345
+ });
347
346
});
348
347
}
349
348
@@ -430,14 +429,14 @@ public void beginCopyWithOptions(HttpClient httpClient, DocumentAnalysisServiceV
430
429
public void listModels (HttpClient httpClient , DocumentAnalysisServiceVersion serviceVersion ) {
431
430
client = getDocumentModelAdminAsyncClient (httpClient , serviceVersion );
432
431
StepVerifier .create (client .listModels ().byPage ().take (4 ))
433
- .thenConsumeWhile (documentModelInfoPagedResponse -> {
434
- documentModelInfoPagedResponse .getValue ()
435
- .forEach (documentModelInfo -> {
436
- assertNotNull (documentModelInfo .getModelId ());
437
- assertNotNull (documentModelInfo .getCreatedOn ());
438
- });
439
- return true ;
440
- }).verifyComplete ();
432
+ .thenConsumeWhile (documentModelInfoPagedResponse -> {
433
+ documentModelInfoPagedResponse .getValue ()
434
+ .forEach (documentModelInfo -> {
435
+ assertNotNull (documentModelInfo .getModelId ());
436
+ assertNotNull (documentModelInfo .getCreatedOn ());
437
+ });
438
+ return true ;
439
+ }).verifyComplete ();
441
440
}
442
441
443
442
/**
0 commit comments