RED-7241: adapted resize endpoints for multi-level dictionaries and added Junit tests and did some refactoring
This commit is contained in:
parent
5eba596815
commit
8701d24f96
@ -33,6 +33,9 @@ public class TypeProvider {
|
||||
}
|
||||
|
||||
public TypeValue testAndProvideType(DossierTemplateModel dossierTemplate, Dossier dossier, String typeName, boolean dossierDictionaryOnly) {
|
||||
return testAndProvideType(dossierTemplate, dossier, typeName, dossierDictionaryOnly, 100);
|
||||
}
|
||||
public TypeValue testAndProvideType(DossierTemplateModel dossierTemplate, Dossier dossier, String typeName, boolean dossierDictionaryOnly, int rank) {
|
||||
|
||||
var type = new CreateTypeValue();
|
||||
type.setType(typeName);
|
||||
@ -42,7 +45,7 @@ public class TypeProvider {
|
||||
type.setRecommendationHexColor("#aaaaaa");
|
||||
type.setSkippedHexColor("#aaaaaa");
|
||||
type.setHint(false);
|
||||
type.setRank(100);
|
||||
type.setRank(rank);
|
||||
type.setRecommendation(false);
|
||||
type.setCaseInsensitive(true);
|
||||
type.setDossierTemplateId(dossierTemplate.getId());
|
||||
@ -53,7 +56,7 @@ public class TypeProvider {
|
||||
var allTypes = dictionaryClient.getAllTypes(dossierTemplate.getDossierTemplateId(),dossier != null ? dossier.getId() : null,false);
|
||||
|
||||
var foundType =allTypes.getTypes().stream().filter(t -> t.getType().equalsIgnoreCase(typeName)).findAny();
|
||||
assertThat(foundType.isPresent()).isTrue();
|
||||
assertThat(foundType).isPresent();
|
||||
|
||||
return foundType.get();
|
||||
}
|
||||
|
||||
@ -9,10 +9,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.event.annotation.AfterTestExecution;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.client.DictionaryClient;
|
||||
@ -26,8 +28,12 @@ import com.iqser.red.service.peristence.v1.server.integration.service.TypeProvid
|
||||
import com.iqser.red.service.peristence.v1.server.integration.service.UserProvider;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.utils.AbstractPersistenceServerServiceTest;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.utils.MetricValidationUtils;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.DictionaryManagementService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.FileManagementStorageService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.RedactionLogService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.EntryPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileStatusPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.redactionlog.RedactionRequest;
|
||||
import com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.CreateTypeValue;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus;
|
||||
@ -92,9 +98,19 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
@Autowired
|
||||
private InternalDictionaryClient internalDictionaryClient;
|
||||
|
||||
@Autowired
|
||||
private RedactionLogService redactionLogService;
|
||||
|
||||
@Autowired
|
||||
private DictionaryManagementService dictionaryManagementService;
|
||||
|
||||
@Autowired
|
||||
private EntryPersistenceService entryPersistenceService;
|
||||
|
||||
|
||||
@Test
|
||||
public void testRemoveToDossierTemplateWithDossierDictionaryOnlyTrue(){
|
||||
public void testRemoveToDossierTemplateWithDossierDictionaryOnlyTrue() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
@ -116,20 +132,20 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
when(redactionLogMergeService.provideRedactionLog(Mockito.any())).thenReturn(redactionLog);
|
||||
|
||||
Assertions.assertThrows(FeignException.Forbidden.class, () ->
|
||||
manualRedactionClient.removeRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(RemoveRedactionRequest.builder().annotationId("AnnotationId").removeFromDictionary(true).removeFromAllDossiers(true).build())));//.get(0);
|
||||
|
||||
Assertions.assertThrows(FeignException.Forbidden.class,
|
||||
() -> manualRedactionClient.removeRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
Set.of(RemoveRedactionRequest.builder().annotationId("AnnotationId").removeFromDictionary(true).removeFromAllDossiers(true).build())));//.get(0);
|
||||
|
||||
var dossierTemplateDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId()), null);
|
||||
assertThat(dossierTemplateDictionary.getEntries().size()).isZero();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAddToDossierTemplateWithDossierDictionaryOnlyTrue(){
|
||||
public void testAddToDossierTemplateWithDossierDictionaryOnlyTrue() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
@ -155,11 +171,12 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
var dossierTemplateDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId()), null);
|
||||
assertThat(dossierTemplateDictionary.getEntries().size()).isZero();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAddToAllDossiersIfDeletedInOneDossier(){
|
||||
public void testAddToAllDossiersIfDeletedInOneDossier() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
@ -194,11 +211,12 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(dossierTemplateDictionary.getEntries().size()).isEqualTo(1);
|
||||
assertThat(dossierTemplateDictionary.getEntries().get(0).isDeleted()).isFalse();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAddToDossierDictionary(){
|
||||
public void testAddToDossierDictionary() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
@ -227,8 +245,10 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(dossierTemplateDictionary.getEntries().isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testManualRemoveFromAllDossiersAndUndo(){
|
||||
public void testManualRemoveFromAllDossiersAndUndo() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
@ -243,7 +263,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("Luke Skywalker"), false, dossier.getDossierId(), DictionaryEntryType.ENTRY);
|
||||
|
||||
var dossierTemplateDictionary = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
assertThat(dossierTemplateDictionary.getEntries()).containsExactlyInAnyOrder("Luke Skywalker","Darth Vader");
|
||||
assertThat(dossierTemplateDictionary.getEntries()).containsExactlyInAnyOrder("Luke Skywalker", "Darth Vader");
|
||||
|
||||
var dossierDictionary = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), dossier.getDossierId());
|
||||
assertThat(dossierDictionary.getEntries()).containsExactlyInAnyOrder("Luke Skywalker");
|
||||
@ -272,14 +292,15 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
manualRedactionClient.undo(dossier.getDossierId(), file.getFileId(), Set.of("AnnotationId"));
|
||||
|
||||
dossierTemplateDictionary = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
assertThat(dossierTemplateDictionary.getEntries()).containsExactlyInAnyOrder("Luke Skywalker","Darth Vader");
|
||||
assertThat(dossierTemplateDictionary.getEntries()).containsExactlyInAnyOrder("Luke Skywalker", "Darth Vader");
|
||||
dossierDictionary = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), dossier.getDossierId());
|
||||
assertThat(dossierDictionary.getEntries()).containsExactlyInAnyOrder("Luke Skywalker");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRemoveFromDossierIfOnlyDossierTemplateEntryExists(){
|
||||
public void testRemoveFromDossierIfOnlyDossierTemplateEntryExists() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
@ -313,7 +334,6 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
var dossierDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId(), dossier.getDossierId()), null);
|
||||
|
||||
|
||||
var dossierTemplateDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId()), null);
|
||||
assertThat(dossierTemplateDictionary.getEntries().size()).isEqualTo(2);
|
||||
assertThat(dossierTemplateDictionary.getEntries().stream().filter(e -> e.getValue().equals("Luke Skywalker")).findFirst().get().isDeleted()).isFalse();
|
||||
@ -324,7 +344,8 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testRemoveFromAllDossiersIfOnlyDossierEntryExists(){
|
||||
public void testRemoveFromAllDossiersIfOnlyDossierEntryExists() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
@ -336,7 +357,6 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
// dictionaryClient.addType(dossierDictionaryType, dossier.getDossierId());
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("Luke Skywalker"), false, dossier.getDossierId(), DictionaryEntryType.ENTRY);
|
||||
|
||||
|
||||
var redactionLog = new RedactionLog(1,
|
||||
1,
|
||||
List.of(RedactionLogEntry.builder().id("AnnotationId").type("test").value("Luke Skywalker").isDictionaryEntry(true).isDossierDictionaryEntry(true).build()),
|
||||
@ -362,9 +382,6 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void testManualRedaction3641() {
|
||||
@ -650,7 +667,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
assertThat(loadedRemoveRedaction2.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||
assertThat(dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null).getEntries().isEmpty());
|
||||
assertThat(loadedRemoveRedaction2.isRemoveFromDictionary()).isEqualTo(true);
|
||||
assertThat(loadedRemoveRedaction2.isRemoveFromDictionary()).isTrue();
|
||||
|
||||
manualRedactionClient.declineRequestBulk(dossier.getId(), file.getId(), Set.of(removeRedaction2.getAnnotationId()));
|
||||
loadedRemoveRedaction2 = manualRedactionClient.getManualRedactions(file.getDossierId(), file.getFileId())
|
||||
@ -815,4 +832,629 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
MetricValidationUtils.validateMetric(prometheusMeterRegistry, "redactmanager_calculateFlags", 1, null);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEnlargeResizeRedactionInDossierDictionary() {
|
||||
|
||||
// preparíng prerequisites
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
|
||||
var dossier1 = dossierTesterAndProvider.provideTestDossier(dossierTemplate, "Dossier 1");
|
||||
var dossier2 = dossierTesterAndProvider.provideTestDossier(dossierTemplate, "Dossier 2");
|
||||
|
||||
var file1 = fileTesterAndProvider.testAndProvideFile(dossier1);
|
||||
var file2 = fileTesterAndProvider.testAndProvideFile(dossier2);
|
||||
|
||||
var typeDosDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosDict", false, 99);
|
||||
var typeDosTempDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosTempDict", false, 101);
|
||||
|
||||
var userId = userProvider.getUserId();
|
||||
|
||||
var redactionDos = AddRedactionRequest.builder()
|
||||
.positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build()))
|
||||
.section("section test")
|
||||
.addToDictionary(true)
|
||||
.addToAllDossiers(false)
|
||||
.type(typeDosDict.getType())
|
||||
.dictionaryEntryType(DictionaryEntryType.ENTRY)
|
||||
.reason("1")
|
||||
.value("test redaction in dossier")
|
||||
.legalBasis("1")
|
||||
.rectangle(false)
|
||||
.sourceId("SourceId")
|
||||
.build();
|
||||
|
||||
var redactionDosTempDict = AddRedactionRequest.builder()
|
||||
.positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build()))
|
||||
.section("section test")
|
||||
.addToDictionary(true)
|
||||
.addToAllDossiers(false)
|
||||
.type(typeDosTempDict.getType())
|
||||
.dictionaryEntryType(DictionaryEntryType.ENTRY)
|
||||
.reason("1")
|
||||
.value("test redaction in dossier template")
|
||||
.legalBasis("1")
|
||||
.rectangle(false)
|
||||
.sourceId("SourceId")
|
||||
.build();
|
||||
|
||||
var addRedactions1 = manualRedactionClient.addRedactionBulk(dossier1.getDossierId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict));
|
||||
var loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId());
|
||||
|
||||
var redactionLog1 = new RedactionLog(1,
|
||||
1,
|
||||
List.of(RedactionLogEntry.builder()
|
||||
.id(addRedactions1.get(0).getAnnotationId())
|
||||
.type(typeDosDict.getType())
|
||||
.value("test redaction in dossier")
|
||||
.isDossierDictionaryEntry(true)
|
||||
.build(),
|
||||
RedactionLogEntry.builder()
|
||||
.id(addRedactions1.get(1).getAnnotationId())
|
||||
.type(typeDosTempDict.getType())
|
||||
.value("test redaction in dossier template")
|
||||
.isDictionaryEntry(true)
|
||||
.build()),
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier1.getId(), file1.getId(), FileType.REDACTION_LOG, redactionLog1);
|
||||
var redactionRequest1 = RedactionRequest.builder().dossierId(file1.getDossierId()).fileId(file1.getFileId()).dossierTemplateId(file1.getDossierTemplateId()).build();
|
||||
when(redactionLogMergeService.provideRedactionLog(redactionRequest1)).thenReturn(redactionLog1);
|
||||
when(redactionLogService.getRedactionLog(file1.getDossierId(), file1.getFileId(), true, true)).thenReturn(redactionLog1);
|
||||
|
||||
var addRedactions2 = manualRedactionClient.addRedactionBulk(dossier2.getDossierId(), file2.getFileId(), Set.of(redactionDosTempDict));
|
||||
var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId());
|
||||
|
||||
var redactionLog2 = new RedactionLog(1,
|
||||
1,
|
||||
List.of(RedactionLogEntry.builder()
|
||||
.id(addRedactions2.get(0).getAnnotationId())
|
||||
.type(typeDosTempDict.getType())
|
||||
.value("test redaction in dossier template")
|
||||
.isDictionaryEntry(true)
|
||||
.build()),
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier2.getId(), file2.getId(), FileType.REDACTION_LOG, redactionLog2);
|
||||
var redactionRequest2 = RedactionRequest.builder().dossierId(file2.getDossierId()).fileId(file2.getFileId()).dossierTemplateId(file2.getDossierTemplateId()).build();
|
||||
when(redactionLogMergeService.provideRedactionLog(redactionRequest2)).thenReturn(redactionLog2);
|
||||
when(redactionLogService.getRedactionLog(file2.getDossierId(), file2.getFileId(), true, true)).thenReturn(redactionLog2);
|
||||
|
||||
// resize redaction in dossier 1
|
||||
var resizeRedactionDosAndAddToAllDos = ResizeRedactionRequest.builder()
|
||||
.annotationId(addRedactions1.get(0).getAnnotationId())
|
||||
.comment("resized dossier redaction")
|
||||
.value("test redaction in dossier dictionary")
|
||||
.updateDictionary(true)
|
||||
.addToAllDossiers(true)
|
||||
.build();
|
||||
|
||||
var resizeRedactions = manualRedactionClient.resizeRedactionBulk(dossier1.getDossierId(), file1.getFileId(), Set.of(resizeRedactionDosAndAddToAllDos));
|
||||
|
||||
loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId());
|
||||
|
||||
assertThat(loadedRedactionsFile1.getResizeRedactions()).hasSize(1);
|
||||
assertThat(loadedRedactionsFile1.getResizeRedactions().stream().toList().get(0).getValue()).isEqualTo("test redaction in dossier dictionary");
|
||||
|
||||
var dictEntries = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier dictionary");
|
||||
assertThat(dictEntries.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier dictionary"))).isNotEmpty();
|
||||
|
||||
var dictionaryOfTypeDosDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosDictInDossier1.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier");
|
||||
|
||||
var dictionaryOfTypeDosDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosDictInDossier2.getEntries()).isEmpty();
|
||||
|
||||
var dictionaryOfTypeDosDictInDossierTemplate = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossierTemplate.getDossierTemplateId(), null);
|
||||
assertThat(dictionaryOfTypeDosDictInDossierTemplate.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosDictInDossierTemplate.getEntries().get(0)).isEqualTo("test redaction in dossier dictionary");
|
||||
|
||||
var dictionaryOfTypeDosTempDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template");
|
||||
|
||||
var dictionaryOfTypeDosTempDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template");
|
||||
|
||||
var dictionaryOfTypeDosTempDictInDossierTemplate = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossierTemplate.getDossierTemplateId(), null);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries()).isEmpty();
|
||||
|
||||
var mergedDictForTypeDosDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(mergedDictForTypeDosDictInDossier1.getEntries()).hasSize(2);
|
||||
assertThat(mergedDictForTypeDosDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier");
|
||||
assertThat(mergedDictForTypeDosDictInDossier1.getEntries().get(1)).isEqualTo("test redaction in dossier dictionary");
|
||||
|
||||
var mergedDictForTypeDosTempDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries()).hasSize(1);
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template");
|
||||
|
||||
var mergedDictForTypeDosDictInDossier2 = dictionaryClient.getMergedDictionaries(typeDosDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(mergedDictForTypeDosDictInDossier2.getEntries()).hasSize(1);
|
||||
assertThat(mergedDictForTypeDosDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier dictionary");
|
||||
|
||||
var mergedDictForTypeDosTempDictInDossier2 = dictionaryClient.getMergedDictionaries(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries()).hasSize(1);
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testShrinkResizeRedactionInDossierDictionary() {
|
||||
|
||||
// preparíng prerequisites
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
|
||||
var dossier1 = dossierTesterAndProvider.provideTestDossier(dossierTemplate, "Dossier 1");
|
||||
var dossier2 = dossierTesterAndProvider.provideTestDossier(dossierTemplate, "Dossier 2");
|
||||
|
||||
var file1 = fileTesterAndProvider.testAndProvideFile(dossier1);
|
||||
var file2 = fileTesterAndProvider.testAndProvideFile(dossier2);
|
||||
|
||||
var typeDosDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosDict", false, 99);
|
||||
var typeDosTempDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosTempDict", false, 101);
|
||||
|
||||
var userId = userProvider.getUserId();
|
||||
|
||||
var redactionDos = AddRedactionRequest.builder()
|
||||
.positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build()))
|
||||
.section("section test")
|
||||
.addToDictionary(true)
|
||||
.addToAllDossiers(false)
|
||||
.type(typeDosDict.getType())
|
||||
.dictionaryEntryType(DictionaryEntryType.ENTRY)
|
||||
.reason("1")
|
||||
.value("test redaction in dossier yayy")
|
||||
.legalBasis("1")
|
||||
.rectangle(false)
|
||||
.sourceId("SourceId")
|
||||
.build();
|
||||
|
||||
var redactionDosTempDict = AddRedactionRequest.builder()
|
||||
.positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build()))
|
||||
.section("section test")
|
||||
.addToDictionary(true)
|
||||
.addToAllDossiers(false)
|
||||
.type(typeDosTempDict.getType())
|
||||
.dictionaryEntryType(DictionaryEntryType.ENTRY)
|
||||
.reason("1")
|
||||
.value("test redaction in dossier template yayy")
|
||||
.legalBasis("1")
|
||||
.rectangle(false)
|
||||
.sourceId("SourceId")
|
||||
.build();
|
||||
|
||||
var addRedactions1 = manualRedactionClient.addRedactionBulk(dossier1.getDossierId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict));
|
||||
var loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId());
|
||||
|
||||
var redactionLog1 = new RedactionLog(1,
|
||||
1,
|
||||
List.of(RedactionLogEntry.builder()
|
||||
.id(addRedactions1.get(0).getAnnotationId())
|
||||
.type(typeDosDict.getType())
|
||||
.value("test redaction in dossier yayy")
|
||||
.isDossierDictionaryEntry(true)
|
||||
.build(),
|
||||
RedactionLogEntry.builder()
|
||||
.id(addRedactions1.get(1).getAnnotationId())
|
||||
.type(typeDosTempDict.getType())
|
||||
.value("test redaction in dossier template yayy")
|
||||
.isDictionaryEntry(true)
|
||||
.build()),
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier1.getId(), file1.getId(), FileType.REDACTION_LOG, redactionLog1);
|
||||
var redactionRequest1 = RedactionRequest.builder().dossierId(file1.getDossierId()).fileId(file1.getFileId()).dossierTemplateId(file1.getDossierTemplateId()).build();
|
||||
when(redactionLogMergeService.provideRedactionLog(redactionRequest1)).thenReturn(redactionLog1);
|
||||
when(redactionLogService.getRedactionLog(file1.getDossierId(), file1.getFileId(), true, true)).thenReturn(redactionLog1);
|
||||
|
||||
var addRedactions2 = manualRedactionClient.addRedactionBulk(dossier2.getDossierId(), file2.getFileId(), Set.of(redactionDosTempDict));
|
||||
var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId());
|
||||
|
||||
var redactionLog2 = new RedactionLog(1,
|
||||
1,
|
||||
List.of(RedactionLogEntry.builder()
|
||||
.id(addRedactions2.get(0).getAnnotationId())
|
||||
.type(typeDosTempDict.getType())
|
||||
.value("test redaction in dossier template yayy")
|
||||
.isDictionaryEntry(true)
|
||||
.build()),
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier2.getId(), file2.getId(), FileType.REDACTION_LOG, redactionLog2);
|
||||
var redactionRequest2 = RedactionRequest.builder().dossierId(file2.getDossierId()).fileId(file2.getFileId()).dossierTemplateId(file2.getDossierTemplateId()).build();
|
||||
when(redactionLogMergeService.provideRedactionLog(redactionRequest2)).thenReturn(redactionLog2);
|
||||
when(redactionLogService.getRedactionLog(file2.getDossierId(), file2.getFileId(), true, true)).thenReturn(redactionLog2);
|
||||
|
||||
// resize redaction in dossier 1
|
||||
var resizeRedactionDosAndAddToAllDos = ResizeRedactionRequest.builder()
|
||||
.annotationId(addRedactions1.get(0).getAnnotationId())
|
||||
.comment("resized dossier redaction")
|
||||
.value("test redaction in dossier")
|
||||
.updateDictionary(true)
|
||||
.addToAllDossiers(true)
|
||||
.build();
|
||||
|
||||
var resizeRedactions = manualRedactionClient.resizeRedactionBulk(dossier1.getDossierId(), file1.getFileId(), Set.of(resizeRedactionDosAndAddToAllDos));
|
||||
|
||||
loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId());
|
||||
|
||||
assertThat(loadedRedactionsFile1.getResizeRedactions()).hasSize(1);
|
||||
assertThat(loadedRedactionsFile1.getResizeRedactions().stream().toList().get(0).getValue()).isEqualTo("test redaction in dossier");
|
||||
|
||||
var dictEntries = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier yayy");
|
||||
assertThat(dictEntries.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier yayy") && dictionaryEntry.isDeleted())).hasSize(3);
|
||||
assertThat(dictEntries.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier yayy") && !dictionaryEntry.isDeleted())).isEmpty();
|
||||
var dictEntriesSec = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier");
|
||||
assertThat(dictEntriesSec.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier"))).isNotEmpty();
|
||||
|
||||
var dictionaryOfTypeDosDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosDictInDossier1.getEntries()).isEmpty();
|
||||
|
||||
var dictionaryOfTypeDosDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosDictInDossier2.getEntries()).isEmpty();
|
||||
|
||||
var dictionaryOfTypeDosDictInDossierTemplate = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossierTemplate.getDossierTemplateId(), null);
|
||||
assertThat(dictionaryOfTypeDosDictInDossierTemplate.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosDictInDossierTemplate.getEntries().get(0)).isEqualTo("test redaction in dossier");
|
||||
|
||||
var dictionaryOfTypeDosTempDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template yayy");
|
||||
|
||||
var dictionaryOfTypeDosTempDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template yayy");
|
||||
|
||||
var dictionaryOfTypeDosTempDictInDossierTemplate = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossierTemplate.getDossierTemplateId(), null);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries()).isEmpty();
|
||||
|
||||
var mergedDictForTypeDosDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(mergedDictForTypeDosDictInDossier1.getEntries()).hasSize(1);
|
||||
assertThat(mergedDictForTypeDosDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier");
|
||||
|
||||
var mergedDictForTypeDosTempDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries()).hasSize(1);
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template yayy");
|
||||
|
||||
var mergedDictForTypeDosDictInDossier2 = dictionaryClient.getMergedDictionaries(typeDosDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(mergedDictForTypeDosDictInDossier2.getEntries()).hasSize(1);
|
||||
assertThat(mergedDictForTypeDosDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier");
|
||||
|
||||
var mergedDictForTypeDosTempDictInDossier2 = dictionaryClient.getMergedDictionaries(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries()).hasSize(1);
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template yayy");
|
||||
|
||||
System.out.println("make some noise");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEnlargeResizeRedactionInDossierTemplateDictionary() {
|
||||
|
||||
// preparíng prerequisites
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
|
||||
var dossier1 = dossierTesterAndProvider.provideTestDossier(dossierTemplate, "Dossier 1");
|
||||
var dossier2 = dossierTesterAndProvider.provideTestDossier(dossierTemplate, "Dossier 2");
|
||||
|
||||
var file1 = fileTesterAndProvider.testAndProvideFile(dossier1);
|
||||
var file2 = fileTesterAndProvider.testAndProvideFile(dossier2);
|
||||
|
||||
var typeDosDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosDict", false , 99);
|
||||
var typeDosTempDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosTempDict", false, 101);
|
||||
|
||||
var userId = userProvider.getUserId();
|
||||
|
||||
var redactionDos = AddRedactionRequest.builder()
|
||||
.positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build()))
|
||||
.section("section test")
|
||||
.addToDictionary(true)
|
||||
.addToAllDossiers(false)
|
||||
.type(typeDosDict.getType())
|
||||
.dictionaryEntryType(DictionaryEntryType.ENTRY)
|
||||
.reason("1")
|
||||
.value("test redaction in dossier")
|
||||
.legalBasis("1")
|
||||
.rectangle(false)
|
||||
.sourceId("SourceId")
|
||||
.build();
|
||||
|
||||
var redactionDosTempDict = AddRedactionRequest.builder()
|
||||
.positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build()))
|
||||
.section("section test")
|
||||
.addToDictionary(true)
|
||||
.addToAllDossiers(false)
|
||||
.type(typeDosTempDict.getType())
|
||||
.dictionaryEntryType(DictionaryEntryType.ENTRY)
|
||||
.reason("1")
|
||||
.value("test redaction in dossier template")
|
||||
.legalBasis("1")
|
||||
.rectangle(false)
|
||||
.sourceId("SourceId")
|
||||
.build();
|
||||
|
||||
var addRedactions1 = manualRedactionClient.addRedactionBulk(dossier1.getDossierId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict));
|
||||
var loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId());
|
||||
|
||||
var redactionLog1 = new RedactionLog(1,
|
||||
1,
|
||||
List.of(RedactionLogEntry.builder().id(addRedactions1.get(0).getAnnotationId()).type(typeDosDict.getType()).value("test redaction in dossier").isDossierDictionaryEntry(true).build(),
|
||||
RedactionLogEntry.builder().id(addRedactions1.get(1).getAnnotationId()).type(typeDosTempDict.getType()).value("test redaction in dossier template").isDictionaryEntry(true).build()),
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier1.getId(), file1.getId(), FileType.REDACTION_LOG, redactionLog1);
|
||||
var redactionRequest1 = RedactionRequest.builder()
|
||||
.dossierId(file1.getDossierId())
|
||||
.fileId(file1.getFileId())
|
||||
.dossierTemplateId(file1.getDossierTemplateId())
|
||||
.build();
|
||||
when(redactionLogMergeService.provideRedactionLog(redactionRequest1)).thenReturn(redactionLog1);
|
||||
when(redactionLogService.getRedactionLog(file1.getDossierId(), file1.getFileId(), true, true)).thenReturn(redactionLog1);
|
||||
|
||||
var addRedactions2 = manualRedactionClient.addRedactionBulk(dossier2.getDossierId(), file2.getFileId(), Set.of(redactionDosTempDict));
|
||||
var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId());
|
||||
|
||||
var redactionLog2 = new RedactionLog(1,
|
||||
1,
|
||||
List.of(RedactionLogEntry.builder().id(addRedactions2.get(0).getAnnotationId()).type(typeDosTempDict.getType()).value("test redaction in dossier template").isDictionaryEntry(true).build()),
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier2.getId(), file2.getId(), FileType.REDACTION_LOG, redactionLog2);
|
||||
var redactionRequest2 = RedactionRequest.builder()
|
||||
.dossierId(file2.getDossierId())
|
||||
.fileId(file2.getFileId())
|
||||
.dossierTemplateId(file2.getDossierTemplateId())
|
||||
.build();
|
||||
when(redactionLogMergeService.provideRedactionLog(redactionRequest2)).thenReturn(redactionLog2);
|
||||
when(redactionLogService.getRedactionLog(file2.getDossierId(), file2.getFileId(), true, true)).thenReturn(redactionLog2);
|
||||
|
||||
// resize redaction in dossier dict
|
||||
var resizeRedactionDosTemp = ResizeRedactionRequest.builder()
|
||||
.annotationId(addRedactions2.get(0).getAnnotationId())
|
||||
.comment("resized dossier template redaction")
|
||||
.value("test redaction in dossier template dictionary")
|
||||
.updateDictionary(true)
|
||||
.addToAllDossiers(false)
|
||||
.build();
|
||||
|
||||
var resizeRedactions = manualRedactionClient.resizeRedactionBulk(dossier2.getDossierId(),
|
||||
file2.getFileId(),
|
||||
Set.of(resizeRedactionDosTemp
|
||||
));
|
||||
|
||||
|
||||
loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId());
|
||||
loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId());
|
||||
|
||||
assertThat(loadedRedactionsFile2.getResizeRedactions()).hasSize(1);
|
||||
assertThat(loadedRedactionsFile2.getResizeRedactions().stream().toList().get(0).getValue()).isEqualTo("test redaction in dossier template dictionary");
|
||||
|
||||
var dictEntries = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier template dictionary");
|
||||
assertThat(dictEntries.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier template dictionary"))).isNotEmpty();
|
||||
|
||||
var dictionaryOfTypeDosDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosDictInDossier1.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier");
|
||||
|
||||
var dictionaryOfTypeDosDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosDictInDossier2.getEntries()).isEmpty();
|
||||
|
||||
var dictionaryOfTypeDosDictInDossierTemplate = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossierTemplate.getDossierTemplateId(), null);
|
||||
assertThat(dictionaryOfTypeDosDictInDossierTemplate.getEntries()).isEmpty();
|
||||
|
||||
var dictionaryOfTypeDosTempDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template");
|
||||
|
||||
var dictionaryOfTypeDosTempDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template");
|
||||
|
||||
var dictionaryOfTypeDosTempDictInDossierTemplate = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossierTemplate.getDossierTemplateId(), null);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries().get(0)).isEqualTo("test redaction in dossier template dictionary");
|
||||
|
||||
var mergedDictForTypeDosDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(mergedDictForTypeDosDictInDossier1.getEntries()).hasSize(1);
|
||||
assertThat(mergedDictForTypeDosDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier");
|
||||
|
||||
var mergedDictForTypeDosTempDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries()).hasSize(2);
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template");
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries().get(1)).isEqualTo("test redaction in dossier template dictionary");
|
||||
|
||||
var mergedDictForTypeDosDictInDossier2 = dictionaryClient.getMergedDictionaries(typeDosDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(mergedDictForTypeDosDictInDossier2.getEntries()).isEmpty();
|
||||
|
||||
var mergedDictForTypeDosTempDictInDossier2 = dictionaryClient.getMergedDictionaries(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries()).hasSize(2);
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template");
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries().get(1)).isEqualTo("test redaction in dossier template dictionary");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testShrinkResizeRedactionInDossierTemplateDictionary() {
|
||||
|
||||
// preparíng prerequisites
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
|
||||
var dossier1 = dossierTesterAndProvider.provideTestDossier(dossierTemplate, "Dossier 1");
|
||||
var dossier2 = dossierTesterAndProvider.provideTestDossier(dossierTemplate, "Dossier 2");
|
||||
|
||||
var file1 = fileTesterAndProvider.testAndProvideFile(dossier1);
|
||||
var file2 = fileTesterAndProvider.testAndProvideFile(dossier2);
|
||||
|
||||
var typeDosDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosDict", false, 99);
|
||||
var typeDosTempDict = typeProvider.testAndProvideType(dossierTemplate, null, "typeDosTempDict", false, 101);
|
||||
|
||||
var userId = userProvider.getUserId();
|
||||
|
||||
var redactionDos = AddRedactionRequest.builder()
|
||||
.positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build()))
|
||||
.section("section test")
|
||||
.addToDictionary(true)
|
||||
.addToAllDossiers(false)
|
||||
.type(typeDosDict.getType())
|
||||
.dictionaryEntryType(DictionaryEntryType.ENTRY)
|
||||
.reason("1")
|
||||
.value("test redaction in dossier yayy")
|
||||
.legalBasis("1")
|
||||
.rectangle(false)
|
||||
.sourceId("SourceId")
|
||||
.build();
|
||||
|
||||
var redactionDosTempDict = AddRedactionRequest.builder()
|
||||
.positions(List.of(Rectangle.builder().page(1).topLeftY(1).topLeftX(1).height(1).width(1).build()))
|
||||
.section("section test")
|
||||
.addToDictionary(true)
|
||||
.addToAllDossiers(false)
|
||||
.type(typeDosTempDict.getType())
|
||||
.dictionaryEntryType(DictionaryEntryType.ENTRY)
|
||||
.reason("1")
|
||||
.value("test redaction in dossier template yayy")
|
||||
.legalBasis("1")
|
||||
.rectangle(false)
|
||||
.sourceId("SourceId")
|
||||
.build();
|
||||
|
||||
var addRedactions1 = manualRedactionClient.addRedactionBulk(dossier1.getDossierId(), file1.getId(), Set.of(redactionDos, redactionDosTempDict));
|
||||
var loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId());
|
||||
|
||||
var redactionLog1 = new RedactionLog(1,
|
||||
1,
|
||||
List.of(RedactionLogEntry.builder()
|
||||
.id(addRedactions1.get(0).getAnnotationId())
|
||||
.type(typeDosDict.getType())
|
||||
.value("test redaction in dossier yayy")
|
||||
.isDossierDictionaryEntry(true)
|
||||
.build(),
|
||||
RedactionLogEntry.builder()
|
||||
.id(addRedactions1.get(1).getAnnotationId())
|
||||
.type(typeDosTempDict.getType())
|
||||
.value("test redaction in dossier template yayy")
|
||||
.isDictionaryEntry(true)
|
||||
.build()),
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier1.getId(), file1.getId(), FileType.REDACTION_LOG, redactionLog1);
|
||||
var redactionRequest1 = RedactionRequest.builder().dossierId(file1.getDossierId()).fileId(file1.getFileId()).dossierTemplateId(file1.getDossierTemplateId()).build();
|
||||
when(redactionLogMergeService.provideRedactionLog(redactionRequest1)).thenReturn(redactionLog1);
|
||||
when(redactionLogService.getRedactionLog(file1.getDossierId(), file1.getFileId(), true, true)).thenReturn(redactionLog1);
|
||||
|
||||
var addRedactions2 = manualRedactionClient.addRedactionBulk(dossier2.getDossierId(), file2.getFileId(), Set.of(redactionDosTempDict));
|
||||
var loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId());
|
||||
|
||||
var redactionLog2 = new RedactionLog(1,
|
||||
1,
|
||||
List.of(RedactionLogEntry.builder()
|
||||
.id(addRedactions2.get(0).getAnnotationId())
|
||||
.type(typeDosTempDict.getType())
|
||||
.value("test redaction in dossier template yayy")
|
||||
.isDictionaryEntry(true)
|
||||
.build()),
|
||||
null,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier2.getId(), file2.getId(), FileType.REDACTION_LOG, redactionLog2);
|
||||
var redactionRequest2 = RedactionRequest.builder().dossierId(file2.getDossierId()).fileId(file2.getFileId()).dossierTemplateId(file2.getDossierTemplateId()).build();
|
||||
when(redactionLogMergeService.provideRedactionLog(redactionRequest2)).thenReturn(redactionLog2);
|
||||
when(redactionLogService.getRedactionLog(file2.getDossierId(), file2.getFileId(), true, true)).thenReturn(redactionLog2);
|
||||
|
||||
// resize redaction in dossier dict
|
||||
var resizeRedactionDosTemp = ResizeRedactionRequest.builder()
|
||||
.annotationId(addRedactions2.get(0).getAnnotationId())
|
||||
.comment("resized dossier template redaction")
|
||||
.value("test redaction in dossier template")
|
||||
.updateDictionary(true)
|
||||
.addToAllDossiers(false)
|
||||
.build();
|
||||
|
||||
var resizeRedactions = manualRedactionClient.resizeRedactionBulk(dossier2.getDossierId(),
|
||||
file2.getFileId(),
|
||||
Set.of(resizeRedactionDosTemp
|
||||
));
|
||||
|
||||
|
||||
loadedRedactionsFile1 = manualRedactionClient.getManualRedactions(file1.getDossierId(), file1.getFileId());
|
||||
loadedRedactionsFile2 = manualRedactionClient.getManualRedactions(file2.getDossierId(), file2.getFileId());
|
||||
|
||||
assertThat(loadedRedactionsFile2.getResizeRedactions()).hasSize(1);
|
||||
assertThat(loadedRedactionsFile2.getResizeRedactions().stream().toList().get(0).getValue()).isEqualTo("test redaction in dossier template");
|
||||
|
||||
var dictEntries = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier template yayy");
|
||||
assertThat(dictEntries.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier template yayy") && dictionaryEntry.isDeleted())).hasSize(1);
|
||||
assertThat(dictEntries.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier template yayy") && !dictionaryEntry.isDeleted())).hasSize(2);
|
||||
var dictEntriesSec = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplate.getDossierTemplateId(), "test redaction in dossier template");
|
||||
assertThat(dictEntriesSec.stream().filter(dictionaryEntry -> dictionaryEntry.getValue().equals("test redaction in dossier template"))).isNotEmpty();
|
||||
|
||||
var dictionaryOfTypeDosDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosDictInDossier1.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier yayy");
|
||||
|
||||
var dictionaryOfTypeDosDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosDictInDossier2.getEntries()).isEmpty();
|
||||
|
||||
var dictionaryOfTypeDosDictInDossierTemplate = dictionaryClient.getDictionaryForType(typeDosDict.getType(), dossierTemplate.getDossierTemplateId(), null);
|
||||
assertThat(dictionaryOfTypeDosDictInDossierTemplate.getEntries()).isEmpty();
|
||||
|
||||
var dictionaryOfTypeDosTempDictInDossier1 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template yayy");
|
||||
|
||||
var dictionaryOfTypeDosTempDictInDossier2 = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template yayy");
|
||||
|
||||
var dictionaryOfTypeDosTempDictInDossierTemplate = dictionaryClient.getDictionaryForType(typeDosTempDict.getType(), dossierTemplate.getDossierTemplateId(), null);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries()).hasSize(1);
|
||||
assertThat(dictionaryOfTypeDosTempDictInDossierTemplate.getEntries().get(0)).isEqualTo("test redaction in dossier template");
|
||||
|
||||
var mergedDictForTypeDosDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(mergedDictForTypeDosDictInDossier1.getEntries()).hasSize(1);
|
||||
assertThat(mergedDictForTypeDosDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier yayy");
|
||||
|
||||
var mergedDictForTypeDosTempDictInDossier1 = dictionaryClient.getMergedDictionaries(typeDosTempDict.getType(), dossier1.getDossierTemplateId(), dossier1.getDossierId());
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries()).hasSize(2);
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries().get(0)).isEqualTo("test redaction in dossier template");
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier1.getEntries().get(1)).isEqualTo("test redaction in dossier template yayy");
|
||||
|
||||
var mergedDictForTypeDosDictInDossier2 = dictionaryClient.getMergedDictionaries(typeDosDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(mergedDictForTypeDosDictInDossier2.getEntries()).isEmpty();
|
||||
|
||||
var mergedDictForTypeDosTempDictInDossier2 = dictionaryClient.getMergedDictionaries(typeDosTempDict.getType(), dossier2.getDossierTemplateId(), dossier2.getDossierId());
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries()).hasSize(2);
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries().get(0)).isEqualTo("test redaction in dossier template");
|
||||
assertThat(mergedDictForTypeDosTempDictInDossier2.getEntries().get(1)).isEqualTo("test redaction in dossier template yayy");
|
||||
|
||||
System.out.println("make some noise");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user