Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .github/workflows/_test-code-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
MINDEE_V2_SE_TESTS_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
MINDEE_V2_SE_TESTS_CROP_EXTRACTION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_EXTRACTION_MODEL_ID }}
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
MINDEE_V2_SE_TESTS_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
MINDEE_V2_SE_TESTS_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
MINDEE_V2_SE_TESTS_CROP_EXTRACTION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_EXTRACTION_MODEL_ID }}
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
MINDEE_V2_SE_TESTS_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}

Expand Down
71 changes: 63 additions & 8 deletions src/test/java/com/mindee/v2/product/CropIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Tag("integration")
@DisplayName("MindeeV2 –Integration Tests - Crop")
@DisplayName("MindeeV2 – Integration Tests - Crop")
class CropIT {

private MindeeClient mindeeClient;
private String modelId;
private String cropModelId;
private String cropExtractionModelId;

@BeforeAll
void setUp() {
var apiKey = System.getenv("MINDEE_V2_API_KEY");
modelId = System.getenv("MINDEE_V2_SE_TESTS_CROP_MODEL_ID");
cropModelId = System.getenv("MINDEE_V2_SE_TESTS_CROP_MODEL_ID");
cropExtractionModelId = System.getenv("MINDEE_V2_SE_TESTS_CROP_EXTRACTION_MODEL_ID");
mindeeClient = new MindeeClient(apiKey);
}

@Test
@DisplayName("Empty, multi-page PDF – enqueue & parse must succeed")
void parseFile_FilledMultiPage_mustSucceed() throws IOException, InterruptedException {
@DisplayName("Filled, multi-page PDF – crop must succeed")
void filledMultiPage_cropMustSucceed() throws IOException, InterruptedException {
var source = new LocalInputSource(getV2ResourcePath("products/crop/multipage_sample.pdf"));
var params = CropParameters
.builder(modelId)
.builder(cropModelId)
.alias("java_integration-test_crop_multipage")
.build();
var pollingOptions = PollingOptions
Expand All @@ -58,11 +60,64 @@ void parseFile_FilledMultiPage_mustSucceed() throws IOException, InterruptedExce
assertEquals(2, file.getPageCount());

assertNotNull(inference.getModel());
assertEquals(modelId, inference.getModel().getId());
assertEquals(cropModelId, inference.getModel().getId());

var result = inference.getResult();
assertNotNull(result);
assertEquals(5, result.getCrops().size());
assertEquals("receipt", result.getCrops().get(0).getObjectType());
var crop0 = result.getCrops().get(0);
assertEquals("receipt", crop0.getObjectType());
assertNotNull(crop0.getLocation().getPolygon());
assertEquals(0, crop0.getLocation().getPage());
}

@Test
@DisplayName("Filled image – crop and extraction must succeed")
void filledSinglePage_extractionMustSucceed() throws IOException, InterruptedException {
var source = new LocalInputSource(getV2ResourcePath("products/crop/default_sample.jpg"));
var params = CropParameters
.builder(cropExtractionModelId)
.alias("java_integration-test_crop_multipage")
.build();
var pollingOptions = PollingOptions
.builder()
.initialDelaySec(5.0)
.intervalSec(1.5)
.maxRetries(80)
.build();

CropResponse response = mindeeClient
.enqueueAndGetResult(CropResponse.class, source, params, pollingOptions);
assertNotNull(response);

var inference = response.getInference();
assertNotNull(inference);

var file = inference.getFile();
assertNotNull(file);
assertEquals("default_sample.jpg", file.getName());
assertEquals(1, file.getPageCount());

assertNotNull(inference.getModel());
assertEquals(cropExtractionModelId, inference.getModel().getId());

var result = inference.getResult();
assertNotNull(result);
assertEquals(2, result.getCrops().size());
var crop0 = result.getCrops().get(0);
assertEquals("receipt", crop0.getObjectType());
assertNotNull(crop0.getLocation().getPolygon());
assertEquals(0, crop0.getLocation().getPage());
var extractionResponse0 = crop0.getExtractionResponse();
assertNotNull(extractionResponse0);
assertEquals(
"CHEZ ALAIN MIAM MIAM",
extractionResponse0
.getInference()
.getResult()
.getFields()
.getSimpleField("supplier_name")
.getValue()
);
}
}
2 changes: 1 addition & 1 deletion src/test/java/com/mindee/v2/product/SplitIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Tag("integration")
@DisplayName("MindeeV2 –Integration Tests - Split")
@DisplayName("MindeeV2 – Integration Tests - Split")
class SplitIT {

private MindeeClient mindeeClient;
Expand Down
Loading