Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Live tests pipeline for Form Recognizer #22480

Merged
merged 4 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.azure.ai.formrecognizer.models.FormContentType;
import com.azure.ai.formrecognizer.models.FormPage;
import com.azure.ai.formrecognizer.models.FormRecognizerErrorInformation;
import com.azure.ai.formrecognizer.models.FormRecognizerException;
import com.azure.ai.formrecognizer.models.FormRecognizerLanguage;
import com.azure.ai.formrecognizer.models.FormRecognizerLocale;
import com.azure.ai.formrecognizer.models.FormRecognizerOperationResult;
Expand Down Expand Up @@ -242,7 +241,7 @@ public void recognizeReceiptSourceUrl(HttpClient httpClient, FormRecognizerServi
*/
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.formrecognizer.TestUtils#getTestParameters")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21331")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21687")
public void recognizeReceiptFromUrlWithEncodedBlankSpaceSourceUrl(HttpClient httpClient,
FormRecognizerServiceVersion serviceVersion) {
client = getFormRecognizerAsyncClient(httpClient, serviceVersion);
Expand Down Expand Up @@ -315,7 +314,6 @@ public void recognizeReceiptSourceUrlWithPngFile(HttpClient httpClient,
@Disabled
public void recognizeReceiptFromUrlMultiPage(HttpClient httpClient, FormRecognizerServiceVersion serviceVersion) {
client = getFormRecognizerAsyncClient(httpClient, serviceVersion);
// TODO: (https://github.com/Azure/azure-sdk-for-java/issues/20012)
urlRunner(fileUrl -> {
SyncPoller<FormRecognizerOperationResult, List<RecognizedForm>> syncPoller =
client.beginRecognizeReceiptsFromUrl(
Expand Down Expand Up @@ -542,7 +540,7 @@ public void recognizeContentFromUrl(HttpClient httpClient, FormRecognizerService
*/
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.formrecognizer.TestUtils#getTestParameters")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21331")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21687")
public void recognizeContentFromUrlWithEncodedBlankSpaceSourceUrl(HttpClient httpClient,
FormRecognizerServiceVersion serviceVersion) {
client = getFormRecognizerAsyncClient(httpClient, serviceVersion);
Expand Down Expand Up @@ -832,13 +830,14 @@ public void recognizeCustomFormInvalidStatus(HttpClient httpClient, FormRecogniz
new TrainingOptions().setPollInterval(durationTestMode)).getSyncPoller();
syncPoller.waitForCompletion();
CustomFormModel createdModel = syncPoller.getFinalResult();
FormRecognizerException formRecognizerException = assertThrows(FormRecognizerException.class,
HttpResponseException httpResponseException = assertThrows(HttpResponseException.class,
() -> client.beginRecognizeCustomFormsFromUrl(
createdModel.getModelId(), invalidSourceUrl, new RecognizeCustomFormsOptions()
.setPollInterval(durationTestMode))
.getSyncPoller().getFinalResult());
FormRecognizerErrorInformation errorInformation = formRecognizerException.getErrorInformation().get(0);
assertEquals(URL_BADLY_FORMATTED_ERROR_CODE, errorInformation.getErrorCode());
FormRecognizerErrorInformation errorInformation =
(FormRecognizerErrorInformation) httpResponseException.getValue();
assertEquals(INVALID_SOURCE_URL_EXCEPTION_MESSAGE, errorInformation.getMessage());
}));
}

Expand Down Expand Up @@ -1274,6 +1273,7 @@ modelId, fileUrl, new RecognizeCustomFormsOptions()
*/
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.formrecognizer.TestUtils#getTestParameters")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21687")
public void recognizeCustomFormFromUrlWithEncodedBlankSpaceSourceUrl(HttpClient httpClient,
FormRecognizerServiceVersion serviceVersion) {
client = getFormRecognizerAsyncClient(httpClient, serviceVersion);
Expand Down Expand Up @@ -1559,7 +1559,7 @@ public void recognizeBusinessCardSourceUrl(HttpClient httpClient, FormRecognizer
*/
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.formrecognizer.TestUtils#getTestParameters")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21331")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21687")
public void recognizeBusinessCardFromUrlWithEncodedBlankSpaceSourceUrl(HttpClient httpClient,
FormRecognizerServiceVersion serviceVersion) {
client = getFormRecognizerAsyncClient(httpClient, serviceVersion);
Expand Down Expand Up @@ -1871,7 +1871,7 @@ public void recognizeInvoiceSourceUrl(HttpClient httpClient, FormRecognizerServi
*/
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.formrecognizer.TestUtils#getTestParameters")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21331")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21687")
public void recognizeInvoiceFromUrlWithEncodedBlankSpaceSourceUrl(HttpClient httpClient,
FormRecognizerServiceVersion serviceVersion) {
client = getFormRecognizerAsyncClient(httpClient, serviceVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.azure.ai.formrecognizer.models.FormContentType;
import com.azure.ai.formrecognizer.models.FormPage;
import com.azure.ai.formrecognizer.models.FormRecognizerErrorInformation;
import com.azure.ai.formrecognizer.models.FormRecognizerException;
import com.azure.ai.formrecognizer.models.FormRecognizerLanguage;
import com.azure.ai.formrecognizer.models.FormRecognizerLocale;
import com.azure.ai.formrecognizer.models.FormRecognizerOperationResult;
Expand Down Expand Up @@ -228,7 +227,7 @@ public void recognizeReceiptSourceUrl(HttpClient httpClient, FormRecognizerServi
*/
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.formrecognizer.TestUtils#getTestParameters")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21331")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21687")
public void recognizeReceiptFromUrlWithEncodedBlankSpaceSourceUrl(HttpClient httpClient,
FormRecognizerServiceVersion serviceVersion) {
client = getFormRecognizerClient(httpClient, serviceVersion);
Expand Down Expand Up @@ -521,7 +520,7 @@ public void recognizeContentFromUrl(HttpClient httpClient, FormRecognizerService
*/
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.formrecognizer.TestUtils#getTestParameters")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21331")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21687")
public void recognizeContentFromUrlWithEncodedBlankSpaceSourceUrl(HttpClient httpClient,
FormRecognizerServiceVersion serviceVersion) {
client = getFormRecognizerClient(httpClient, serviceVersion);
Expand Down Expand Up @@ -795,13 +794,15 @@ public void recognizeCustomFormInvalidStatus(HttpClient httpClient, FormRecogniz
new TrainingOptions().setPollInterval(durationTestMode), Context.NONE);
syncPoller.waitForCompletion();
CustomFormModel createdModel = syncPoller.getFinalResult();
FormRecognizerException formRecognizerException = assertThrows(FormRecognizerException.class,
HttpResponseException httpResponseException = assertThrows(HttpResponseException.class,
() -> client.beginRecognizeCustomFormsFromUrl(
createdModel.getModelId(), invalidSourceUrl, new RecognizeCustomFormsOptions()
.setPollInterval(durationTestMode), Context.NONE)
.getFinalResult());
FormRecognizerErrorInformation errorInformation = formRecognizerException.getErrorInformation().get(0);
assertEquals(URL_BADLY_FORMATTED_ERROR_CODE, errorInformation.getErrorCode());
System.out.println(httpResponseException.getValue());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this system.out.println can be removed.

FormRecognizerErrorInformation errorInformation =
(FormRecognizerErrorInformation) httpResponseException.getValue();
assertEquals(INVALID_SOURCE_URL_EXCEPTION_MESSAGE, errorInformation.getMessage());
}));
}

Expand Down Expand Up @@ -1195,6 +1196,7 @@ modelId, fileUrl, new RecognizeCustomFormsOptions()
*/
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.formrecognizer.TestUtils#getTestParameters")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21687")
public void recognizeCustomFormFromUrlWithEncodedBlankSpaceSourceUrl(HttpClient httpClient,
FormRecognizerServiceVersion serviceVersion) {
client = getFormRecognizerClient(httpClient, serviceVersion);
Expand Down Expand Up @@ -1738,7 +1740,7 @@ public void recognizeBusinessCardSourceUrl(HttpClient httpClient, FormRecognizer
*/
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.formrecognizer.TestUtils#getTestParameters")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21331")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21687")
public void recognizeBusinessCardFromUrlWithEncodedBlankSpaceSourceUrl(HttpClient httpClient,
FormRecognizerServiceVersion serviceVersion) {
client = getFormRecognizerClient(httpClient, serviceVersion);
Expand Down Expand Up @@ -1987,7 +1989,7 @@ public void recognizeInvoiceSourceUrl(HttpClient httpClient, FormRecognizerServi
*/
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.formrecognizer.TestUtils#getTestParameters")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21331")
@Disabled("https://github.com/Azure/azure-sdk-for-java/issues/21687")
public void recognizeInvoiceFromUrlWithEncodedBlankSpaceSourceUrl(HttpClient httpClient,
FormRecognizerServiceVersion serviceVersion) {
client = getFormRecognizerClient(httpClient, serviceVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public abstract class FormRecognizerClientTestBase extends TestBase {
private static final String EXPECTED_MULTIPAGE_RECEIPT_PHONE_NUMBER_VALUE = "+19876543210";
private static final String ITEMIZED_RECEIPT_VALUE = "Itemized";
static final String RECEIPT_CONTOSO_JPG = "contoso-allinone.jpg";
// TODO (Service pending) Disabled, service to provide a different png file.
static final String RECEIPT_CONTOSO_PNG = "contoso-receipt.png";
static final String INVOICE_6_PDF = "Invoice_6.pdf";
static final String MULTIPAGE_INVOICE_PDF = "multipage_invoice1.pdf";
Expand All @@ -111,7 +110,10 @@ public abstract class FormRecognizerClientTestBase extends TestBase {
static final String HTTPS_EXCEPTION_MESSAGE =
"Max retries 3 times exceeded. Error Details: Key credentials require HTTPS to prevent leaking the key.";
static final String INVALID_UUID_EXCEPTION_MESSAGE = "Invalid UUID string: ";
static final String INVALID_SOURCE_URL_EXCEPTION_MESSAGE = "Failed to download the image from the submitted URL. "
+ "The URL may either be invalid or the server hosting the image is experiencing some technical difficulties.";
static final String MODEL_ID_IS_REQUIRED_EXCEPTION_MESSAGE = "'modelId' is required and cannot be null.";
static final String COPY_OPERATION_FAILED_STATUS_MESSAGE = "Copy operation failed";

static final String INVALID_ENDPOINT = "https://notreal.azure.com";
static final String LOCAL_FILE_PATH = "src/test/resources/sample_files/Test/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ public void beginCopyIncorrectRegion(HttpClient httpClient, FormRecognizerServic
FormRecognizerException formRecognizerException = assertThrows(FormRecognizerException.class,
() -> client.beginCopyModel(actualModel.getModelId(), target, durationTestMode)
.getSyncPoller().getFinalResult());
FormRecognizerErrorInformation errorInformation = formRecognizerException.getErrorInformation().get(0);
// assertTrue(formRecognizerException.getMessage().startsWith(COPY_OPERATION_FAILED_STATUS_MESSAGE));
assertTrue(formRecognizerException.getMessage().startsWith(
FormRecognizerClientTestBase.COPY_OPERATION_FAILED_STATUS_MESSAGE));
});
});
}
Expand Down Expand Up @@ -774,9 +774,9 @@ public void beginCreateComposedDuplicateModels(HttpClient httpClient, FormRecogn
// });
// }

// /**
// * Verifies the result contains the user defined model display name for unlabeled model.
// */
/**
* Verifies the result contains the user defined model display name for unlabeled model.
*/
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.formrecognizer.TestUtils#getTestParameters")
public void beginTrainingUnlabeledModelName(HttpClient httpClient, FormRecognizerServiceVersion serviceVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,8 @@ public void beginCopyIncorrectRegion(HttpClient httpClient, FormRecognizerServic
FormRecognizerException formRecognizerException = assertThrows(FormRecognizerException.class,
() -> client.beginCopyModel(actualModel.getModelId(), target, durationTestMode, Context.NONE)
.getFinalResult());
FormRecognizerErrorInformation errorInformation = formRecognizerException.getErrorInformation().get(0);
// TODO: Service bug https://github.com/Azure/azure-sdk-for-java/issues/12046
// assertEquals(RESOURCE_RESOLVER_ERROR, errorInformation.getCode());
// assertTrue(formRecognizerException.getMessage().startsWith(COPY_OPERATION_FAILED_STATUS_MESSAGE));
assertTrue(formRecognizerException.getMessage().startsWith(
FormRecognizerClientTestBase.COPY_OPERATION_FAILED_STATUS_MESSAGE));
});
});
}
Expand Down
Loading