RED-7375:Integrate Table Parsing Service
* fixed end2end test by introducing sample table extractor response
This commit is contained in:
parent
3dd447ebef
commit
b7fe6fd3c4
@ -26,6 +26,8 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.swing.text.html.Option;
|
||||||
|
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@Import(AbstractTest.TestConfiguration.class)
|
@Import(AbstractTest.TestConfiguration.class)
|
||||||
@ -46,6 +48,8 @@ public abstract class AbstractTest {
|
|||||||
protected final static String ORIGIN_FILE_ID = "origin";
|
protected final static String ORIGIN_FILE_ID = "origin";
|
||||||
protected final static String TABLE_FILE_ID = "table";
|
protected final static String TABLE_FILE_ID = "table";
|
||||||
protected final static String IMAGE_FILE_ID = "image";
|
protected final static String IMAGE_FILE_ID = "image";
|
||||||
|
|
||||||
|
protected final static String TABLE_EXTRACTOR_FILE_ID = "extractedTable";
|
||||||
protected final static String STRUCTURE_FILE_ID = "structure";
|
protected final static String STRUCTURE_FILE_ID = "structure";
|
||||||
protected final static String TEXT_FILE_ID = "texts";
|
protected final static String TEXT_FILE_ID = "texts";
|
||||||
protected final static String POSITION_FILE_ID = "positions";
|
protected final static String POSITION_FILE_ID = "positions";
|
||||||
@ -62,6 +66,7 @@ public abstract class AbstractTest {
|
|||||||
.originFileStorageId(ORIGIN_FILE_ID)
|
.originFileStorageId(ORIGIN_FILE_ID)
|
||||||
.tablesFileStorageId(Optional.of(TABLE_FILE_ID))
|
.tablesFileStorageId(Optional.of(TABLE_FILE_ID))
|
||||||
.imagesFileStorageId(Optional.of(IMAGE_FILE_ID))
|
.imagesFileStorageId(Optional.of(IMAGE_FILE_ID))
|
||||||
|
.tableExtractorFileId(Optional.of(TABLE_EXTRACTOR_FILE_ID))
|
||||||
.structureFileStorageId(STRUCTURE_FILE_ID)
|
.structureFileStorageId(STRUCTURE_FILE_ID)
|
||||||
.textBlockFileStorageId(TEXT_FILE_ID)
|
.textBlockFileStorageId(TEXT_FILE_ID)
|
||||||
.positionBlockFileStorageId(POSITION_FILE_ID)
|
.positionBlockFileStorageId(POSITION_FILE_ID)
|
||||||
@ -89,7 +94,7 @@ public abstract class AbstractTest {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
protected LayoutParsingRequest prepareStorage(String file) {
|
protected LayoutParsingRequest prepareStorage(String file) {
|
||||||
|
|
||||||
return prepareStorage(file, "cv_table_parsing_response/empty.json", "image_service_response/empty.json");
|
return prepareStorage(file, "cv_table_parsing_response/empty.json", "image_service_response/empty.json","table_extractor_response/empty.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -107,6 +112,7 @@ public abstract class AbstractTest {
|
|||||||
.originFileStorageId(ORIGIN_FILE_ID)
|
.originFileStorageId(ORIGIN_FILE_ID)
|
||||||
.tablesFileStorageId(Optional.of(TABLE_FILE_ID))
|
.tablesFileStorageId(Optional.of(TABLE_FILE_ID))
|
||||||
.imagesFileStorageId(Optional.of(IMAGE_FILE_ID))
|
.imagesFileStorageId(Optional.of(IMAGE_FILE_ID))
|
||||||
|
.tableExtractorFileId(Optional.of(TABLE_EXTRACTOR_FILE_ID))
|
||||||
.structureFileStorageId(STRUCTURE_FILE_ID)
|
.structureFileStorageId(STRUCTURE_FILE_ID)
|
||||||
.textBlockFileStorageId(TEXT_FILE_ID)
|
.textBlockFileStorageId(TEXT_FILE_ID)
|
||||||
.positionBlockFileStorageId(POSITION_FILE_ID)
|
.positionBlockFileStorageId(POSITION_FILE_ID)
|
||||||
@ -117,21 +123,23 @@ public abstract class AbstractTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
protected LayoutParsingRequest prepareStorage(String file, String cvServiceResponseFile, String imageInfoFile) {
|
protected LayoutParsingRequest prepareStorage(String file, String cvServiceResponseFile, String imageInfoFile, String tableExtractorResponseFile) {
|
||||||
|
|
||||||
ClassPathResource pdfFileResource = new ClassPathResource(file);
|
ClassPathResource pdfFileResource = new ClassPathResource(file);
|
||||||
ClassPathResource cvServiceResponseFileResource = new ClassPathResource(cvServiceResponseFile);
|
ClassPathResource cvServiceResponseFileResource = new ClassPathResource(cvServiceResponseFile);
|
||||||
ClassPathResource imageInfoFileResource = new ClassPathResource(imageInfoFile);
|
ClassPathResource imageInfoFileResource = new ClassPathResource(imageInfoFile);
|
||||||
|
ClassPathResource tableExtractorResponseFileRessource = new ClassPathResource(tableExtractorResponseFile);
|
||||||
|
|
||||||
return prepareStorage(pdfFileResource.getInputStream(), cvServiceResponseFileResource.getInputStream(), imageInfoFileResource.getInputStream());
|
return prepareStorage(pdfFileResource.getInputStream(), cvServiceResponseFileResource.getInputStream(), imageInfoFileResource.getInputStream(),tableExtractorResponseFileRessource.getInputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
protected LayoutParsingRequest prepareStorage(InputStream fileStream, InputStream cvServiceResponseFileStream, InputStream imageInfoStream) {
|
protected LayoutParsingRequest prepareStorage(InputStream fileStream, InputStream cvServiceResponseFileStream, InputStream imageInfoStream, InputStream tableExtractorResponseFileStream) {
|
||||||
|
|
||||||
storageService.storeObject(TenantContext.getTenantId(), IMAGE_FILE_ID, imageInfoStream);
|
storageService.storeObject(TenantContext.getTenantId(), IMAGE_FILE_ID, imageInfoStream);
|
||||||
storageService.storeObject(TenantContext.getTenantId(), TABLE_FILE_ID, cvServiceResponseFileStream);
|
storageService.storeObject(TenantContext.getTenantId(), TABLE_FILE_ID, cvServiceResponseFileStream);
|
||||||
|
storageService.storeObject(TenantContext.getTenantId(), TABLE_EXTRACTOR_FILE_ID, tableExtractorResponseFileStream);
|
||||||
storageService.storeObject(TenantContext.getTenantId(), ORIGIN_FILE_ID, fileStream);
|
storageService.storeObject(TenantContext.getTenantId(), ORIGIN_FILE_ID, fileStream);
|
||||||
|
|
||||||
return buildDefaultLayoutParsingRequest(LayoutParsingType.REDACT_MANAGER);
|
return buildDefaultLayoutParsingRequest(LayoutParsingType.REDACT_MANAGER);
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public abstract class BuildDocumentTest extends AbstractTest {
|
|||||||
protected Document buildGraph(String filename, LayoutParsingType layoutParsingType) {
|
protected Document buildGraph(String filename, LayoutParsingType layoutParsingType) {
|
||||||
|
|
||||||
if (filename.equals("files/S-Metolachlor_RAR_01_Volume_1_2018-09-06.pdf")) {
|
if (filename.equals("files/S-Metolachlor_RAR_01_Volume_1_2018-09-06.pdf")) {
|
||||||
prepareStorage(filename, "cv_table_parsing_response/empty.json", "image_service_response/S-Metolachlor_RAR_01_Volume_1_2018-09-06.IMAGE_INFO.json");
|
prepareStorage(filename, "cv_table_parsing_response/empty.json", "image_service_response/S-Metolachlor_RAR_01_Volume_1_2018-09-06.IMAGE_INFO.json","table_extractor_response/empty.json");
|
||||||
} else {
|
} else {
|
||||||
prepareStorage(filename);
|
prepareStorage(filename);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"dossierId": "123",
|
||||||
|
"fileId": "123",
|
||||||
|
"operation": "table",
|
||||||
|
"targetFileExtension": "ORIGIN.pdf.gz",
|
||||||
|
"responseFileExtension": "TABLES.json.gz",
|
||||||
|
"extractedTableData": []
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user