|
| 1 | +package com.mindee.v2.product; |
| 2 | + |
| 3 | +import static com.mindee.TestingUtilities.getResourcePath; |
| 4 | +import static org.junit.jupiter.api.Assertions.*; |
| 5 | + |
| 6 | +import com.mindee.AsyncPollingOptions; |
| 7 | +import com.mindee.MindeeClientV2; |
| 8 | +import com.mindee.input.LocalInputSource; |
| 9 | +import com.mindee.parsing.v2.InferenceFile; |
| 10 | +import com.mindee.v2.product.crop.CropInference; |
| 11 | +import com.mindee.v2.product.crop.CropResponse; |
| 12 | +import com.mindee.v2.product.crop.CropResult; |
| 13 | +import com.mindee.v2.product.crop.params.CropParameters; |
| 14 | +import java.io.IOException; |
| 15 | +import org.junit.jupiter.api.BeforeAll; |
| 16 | +import org.junit.jupiter.api.DisplayName; |
| 17 | +import org.junit.jupiter.api.Tag; |
| 18 | +import org.junit.jupiter.api.Test; |
| 19 | +import org.junit.jupiter.api.TestInstance; |
| 20 | + |
| 21 | +@TestInstance(TestInstance.Lifecycle.PER_CLASS) |
| 22 | +@Tag("integration") |
| 23 | +@DisplayName("MindeeV2 –Integration Tests - Crop") |
| 24 | +class CropIT { |
| 25 | + |
| 26 | + private MindeeClientV2 mindeeClient; |
| 27 | + private String modelId; |
| 28 | + |
| 29 | + @BeforeAll |
| 30 | + void setUp() { |
| 31 | + String apiKey = System.getenv("MINDEE_V2_API_KEY"); |
| 32 | + modelId = System.getenv("MINDEE_V2_SE_TESTS_CROP_MODEL_ID"); |
| 33 | + mindeeClient = new MindeeClientV2(apiKey); |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + @DisplayName("Empty, multi-page PDF – enqueue & parse must succeed") |
| 38 | + void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedException { |
| 39 | + LocalInputSource source = new LocalInputSource( |
| 40 | + getResourcePath("file_types/pdf/multipage_cut-2.pdf") |
| 41 | + ); |
| 42 | + CropParameters params = CropParameters |
| 43 | + .builder(modelId) |
| 44 | + .alias("java_integration-test_crop_multipage") |
| 45 | + .pollingOptions( |
| 46 | + AsyncPollingOptions.builder().initialDelaySec(3.0).intervalSec(1.5).maxRetries(80).build() |
| 47 | + ) |
| 48 | + .build(); |
| 49 | + |
| 50 | + CropResponse response = mindeeClient.enqueueAndGetResult(CropResponse.class, source, params); |
| 51 | + assertNotNull(response); |
| 52 | + CropInference inference = response.getInference(); |
| 53 | + assertNotNull(inference); |
| 54 | + |
| 55 | + InferenceFile file = inference.getFile(); |
| 56 | + assertNotNull(file); |
| 57 | + assertEquals("multipage_cut-2.pdf", file.getName()); |
| 58 | + assertEquals(2, file.getPageCount()); |
| 59 | + |
| 60 | + assertNotNull(inference.getModel()); |
| 61 | + assertEquals(modelId, inference.getModel().getId()); |
| 62 | + |
| 63 | + CropResult result = inference.getResult(); |
| 64 | + assertNotNull(result); |
| 65 | + assertEquals(1, result.getCrops().size()); |
| 66 | + assertEquals("other", result.getCrops().get(0).getObjectType()); |
| 67 | + } |
| 68 | +} |
0 commit comments