Pull request #116: RED-2664 All manual Redactions deleted after toggling enable/disable-redaction

Merge in RED/persistence-service from bugfix/RED-2664 to master

* commit '121d1b7f2515f3ce2832fe0e2335b375446359ee':
  RED-2664 All manual Redactions deleted after toggling enable/disable-redaction
This commit is contained in:
Corina Olariu 2021-11-17 08:55:46 +01:00 committed by Timo Bejan
commit ce1553bb77
2 changed files with 34 additions and 2 deletions

View File

@ -27,8 +27,6 @@ public class ExcludeFromAnalysisService {
if (!excluded) {
// if file has been re-enabled - process it
fileStatusService.setStatusFullReprocess(dossierId, fileId, 2);
} else {
fileStatusService.wipeFileData(dossierId, fileId);
}
}

View File

@ -240,4 +240,38 @@ public class FileTest extends AbstractPersistenceServerServiceTest {
assertThat(activeFiles.size()).isEqualTo(0);
}
@Test
public void testToggleEnableRedactionTwice() {
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
String dossierId = dossier.getId();
var file = fileTesterAndProvider.testAndProvideFile(dossier);
String fileId = file.getId();
var type = typeProvider.testAndProvideType(dossierTemplate, null, "manual");
String typeId = type.getId();
assertThat(fileClient.getAllStatuses().size()).isEqualTo(1);
var addRedaction = manualRedactionClient.addAddRedaction(dossierId, fileId, AddRedactionRequest.builder().addToDictionary(true)
.addToDossierDictionary(false).comment("comment").status(AnnotationStatus.REQUESTED).typeId(typeId).user("user").reason("1").value("test").legalBasis("1").build());
var loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId());
assertThat(manualRedactionClient.getAddRedaction(fileId, addRedaction.getAnnotationId()).getFileId()).isEqualTo(loadedFile.getId());
fileClient.toggleExclusion(dossier.getId(), file.getId(), true);
loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId());
assertThat(loadedFile.isExcluded()).isTrue();
assertThat(manualRedactionClient.getAddRedaction(fileId, addRedaction.getAnnotationId()).getFileId()).isEqualTo(loadedFile.getId());
fileClient.toggleExclusion(dossier.getId(), file.getId(), false);
loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId());
assertThat(loadedFile.isExcluded()).isFalse();
assertThat(manualRedactionClient.getAddRedaction(fileId, addRedaction.getAnnotationId()).getFileId()).isEqualTo(loadedFile.getId());
}
}