RED-6725: deprecate FileType.TEXT, fix tests
This commit is contained in:
parent
06c52c7cfe
commit
8d881a5597
@ -97,6 +97,114 @@ public class RedactionLogController implements RedactionLogResource {
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@PreAuthorize("hasAuthority('" + READ_REDACTION_LOG + "')")
|
||||
public ResponseEntity<?> getDocumentText(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId) {
|
||||
|
||||
try {
|
||||
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.parseMediaType("application/zip"));
|
||||
|
||||
var fileStatus = fileStatusService.getStatus(fileId);
|
||||
String filename = fileStatus.getFilename();
|
||||
if (filename != null) {
|
||||
var index = filename.lastIndexOf(".");
|
||||
String prefix = filename.substring(0, index);
|
||||
filename = prefix + ".json";
|
||||
httpHeaders.add("Content-Disposition", "attachment; filename=" + prefix + ".zip");
|
||||
}
|
||||
|
||||
byte[] zipBytes = getZippedBytes(dossierId, fileId, filename, FileType.DOCUMENT_TEXT);
|
||||
return new ResponseEntity<>(zipBytes, httpHeaders, HttpStatus.OK);
|
||||
|
||||
} catch (FeignException e) {
|
||||
throw processFeignException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@PreAuthorize("hasAuthority('" + READ_REDACTION_LOG + "')")
|
||||
public ResponseEntity<?> getDocumentPositions(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId) {
|
||||
|
||||
try {
|
||||
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.parseMediaType("application/zip"));
|
||||
|
||||
var fileStatus = fileStatusService.getStatus(fileId);
|
||||
String filename = fileStatus.getFilename();
|
||||
if (filename != null) {
|
||||
var index = filename.lastIndexOf(".");
|
||||
String prefix = filename.substring(0, index);
|
||||
filename = prefix + ".json";
|
||||
httpHeaders.add("Content-Disposition", "attachment; filename=" + prefix + ".zip");
|
||||
}
|
||||
|
||||
byte[] zipBytes = getZippedBytes(dossierId, fileId, filename, FileType.DOCUMENT_POSITION);
|
||||
return new ResponseEntity<>(zipBytes, httpHeaders, HttpStatus.OK);
|
||||
|
||||
} catch (FeignException e) {
|
||||
throw processFeignException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@PreAuthorize("hasAuthority('" + READ_REDACTION_LOG + "')")
|
||||
public ResponseEntity<?> getDocumentStructure(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId) {
|
||||
|
||||
try {
|
||||
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.parseMediaType("application/zip"));
|
||||
|
||||
var fileStatus = fileStatusService.getStatus(fileId);
|
||||
String filename = fileStatus.getFilename();
|
||||
if (filename != null) {
|
||||
var index = filename.lastIndexOf(".");
|
||||
String prefix = filename.substring(0, index);
|
||||
filename = prefix + ".json";
|
||||
httpHeaders.add("Content-Disposition", "attachment; filename=" + prefix + ".zip");
|
||||
}
|
||||
|
||||
byte[] zipBytes = getZippedBytes(dossierId, fileId, filename, FileType.DOCUMENT_STRUCTURE);
|
||||
return new ResponseEntity<>(zipBytes, httpHeaders, HttpStatus.OK);
|
||||
|
||||
} catch (FeignException e) {
|
||||
throw processFeignException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@PreAuthorize("hasAuthority('" + READ_REDACTION_LOG + "')")
|
||||
public ResponseEntity<?> getDocumentPages(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId) {
|
||||
|
||||
try {
|
||||
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.parseMediaType("application/zip"));
|
||||
|
||||
var fileStatus = fileStatusService.getStatus(fileId);
|
||||
String filename = fileStatus.getFilename();
|
||||
if (filename != null) {
|
||||
var index = filename.lastIndexOf(".");
|
||||
String prefix = filename.substring(0, index);
|
||||
filename = prefix + ".json";
|
||||
httpHeaders.add("Content-Disposition", "attachment; filename=" + prefix + ".zip");
|
||||
}
|
||||
|
||||
byte[] zipBytes = getZippedBytes(dossierId, fileId, filename, FileType.DOCUMENT_PAGES);
|
||||
return new ResponseEntity<>(zipBytes, httpHeaders, HttpStatus.OK);
|
||||
|
||||
} catch (FeignException e) {
|
||||
throw processFeignException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@PreAuthorize("hasAuthority('" + READ_REDACTION_LOG + "')")
|
||||
public ResponseEntity<?> getSimplifiedSectionText(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId) {
|
||||
|
||||
@ -26,6 +26,10 @@ public interface RedactionLogResource {
|
||||
String REDACTION_LOG_PATH = ExternalApi.BASE_PATH + "/redactionLog";
|
||||
String SECTION_GRID_PATH = ExternalApi.BASE_PATH + "/sectionGrid";
|
||||
String SECTION_TEXT_PATH = ExternalApi.BASE_PATH + "/sectionText";
|
||||
String DOCUMENT_TEXT_PATH = ExternalApi.BASE_PATH + "/documentText";
|
||||
String DOCUMENT_POSITIONS_PATH = ExternalApi.BASE_PATH + "/documentPositions";
|
||||
String DOCUMENT_PAGES_PATH = ExternalApi.BASE_PATH + "/documentPages";
|
||||
String DOCUMENT_STRUCTURE_PATH = ExternalApi.BASE_PATH + "/documentStructure";
|
||||
String SIMPLIFIED_SECTION_TEXT_PATH = ExternalApi.BASE_PATH + "/simplifiedSectionText";
|
||||
|
||||
String FILE_ID = "fileId";
|
||||
@ -51,12 +55,37 @@ public interface RedactionLogResource {
|
||||
SectionGrid getSectionGrid(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId);
|
||||
|
||||
|
||||
@Deprecated
|
||||
@GetMapping(value = SECTION_TEXT_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE)
|
||||
@Operation(summary = "Gets the section text for a fileId", description = "None")
|
||||
@Operation(summary = "Gets the text blocks of a document for a fileId", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request " + "contains error."), @ApiResponse(responseCode = "404", description = "The section text is not found.")})
|
||||
ResponseEntity<?> getSectionText(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId);
|
||||
|
||||
|
||||
@GetMapping(value = DOCUMENT_TEXT_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE)
|
||||
@Operation(summary = "Gets the text blocks of a document for a fileId", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request " + "contains error."), @ApiResponse(responseCode = "404", description = "The section text is not found.")})
|
||||
ResponseEntity<?> getDocumentText(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId);
|
||||
|
||||
|
||||
@GetMapping(value = DOCUMENT_POSITIONS_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE)
|
||||
@Operation(summary = "Gets the positions of the text blocks of a document for a fileId", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request " + "contains error."), @ApiResponse(responseCode = "404", description = "The section text is not found.")})
|
||||
ResponseEntity<?> getDocumentPositions(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId);
|
||||
|
||||
|
||||
@GetMapping(value = DOCUMENT_STRUCTURE_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE)
|
||||
@Operation(summary = "Gets the document structure for a fileId", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request " + "contains error."), @ApiResponse(responseCode = "404", description = "The section text is not found.")})
|
||||
ResponseEntity<?> getDocumentStructure(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId);
|
||||
|
||||
|
||||
@GetMapping(value = DOCUMENT_PAGES_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE)
|
||||
@Operation(summary = "Gets the page information of a document for a fileId", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request " + "contains error."), @ApiResponse(responseCode = "404", description = "The section text is not found.")})
|
||||
ResponseEntity<?> getDocumentPages(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId);
|
||||
|
||||
|
||||
@GetMapping(value = SIMPLIFIED_SECTION_TEXT_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE)
|
||||
@Operation(summary = "Gets the simplified section text for a fileId", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request " + "contains error."), @ApiResponse(responseCode = "404", description = "The simplified section text is not found.")})
|
||||
|
||||
@ -37,7 +37,10 @@ public class AdminInterfaceController {
|
||||
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.SECTION_GRID);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.REDACTION_LOG);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.TEXT);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_PAGES);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_TEXT);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_POSITION);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_STRUCTURE);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.NER_ENTITIES);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.FIGURE);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.TABLES);
|
||||
@ -136,7 +139,10 @@ public class AdminInterfaceController {
|
||||
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.SECTION_GRID);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.REDACTION_LOG);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.TEXT);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_STRUCTURE);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_TEXT);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_PAGES);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_POSITION);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.NER_ENTITIES);
|
||||
|
||||
fileStatusService.setStatusFullReprocess(dossierId, fileId, true, true);
|
||||
|
||||
@ -184,8 +184,9 @@ public class FileStatusService {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fileManagementStorageService.objectExists(dossierId, fileId, FileType.DOCUMENT_STRUCTURE)) {
|
||||
if (!fileManagementStorageService.objectExists(dossierId, fileId, FileType.DOCUMENT_TEXT)) {
|
||||
var layoutParsingRequest = layoutParsingRequestFactory.build(dossierId, fileId, priority, dossier);
|
||||
setStatusFullProcessing(fileId);
|
||||
rabbitTemplate.convertAndSend(LAYOUT_PARSING_REQUEST_QUEUE, layoutParsingRequest);
|
||||
return;
|
||||
}
|
||||
@ -597,7 +598,10 @@ public class FileStatusService {
|
||||
|
||||
if (requiresStructureAnalysis) {
|
||||
log.info("Delete text and NER entities from file {} in dossier {}", fileId, dossierId);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.TEXT);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_POSITION);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_PAGES);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_TEXT);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_STRUCTURE);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.NER_ENTITIES);
|
||||
}
|
||||
|
||||
@ -635,7 +639,10 @@ public class FileStatusService {
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.REDACTION_LOG);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.SECTION_GRID);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.IMAGE_INFO);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.TEXT);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_STRUCTURE);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_PAGES);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_POSITION);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.DOCUMENT_TEXT);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.NER_ENTITIES);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.FIGURE);
|
||||
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.TABLES);
|
||||
|
||||
@ -462,7 +462,10 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
var type = typeProvider.testAndProvideType(dossierTemplate, null, "PII");
|
||||
|
||||
// assume file is already proccessed once, test that add to dict triggers reanalysis
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.TEXT, "{}");
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.DOCUMENT_TEXT, "{}");
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.DOCUMENT_PAGES, "{}");
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.DOCUMENT_STRUCTURE, "{}");
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.DOCUMENT_POSITION, "{}");
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.NER_ENTITIES, "{}");
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.IMAGE_INFO, "{}");
|
||||
fileStatusPersistenceService.updateProcessingStatus(file.getId(), ProcessingStatus.PROCESSED);
|
||||
|
||||
@ -1,209 +0,0 @@
|
||||
package com.iqser.red.service.peristence.v1.server.integration.tests;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.commons.jackson.ObjectMapperFactory;
|
||||
import com.iqser.red.service.pdftron.redaction.v1.api.model.highlights.TextHighlightConversionOperation;
|
||||
import com.iqser.red.service.pdftron.redaction.v1.api.model.highlights.TextHighlightConversionRequest;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.client.pdftronredactionservice.PDFTronClient;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.DossierEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.FileManagementStorageService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.FileStatusService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.IndexingService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.ManualRedactionProviderService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.ReanalysisRequiredStatusService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.ReanalysisService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.layoutparsing.LayoutParsingRequestFactory;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DictionaryPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DossierPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileAttributeConfigPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileStatusPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.LegalBasisMappingPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.RulesPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.ViewedPagesPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.annotations.AddRedactionPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.annotations.CommentPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.annotations.ForceRedactionPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.annotations.ImageRecategorizationPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.annotations.LegalBasisChangePersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.annotations.RemoveRedactionPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.annotations.ResizeRedactionPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.settings.FileManagementServiceSettings;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.utils.FileModelMapper;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.FileStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.Dossier;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileModel;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.ProcessingStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||
import com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter;
|
||||
|
||||
class ReanalysisServiceTest {
|
||||
|
||||
private ReanalysisService reanalysisService;
|
||||
|
||||
private FileStatusService fileStatusService;
|
||||
|
||||
@Mock
|
||||
private ReanalysisRequiredStatusService reanalysisRequiredStatusService;
|
||||
|
||||
@Mock
|
||||
private IndexingService indexingService;
|
||||
@Mock
|
||||
private DossierPersistenceService dossierPersistenceService;
|
||||
@Mock
|
||||
private PDFTronClient pdfTronClient;
|
||||
@Mock
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
@Mock
|
||||
private FileStatusPersistenceService fileStatusPersistenceService;
|
||||
@Mock
|
||||
private ObjectMapper objectMapper;
|
||||
@Mock
|
||||
private ManualRedactionProviderService manualRedactionProviderService;
|
||||
@Mock
|
||||
private FileManagementStorageService fileManagementStorageService;
|
||||
@Mock
|
||||
private LegalBasisChangePersistenceService legalBasisChangePersistenceService;
|
||||
@Mock
|
||||
private ImageRecategorizationPersistenceService imageRecategorizationPersistenceService;
|
||||
@Mock
|
||||
private CommentPersistenceService commentPersistenceService;
|
||||
@Mock
|
||||
private ForceRedactionPersistenceService forceRedactionPersistenceService;
|
||||
@Mock
|
||||
private RemoveRedactionPersistenceService removeRedactionPersistenceService;
|
||||
@Mock
|
||||
private AddRedactionPersistenceService addRedactionPersistenceService;
|
||||
@Mock
|
||||
private ResizeRedactionPersistenceService resizeRedactionPersistenceService;
|
||||
@Mock
|
||||
private FileAttributeConfigPersistenceService fileAttributeConfigPersistenceService;
|
||||
@Mock
|
||||
private FileManagementServiceSettings settings;
|
||||
@Mock
|
||||
private ViewedPagesPersistenceService viewedPagesPersistenceService;
|
||||
@Mock
|
||||
private FileManagementServiceSettings fileManagementServiceSettings;
|
||||
@Mock
|
||||
private DictionaryPersistenceService dictionaryPersistenceService;
|
||||
@Mock
|
||||
private RulesPersistenceService rulesPersistenceService;
|
||||
@Mock
|
||||
private LegalBasisMappingPersistenceService legalBasisMappingPersistenceService;
|
||||
@Mock
|
||||
private LayoutParsingRequestFactory layoutParsingRequestFactory;
|
||||
|
||||
private static String DOSSIER_ID = "123";
|
||||
private static String FILE_ID = "456";
|
||||
|
||||
private FileModel fileModel;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void stubAndCreate() {
|
||||
|
||||
fileModel = MagicConverter.convert(getTestFileEntity(), FileModel.class, new FileModelMapper());
|
||||
MockitoAnnotations.openMocks(this);
|
||||
|
||||
fileStatusService = new FileStatusService(fileStatusPersistenceService,
|
||||
dossierPersistenceService,
|
||||
rabbitTemplate,
|
||||
ObjectMapperFactory.create(),
|
||||
manualRedactionProviderService,
|
||||
fileManagementStorageService,
|
||||
legalBasisChangePersistenceService,
|
||||
imageRecategorizationPersistenceService,
|
||||
commentPersistenceService,
|
||||
forceRedactionPersistenceService,
|
||||
removeRedactionPersistenceService,
|
||||
addRedactionPersistenceService,
|
||||
resizeRedactionPersistenceService,
|
||||
fileAttributeConfigPersistenceService,
|
||||
settings,
|
||||
reanalysisRequiredStatusService,
|
||||
viewedPagesPersistenceService,
|
||||
fileManagementServiceSettings,
|
||||
layoutParsingRequestFactory);
|
||||
reanalysisService = new ReanalysisService(fileStatusService, dossierPersistenceService, indexingService, pdfTronClient, fileManagementStorageService);
|
||||
|
||||
when(fileStatusPersistenceService.getStatus(FILE_ID)).thenReturn(getTestFileEntity());
|
||||
when(dossierPersistenceService.getAndValidateDossier(DOSSIER_ID)).thenReturn(getDossierEntity());
|
||||
when(fileManagementStorageService.objectExists(DOSSIER_ID, FILE_ID, FileType.ORIGIN)).thenReturn(true);
|
||||
when(fileManagementStorageService.objectExists(DOSSIER_ID, FILE_ID, FileType.TEXT)).thenReturn(true);
|
||||
when(fileManagementStorageService.objectExists(DOSSIER_ID, FILE_ID, FileType.NER_ENTITIES)).thenReturn(true);
|
||||
when(settings.isFigureDetectionEnabled()).thenReturn(false);
|
||||
when(settings.isCvTableParsingEnabled()).thenReturn(false);
|
||||
when(settings.isImageServiceEnabled()).thenReturn(false);
|
||||
when(settings.isOcrByDefault()).thenReturn(false);
|
||||
when(dossierPersistenceService.findByDossierId(DOSSIER_ID)).thenReturn(getDossierEntity());
|
||||
when(reanalysisRequiredStatusService.enhanceFileStatusWithAnalysisRequirements(fileModel, true)) //
|
||||
.thenReturn(fileModel);
|
||||
}
|
||||
|
||||
|
||||
private Dossier getTestDossier() {
|
||||
|
||||
return Dossier.builder().id(DOSSIER_ID).build();
|
||||
}
|
||||
|
||||
|
||||
private static FileStatus getTestFileStatus() {
|
||||
|
||||
return FileStatus.builder().fileId(FILE_ID).dossierId(DOSSIER_ID).processingStatus(ProcessingStatus.PROCESSED).build();
|
||||
}
|
||||
|
||||
|
||||
private static FileEntity getTestFileEntity() {
|
||||
|
||||
return FileEntity.builder()
|
||||
.id(FILE_ID)
|
||||
.dossierId(DOSSIER_ID)
|
||||
.workflowStatus(WorkflowStatus.NEW)
|
||||
.fileAttributes(Collections.emptyList())
|
||||
.excluded(false)
|
||||
.processingStatus(ProcessingStatus.PROCESSED)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
private static DossierEntity getDossierEntity() {
|
||||
|
||||
return DossierEntity.builder().id(DOSSIER_ID).build();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void reanalysisTriggeredByHighLightConversionTest() {
|
||||
|
||||
var dossier = getTestDossier();
|
||||
var fileStatus = getTestFileStatus();
|
||||
|
||||
var textHighlightRequest = new TextHighlightConversionRequest(dossier.getDossierId(),
|
||||
fileStatus.getFileId(),
|
||||
Set.of("1", "2", "3"),
|
||||
TextHighlightConversionOperation.CONVERT);
|
||||
when(pdfTronClient.convertTextHighlights(textHighlightRequest)).thenReturn(true);
|
||||
|
||||
reanalysisService.convertTextHighlights(textHighlightRequest);
|
||||
assertThat(fileModel.getAnalysisVersion()).isEqualTo(1);
|
||||
verify(rabbitTemplate, times(1)).convertAndSend((String) any(), (Object) any());
|
||||
verify(fileStatusPersistenceService, times(1)).updateProcessingStatus(FILE_ID, ProcessingStatus.FULL_PROCESSING);
|
||||
}
|
||||
|
||||
}
|
||||
@ -9,7 +9,7 @@ public enum FileType {
|
||||
REDACTION_LOG(".json"),
|
||||
SIMPLIFIED_TEXT(".json"),
|
||||
SECTION_GRID(".json"),
|
||||
TEXT(".json"), // TODO: refactor this away
|
||||
TEXT(".json"), // deprecated file type, only present in legacy migrations
|
||||
NER_ENTITIES(".json"),
|
||||
IMAGE_INFO(".json"),
|
||||
IMPORTED_REDACTIONS(".json"),
|
||||
@ -17,6 +17,7 @@ public enum FileType {
|
||||
FIGURE(".json"),
|
||||
TABLES(".json"),
|
||||
COMPONENTS(".json"),
|
||||
// document is split into 4 files, all should be overridden/deleted at the same time
|
||||
DOCUMENT_TEXT(".json"),
|
||||
DOCUMENT_STRUCTURE(".json"),
|
||||
DOCUMENT_POSITION(".json"),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user