RED-9123: Improve performance of re-analysis (Spike)
This commit is contained in:
parent
3e75f3e5e7
commit
776a24306f
@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
description = "redaction-service-api-v1"
|
description = "redaction-service-api-v1"
|
||||||
val persistenceServiceVersion = "2.467.0"
|
val persistenceServiceVersion = "2.473.0"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.springframework:spring-web:6.0.12")
|
implementation("org.springframework:spring-web:6.0.12")
|
||||||
|
|||||||
@ -16,7 +16,7 @@ val layoutParserVersion = "0.141.0"
|
|||||||
val jacksonVersion = "2.15.2"
|
val jacksonVersion = "2.15.2"
|
||||||
val droolsVersion = "9.44.0.Final"
|
val droolsVersion = "9.44.0.Final"
|
||||||
val pdfBoxVersion = "3.0.0"
|
val pdfBoxVersion = "3.0.0"
|
||||||
val persistenceServiceVersion = "2.467.0"
|
val persistenceServiceVersion = "2.473.0"
|
||||||
val springBootStarterVersion = "3.1.5"
|
val springBootStarterVersion = "3.1.5"
|
||||||
val springCloudVersion = "4.0.4"
|
val springCloudVersion = "4.0.4"
|
||||||
val testContainersVersion = "1.19.7"
|
val testContainersVersion = "1.19.7"
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import com.iqser.red.service.dictionarymerge.commons.DictionaryEntry;
|
|||||||
import com.iqser.red.service.dictionarymerge.commons.DictionaryEntryModel;
|
import com.iqser.red.service.dictionarymerge.commons.DictionaryEntryModel;
|
||||||
import com.iqser.red.service.dictionarymerge.commons.DictionaryMergeService;
|
import com.iqser.red.service.dictionarymerge.commons.DictionaryMergeService;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.configuration.Colors;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.configuration.Colors;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.Type;
|
||||||
import com.iqser.red.service.redaction.v1.server.RedactionServiceSettings;
|
import com.iqser.red.service.redaction.v1.server.RedactionServiceSettings;
|
||||||
import com.iqser.red.service.redaction.v1.server.client.DictionaryClient;
|
import com.iqser.red.service.redaction.v1.server.client.DictionaryClient;
|
||||||
import com.iqser.red.service.redaction.v1.server.model.dictionary.Dictionary;
|
import com.iqser.red.service.redaction.v1.server.model.dictionary.Dictionary;
|
||||||
@ -97,8 +98,7 @@ public class DictionaryService {
|
|||||||
updateDictionaryEntry(dossierTemplateId, dossierDictionaryVersion, getVersion(dossierDictionary), dossierId);
|
updateDictionaryEntry(dossierTemplateId, dossierDictionaryVersion, getVersion(dossierDictionary), dossierId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DictionaryVersion.builder().dossierTemplateVersion(dossierTemplateDictionaryVersion).dossierVersion(dossierDictionaryVersion)
|
return DictionaryVersion.builder().dossierTemplateVersion(dossierTemplateDictionaryVersion).dossierVersion(dossierDictionaryVersion).build();
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -167,13 +167,18 @@ public class DictionaryService {
|
|||||||
try {
|
try {
|
||||||
DictionaryRepresentation dictionaryRepresentation = new DictionaryRepresentation();
|
DictionaryRepresentation dictionaryRepresentation = new DictionaryRepresentation();
|
||||||
|
|
||||||
var typeResponse = dossierId == null ? dictionaryClient.getAllTypesForDossierTemplate(dossierTemplateId, true) : dictionaryClient.getAllTypesForDossier(dossierId,
|
var typeResponse = dossierId == null ? dictionaryClient.getAllTypesForDossierTemplate(dossierTemplateId, currentVersion, true) : dictionaryClient.getAllTypesForDossier(
|
||||||
true);
|
dossierId,
|
||||||
|
currentVersion,
|
||||||
|
true);
|
||||||
if (CollectionUtils.isNotEmpty(typeResponse)) {
|
if (CollectionUtils.isNotEmpty(typeResponse)) {
|
||||||
|
|
||||||
|
String tenantId = TenantContext.getTenantId();
|
||||||
List<DictionaryModel> dictionary = typeResponse.stream()
|
List<DictionaryModel> dictionary = typeResponse.stream()
|
||||||
|
.parallel()
|
||||||
.map(t -> {
|
.map(t -> {
|
||||||
|
|
||||||
|
TenantContext.setTenantId(tenantId);
|
||||||
Optional<DictionaryModel> optionalOldModel;
|
Optional<DictionaryModel> optionalOldModel;
|
||||||
if (dossierId == null) {
|
if (dossierId == null) {
|
||||||
var representation = getDossierTemplateDictionary(dossierTemplateId);
|
var representation = getDossierTemplateDictionary(dossierTemplateId);
|
||||||
@ -193,7 +198,7 @@ public class DictionaryService {
|
|||||||
Set<DictionaryEntryModel> falsePositives = new HashSet<>();
|
Set<DictionaryEntryModel> falsePositives = new HashSet<>();
|
||||||
Set<DictionaryEntryModel> falseRecommendations = new HashSet<>();
|
Set<DictionaryEntryModel> falseRecommendations = new HashSet<>();
|
||||||
|
|
||||||
DictionaryEntries newEntries = getEntries(t.getId(), currentVersion);
|
DictionaryEntries newEntries = mapEntries(t);
|
||||||
|
|
||||||
var newValues = newEntries.getEntries()
|
var newValues = newEntries.getEntries()
|
||||||
.stream()
|
.stream()
|
||||||
@ -308,9 +313,7 @@ public class DictionaryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private DictionaryEntries getEntries(String typeId, Long fromVersion) {
|
private DictionaryEntries mapEntries(Type type) {
|
||||||
|
|
||||||
var type = dictionaryClient.getDictionaryForType(typeId, fromVersion);
|
|
||||||
|
|
||||||
Set<DictionaryEntryModel> entries = type.getEntries() != null ? new HashSet<>(type.getEntries()
|
Set<DictionaryEntryModel> entries = type.getEntries() != null ? new HashSet<>(type.getEntries()
|
||||||
.stream()
|
.stream()
|
||||||
@ -334,7 +337,7 @@ public class DictionaryService {
|
|||||||
entries.size(),
|
entries.size(),
|
||||||
falsePositives.size(),
|
falsePositives.size(),
|
||||||
falseRecommendations.size(),
|
falseRecommendations.size(),
|
||||||
typeId);
|
entries);
|
||||||
return new DictionaryEntries(entries, falsePositives, falseRecommendations);
|
return new DictionaryEntries(entries, falsePositives, falseRecommendations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,7 +403,9 @@ public class DictionaryService {
|
|||||||
return new Dictionary(mergedDictionaries.stream()
|
return new Dictionary(mergedDictionaries.stream()
|
||||||
.sorted(Comparator.comparingInt(DictionaryModel::getRank).reversed())
|
.sorted(Comparator.comparingInt(DictionaryModel::getRank).reversed())
|
||||||
.collect(Collectors.toList()),
|
.collect(Collectors.toList()),
|
||||||
DictionaryVersion.builder().dossierTemplateVersion(dossierTemplateRepresentation.getDictionaryVersion()).dossierVersion(dossierDictionaryVersion)
|
DictionaryVersion.builder()
|
||||||
|
.dossierTemplateVersion(dossierTemplateRepresentation.getDictionaryVersion())
|
||||||
|
.dossierVersion(dossierDictionaryVersion)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import java.util.function.Supplier;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.core.task.TaskExecutor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
|
||||||
@ -47,6 +48,8 @@ public class RedactionStorageService {
|
|||||||
|
|
||||||
private final EntityLogMongoService entityLogMongoService;
|
private final EntityLogMongoService entityLogMongoService;
|
||||||
|
|
||||||
|
private final TaskExecutor taskExecutor;
|
||||||
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public InputStream getStoredObject(String storageId) {
|
public InputStream getStoredObject(String storageId) {
|
||||||
@ -228,24 +231,24 @@ public class RedactionStorageService {
|
|||||||
Supplier<DocumentStructure> documentStructureSupplier = () -> storageService.readJSONObject(TenantContext.getTenantId(),
|
Supplier<DocumentStructure> documentStructureSupplier = () -> storageService.readJSONObject(TenantContext.getTenantId(),
|
||||||
StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_STRUCTURE),
|
StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_STRUCTURE),
|
||||||
DocumentStructure.class);
|
DocumentStructure.class);
|
||||||
CompletableFuture<DocumentStructure> documentStructureFuture = CompletableFuture.supplyAsync(documentStructureSupplier);
|
CompletableFuture<DocumentStructure> documentStructureFuture = CompletableFuture.supplyAsync(documentStructureSupplier, taskExecutor);
|
||||||
|
|
||||||
Supplier<DocumentTextData[]> documentTextDataSupplier = () -> storageService.readJSONObject(TenantContext.getTenantId(),
|
Supplier<DocumentTextData[]> documentTextDataSupplier = () -> storageService.readJSONObject(TenantContext.getTenantId(),
|
||||||
StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_TEXT),
|
StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_TEXT),
|
||||||
DocumentTextData[].class);
|
DocumentTextData[].class);
|
||||||
CompletableFuture<DocumentTextData[]> documentTextDataFuture = CompletableFuture.supplyAsync(documentTextDataSupplier);
|
CompletableFuture<DocumentTextData[]> documentTextDataFuture = CompletableFuture.supplyAsync(documentTextDataSupplier, taskExecutor);
|
||||||
|
|
||||||
Supplier<DocumentPositionData[]> documentPositionDataSupplier = () -> storageService.readJSONObject(TenantContext.getTenantId(),
|
Supplier<DocumentPositionData[]> documentPositionDataSupplier = () -> storageService.readJSONObject(TenantContext.getTenantId(),
|
||||||
StorageIdUtils.getStorageId(dossierId,
|
StorageIdUtils.getStorageId(dossierId,
|
||||||
fileId,
|
fileId,
|
||||||
FileType.DOCUMENT_POSITION),
|
FileType.DOCUMENT_POSITION),
|
||||||
DocumentPositionData[].class);
|
DocumentPositionData[].class);
|
||||||
CompletableFuture<DocumentPositionData[]> documentPositionDataFuture = CompletableFuture.supplyAsync(documentPositionDataSupplier);
|
CompletableFuture<DocumentPositionData[]> documentPositionDataFuture = CompletableFuture.supplyAsync(documentPositionDataSupplier, taskExecutor);
|
||||||
|
|
||||||
Supplier<DocumentPage[]> documentPageSupplier = () -> storageService.readJSONObject(TenantContext.getTenantId(),
|
Supplier<DocumentPage[]> documentPageSupplier = () -> storageService.readJSONObject(TenantContext.getTenantId(),
|
||||||
StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_PAGES),
|
StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_PAGES),
|
||||||
DocumentPage[].class);
|
DocumentPage[].class);
|
||||||
CompletableFuture<DocumentPage[]> documentPagesFuture = CompletableFuture.supplyAsync(documentPageSupplier);
|
CompletableFuture<DocumentPage[]> documentPagesFuture = CompletableFuture.supplyAsync(documentPageSupplier, taskExecutor);
|
||||||
|
|
||||||
CompletableFuture.allOf(documentStructureFuture, documentTextDataFuture, documentPositionDataFuture, documentPagesFuture).join();
|
CompletableFuture.allOf(documentStructureFuture, documentTextDataFuture, documentPositionDataFuture, documentPagesFuture).join();
|
||||||
|
|
||||||
|
|||||||
@ -186,7 +186,6 @@ public abstract class AbstractRedactionIntegrationTest {
|
|||||||
protected final Map<String, Long> reanlysisVersions = new HashMap<>();
|
protected final Map<String, Long> reanlysisVersions = new HashMap<>();
|
||||||
protected final Set<String> deleted = new HashSet<>();
|
protected final Set<String> deleted = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
@MockBean
|
@MockBean
|
||||||
protected RulesClient rulesClient;
|
protected RulesClient rulesClient;
|
||||||
|
|
||||||
@ -260,6 +259,9 @@ public abstract class AbstractRedactionIntegrationTest {
|
|||||||
true));
|
true));
|
||||||
when(dictionaryClient.getDictionaryForType(DOSSIER_AUTHOR_TYPE_ID, version)).then((Answer<Type>) invocation -> getDictionaryResponse(DICTIONARY_AUTHOR, true));
|
when(dictionaryClient.getDictionaryForType(DOSSIER_AUTHOR_TYPE_ID, version)).then((Answer<Type>) invocation -> getDictionaryResponse(DICTIONARY_AUTHOR, true));
|
||||||
|
|
||||||
|
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, version, true)).then((Answer<List<Type>>)invocation -> (getTypeResponseForTemplate()));
|
||||||
|
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, version, true)).then((Answer<List<Type>>)invocation -> ((getTypeResponseForDossier())));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -513,7 +515,7 @@ public abstract class AbstractRedactionIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected List<Type> getTypeResponse() {
|
protected List<Type> getTypeResponseForTemplate() {
|
||||||
|
|
||||||
return typeColorMap.entrySet()
|
return typeColorMap.entrySet()
|
||||||
.stream()
|
.stream()
|
||||||
@ -526,9 +528,62 @@ public abstract class AbstractRedactionIntegrationTest {
|
|||||||
.isCaseInsensitive(caseInSensitiveMap.get(typeColor.getKey()))
|
.isCaseInsensitive(caseInSensitiveMap.get(typeColor.getKey()))
|
||||||
.isRecommendation(recommendationTypeMap.get(typeColor.getKey()))
|
.isRecommendation(recommendationTypeMap.get(typeColor.getKey()))
|
||||||
.rank(rankTypeMap.get(typeColor.getKey()))
|
.rank(rankTypeMap.get(typeColor.getKey()))
|
||||||
|
.entries(toDictionaryEntry(dictionary.get(typeColor.getKey())))
|
||||||
.build())
|
.build())
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
protected List<Type> getTypeResponseForDossier() {
|
||||||
|
|
||||||
|
return List.of(Type.builder()
|
||||||
|
.id(IMPORTED_REDACTION_TYPE_ID)
|
||||||
|
.type(IMPORTED_REDACTION_INDICATOR)
|
||||||
|
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
||||||
|
.dossierId(TEST_DOSSIER_ID)
|
||||||
|
.hexColor("#ffe187")
|
||||||
|
.isHint(hintTypeMap.get(IMPORTED_REDACTION_INDICATOR))
|
||||||
|
.isCaseInsensitive(caseInSensitiveMap.get(IMPORTED_REDACTION_INDICATOR))
|
||||||
|
.isRecommendation(recommendationTypeMap.get(IMPORTED_REDACTION_INDICATOR))
|
||||||
|
.rank(rankTypeMap.get(IMPORTED_REDACTION_INDICATOR))
|
||||||
|
.entries(toDictionaryEntry(dossierDictionary.get(IMPORTED_REDACTION_INDICATOR)))
|
||||||
|
.build(),
|
||||||
|
Type.builder()
|
||||||
|
.id(DOSSIER_REDACTIONS_TYPE_ID)
|
||||||
|
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||||
|
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
||||||
|
.dossierId(TEST_DOSSIER_ID)
|
||||||
|
.hexColor("#ffe187")
|
||||||
|
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.entries(toDictionaryEntry(dossierDictionary.get(DOSSIER_REDACTIONS_INDICATOR)))
|
||||||
|
.build(),
|
||||||
|
Type.builder()
|
||||||
|
.id(DOSSIER_AUTHOR_TYPE_ID)
|
||||||
|
.type(DICTIONARY_AUTHOR)
|
||||||
|
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
||||||
|
.dossierId(TEST_DOSSIER_ID)
|
||||||
|
.hexColor("#ffe184")
|
||||||
|
.isHint(hintTypeMap.get(DICTIONARY_AUTHOR))
|
||||||
|
.isCaseInsensitive(caseInSensitiveMap.get(DICTIONARY_AUTHOR))
|
||||||
|
.isRecommendation(recommendationTypeMap.get(DICTIONARY_AUTHOR))
|
||||||
|
.rank(rankTypeMap.get(DICTIONARY_AUTHOR))
|
||||||
|
.entries(toDictionaryEntry(dossierDictionary.get(DICTIONARY_AUTHOR)))
|
||||||
|
.build(),
|
||||||
|
Type.builder()
|
||||||
|
.id(DOSSIER_PUBLISHED_INFORMATION_TYPE_ID)
|
||||||
|
.type(PUBLISHED_INFORMATION_INDICATOR)
|
||||||
|
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
||||||
|
.dossierId(TEST_DOSSIER_ID)
|
||||||
|
.hexColor("#ffe180")
|
||||||
|
.isHint(hintTypeMap.get(PUBLISHED_INFORMATION_INDICATOR))
|
||||||
|
.isCaseInsensitive(caseInSensitiveMap.get(PUBLISHED_INFORMATION_INDICATOR))
|
||||||
|
.isRecommendation(recommendationTypeMap.get(PUBLISHED_INFORMATION_INDICATOR))
|
||||||
|
.rank(rankTypeMap.get(PUBLISHED_INFORMATION_INDICATOR))
|
||||||
|
.entries(toDictionaryEntry(dossierDictionary.get(PUBLISHED_INFORMATION_INDICATOR)))
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
package com.iqser.red.service.redaction.v1.server;
|
package com.iqser.red.service.redaction.v1.server;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -100,19 +101,23 @@ public class AnalysisTest extends AbstractRedactionIntegrationTest {
|
|||||||
loadTypeForTest();
|
loadTypeForTest();
|
||||||
loadNerForTest();
|
loadNerForTest();
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, false)).thenReturn(getTypeResponse());
|
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, any(), false)).thenReturn(getTypeResponseForTemplate());
|
||||||
|
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, false)).thenReturn(List.of(Type.builder()
|
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, anyLong(), false)).thenReturn(List.of(Type.builder()
|
||||||
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
.id(DOSSIER_REDACTIONS_INDICATOR
|
||||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
+ ":"
|
||||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
+ TEST_DOSSIER_TEMPLATE_ID)
|
||||||
.hexColor("#ffe187")
|
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||||
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.hexColor("#ffe187")
|
||||||
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.isCaseInsensitive(caseInSensitiveMap.get(
|
||||||
.build()));
|
DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.isRecommendation(recommendationTypeMap.get(
|
||||||
|
DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.build()));
|
||||||
|
|
||||||
mockDictionaryCalls(null);
|
mockDictionaryCalls(null);
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,6 @@ import java.util.stream.Stream;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.kie.api.runtime.KieContainer;
|
import org.kie.api.runtime.KieContainer;
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
@ -130,7 +129,7 @@ public class DictionaryServiceTest {
|
|||||||
.map(t -> new DictionaryEntry(1, t, 2L, false, "type1"))
|
.map(t -> new DictionaryEntry(1, t, 2L, false, "type1"))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(anyString(), anyBoolean())).thenReturn(List.of(type1, type2));
|
when(dictionaryClient.getAllTypesForDossierTemplate(anyString(), any(), anyBoolean())).thenReturn(List.of(type1, type2));
|
||||||
when(dictionaryClient.getDictionaryForType("type1", null)).thenReturn(type1);
|
when(dictionaryClient.getDictionaryForType("type1", null)).thenReturn(type1);
|
||||||
when(dictionaryClient.getDictionaryForType("type2", null)).thenReturn(type2);
|
when(dictionaryClient.getDictionaryForType("type2", null)).thenReturn(type2);
|
||||||
when(dictionaryClient.getDictionaryForType("type1", 0L)).thenReturn(type1);
|
when(dictionaryClient.getDictionaryForType("type1", 0L)).thenReturn(type1);
|
||||||
@ -140,7 +139,7 @@ public class DictionaryServiceTest {
|
|||||||
var increments = dictionaryService.getDictionaryIncrements("dossierTemplateId", DictionaryVersion.builder().dossierTemplateVersion(0L).build(), null);
|
var increments = dictionaryService.getDictionaryIncrements("dossierTemplateId", DictionaryVersion.builder().dossierTemplateVersion(0L).build(), null);
|
||||||
|
|
||||||
when(dictionaryClient.getVersion(any())).thenReturn(1L);
|
when(dictionaryClient.getVersion(any())).thenReturn(1L);
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(anyString(), anyBoolean())).thenReturn(List.of(type1Updated));
|
when(dictionaryClient.getAllTypesForDossierTemplate(anyString(), any(), anyBoolean())).thenReturn(List.of(type1Updated));
|
||||||
when(dictionaryClient.getDictionaryForType("type1", 1L)).thenReturn(type1Updated);
|
when(dictionaryClient.getDictionaryForType("type1", 1L)).thenReturn(type1Updated);
|
||||||
|
|
||||||
dictionaryService.updateDictionary("dossierTemplateId", null);
|
dictionaryService.updateDictionary("dossierTemplateId", null);
|
||||||
@ -228,8 +227,8 @@ public class DictionaryServiceTest {
|
|||||||
assertThat(dossierEntries.size()).isEqualTo(3);
|
assertThat(dossierEntries.size()).isEqualTo(3);
|
||||||
dossierType.setEntries(dossierEntries);
|
dossierType.setEntries(dossierEntries);
|
||||||
|
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(anyString(), anyBoolean())).thenReturn(List.of(dtType));
|
when(dictionaryClient.getAllTypesForDossierTemplate(anyString(), any(), anyBoolean())).thenReturn(List.of(dtType));
|
||||||
when(dictionaryClient.getAllTypesForDossier(anyString(), anyBoolean())).thenReturn(List.of(dossierType));
|
when(dictionaryClient.getAllTypesForDossier(anyString(), any(), anyBoolean())).thenReturn(List.of(dossierType));
|
||||||
|
|
||||||
when(dictionaryClient.getDictionaryForType("type1", null)).thenReturn(dtType);
|
when(dictionaryClient.getDictionaryForType("type1", null)).thenReturn(dtType);
|
||||||
when(dictionaryClient.getDictionaryForType("dossierType", null)).thenReturn(dossierType);
|
when(dictionaryClient.getDictionaryForType("dossierType", null)).thenReturn(dossierType);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.iqser.red.service.redaction.v1.server;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -219,10 +220,10 @@ public class DocumineFloraTest extends AbstractRedactionIntegrationTest {
|
|||||||
loadTypeForTest();
|
loadTypeForTest();
|
||||||
loadNerForTest();
|
loadNerForTest();
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, true)).thenReturn(getTypeResponse());
|
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTypeResponseForTemplate());
|
||||||
|
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, true)).thenReturn(List.of(Type.builder()
|
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(List.of(Type.builder()
|
||||||
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.iqser.red.service.redaction.v1.server;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
@ -83,19 +84,10 @@ public class MigrationIntegrationTest extends BuildDocumentIntegrationTest {
|
|||||||
loadDictionaryForTest();
|
loadDictionaryForTest();
|
||||||
loadTypeForTest();
|
loadTypeForTest();
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, true)).thenReturn(getTypeResponse());
|
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTypeResponseForTemplate());
|
||||||
|
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, true)).thenReturn(List.of(Type.builder()
|
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(getTypeResponseForDossier());
|
||||||
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
|
||||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
|
||||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
|
||||||
.hexColor("#ffe187")
|
|
||||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
|
||||||
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
|
||||||
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
|
||||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
|
||||||
.build()));
|
|
||||||
|
|
||||||
mockDictionaryCalls(null);
|
mockDictionaryCalls(null);
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.iqser.red.service.redaction.v1.server;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -98,42 +99,10 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
|
|||||||
loadTypeForTest();
|
loadTypeForTest();
|
||||||
loadNerForTest();
|
loadNerForTest();
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, true)).thenReturn(getTypeResponse());
|
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTypeResponseForTemplate());
|
||||||
|
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, true)).thenReturn(List.of(Type.builder()
|
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(getTypeResponseForDossier());
|
||||||
.id(DOSSIER_REDACTIONS_TYPE_ID)
|
|
||||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
|
||||||
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
|
||||||
.dossierId(TEST_DOSSIER_ID)
|
|
||||||
.hexColor("#ffe187")
|
|
||||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
|
||||||
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
|
||||||
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
|
||||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
|
||||||
.build(),
|
|
||||||
Type.builder()
|
|
||||||
.id(DOSSIER_AUTHOR_TYPE_ID)
|
|
||||||
.type(DICTIONARY_AUTHOR)
|
|
||||||
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
|
||||||
.dossierId(TEST_DOSSIER_ID)
|
|
||||||
.hexColor("#ffe184")
|
|
||||||
.isHint(hintTypeMap.get(DICTIONARY_AUTHOR))
|
|
||||||
.isCaseInsensitive(caseInSensitiveMap.get(DICTIONARY_AUTHOR))
|
|
||||||
.isRecommendation(recommendationTypeMap.get(DICTIONARY_AUTHOR))
|
|
||||||
.rank(rankTypeMap.get(DICTIONARY_AUTHOR))
|
|
||||||
.build(),
|
|
||||||
Type.builder()
|
|
||||||
.id(DOSSIER_PUBLISHED_INFORMATION_TYPE_ID)
|
|
||||||
.type(PUBLISHED_INFORMATION_INDICATOR)
|
|
||||||
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
|
||||||
.dossierId(TEST_DOSSIER_ID)
|
|
||||||
.hexColor("#ffe180")
|
|
||||||
.isHint(hintTypeMap.get(PUBLISHED_INFORMATION_INDICATOR))
|
|
||||||
.isCaseInsensitive(caseInSensitiveMap.get(PUBLISHED_INFORMATION_INDICATOR))
|
|
||||||
.isRecommendation(recommendationTypeMap.get(PUBLISHED_INFORMATION_INDICATOR))
|
|
||||||
.rank(rankTypeMap.get(PUBLISHED_INFORMATION_INDICATOR))
|
|
||||||
.build()));
|
|
||||||
|
|
||||||
mockDictionaryCalls(null);
|
mockDictionaryCalls(null);
|
||||||
|
|
||||||
@ -264,6 +233,7 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
|
|||||||
assertThat(dictionary.get(PUBLISHED_INFORMATION_INDICATOR).contains("Press")).isFalse();
|
assertThat(dictionary.get(PUBLISHED_INFORMATION_INDICATOR).contains("Press")).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPublishedInformationRemovalAtDossierLevel() throws IOException {
|
public void testPublishedInformationRemovalAtDossierLevel() throws IOException {
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package com.iqser.red.service.redaction.v1.server;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.anyLong;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@ -118,19 +118,9 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
|||||||
loadTypeForTest();
|
loadTypeForTest();
|
||||||
loadNerForTest();
|
loadNerForTest();
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, true)).thenReturn(getTypeResponse());
|
|
||||||
|
|
||||||
when(dictionaryClient.getVersionForDossier(TEST_DOSSIER_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersionForDossier(TEST_DOSSIER_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, true)).thenReturn(List.of(Type.builder()
|
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(getTypeResponseForDossier());
|
||||||
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
|
||||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
|
||||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
|
||||||
.hexColor("#ffe187")
|
|
||||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
|
||||||
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
|
||||||
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
|
||||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
|
||||||
.build()));
|
|
||||||
|
|
||||||
mockDictionaryCalls(null);
|
mockDictionaryCalls(null);
|
||||||
|
|
||||||
@ -400,7 +390,7 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
|||||||
System.out.println("noExceptionShouldBeThrownForAnyFiles");
|
System.out.println("noExceptionShouldBeThrownForAnyFiles");
|
||||||
URL url = Thread.currentThread().getContextClassLoader().getResource("files");
|
URL url = Thread.currentThread().getContextClassLoader().getResource("files");
|
||||||
Path path = Paths.get(URI.create(url.toString()));
|
Path path = Paths.get(URI.create(url.toString()));
|
||||||
when(dictionaryClient.getDictionaryForType(anyString(), anyLong())).thenReturn(new Type());
|
when(dictionaryClient.getDictionaryForType(anyString(), any())).thenReturn(new Type());
|
||||||
Files.walk(path)//
|
Files.walk(path)//
|
||||||
.filter(currentPath -> currentPath.toString().endsWith(".pdf"))//
|
.filter(currentPath -> currentPath.toString().endsWith(".pdf"))//
|
||||||
.map(currentPath -> path.getParent().relativize(currentPath))//
|
.map(currentPath -> path.getParent().relativize(currentPath))//
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.iqser.red.service.redaction.v1.server;
|
package com.iqser.red.service.redaction.v1.server;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -74,19 +75,23 @@ public class RedactionIntegrationV2Test extends AbstractRedactionIntegrationTest
|
|||||||
loadTypeForTest();
|
loadTypeForTest();
|
||||||
loadNerForTest();
|
loadNerForTest();
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, false)).thenReturn(getTypeResponse());
|
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, any(), false)).thenReturn(getTypeResponseForTemplate());
|
||||||
|
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, false)).thenReturn(List.of(Type.builder()
|
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, any(), false)).thenReturn(List.of(Type.builder()
|
||||||
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
.id(DOSSIER_REDACTIONS_INDICATOR
|
||||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
+ ":"
|
||||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
+ TEST_DOSSIER_TEMPLATE_ID)
|
||||||
.hexColor("#ffe187")
|
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||||
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.hexColor("#ffe187")
|
||||||
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.isCaseInsensitive(caseInSensitiveMap.get(
|
||||||
.build()));
|
DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.isRecommendation(recommendationTypeMap.get(
|
||||||
|
DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.build()));
|
||||||
|
|
||||||
mockDictionaryCalls(null);
|
mockDictionaryCalls(null);
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.iqser.red.service.redaction.v1.server;
|
|||||||
|
|
||||||
import static java.util.Map.entry;
|
import static java.util.Map.entry;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -272,19 +273,19 @@ public class RulesTest {
|
|||||||
loadDictionaryForTest();
|
loadDictionaryForTest();
|
||||||
loadTypeForTest();
|
loadTypeForTest();
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, false)).thenReturn(getTypeResponse());
|
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, anyLong(), false)).thenReturn(getTypeResponse());
|
||||||
|
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, false)).thenReturn(List.of(Type.builder()
|
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, anyLong(), false)).thenReturn(List.of(Type.builder()
|
||||||
.id(DOSSIER_REDACTIONS + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
.id(DOSSIER_REDACTIONS + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||||
.type(DOSSIER_REDACTIONS)
|
.type(DOSSIER_REDACTIONS)
|
||||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||||
.hexColor("#ffe187")
|
.hexColor("#ffe187")
|
||||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS))
|
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS))
|
||||||
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS))
|
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS))
|
||||||
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS))
|
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS))
|
||||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS))
|
.rank(rankTypeMap.get(DOSSIER_REDACTIONS))
|
||||||
.build()));
|
.build()));
|
||||||
|
|
||||||
mockDictionaryCalls(null);
|
mockDictionaryCalls(null);
|
||||||
mockDictionaryCalls(0L);
|
mockDictionaryCalls(0L);
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.iqser.red.service.redaction.v1.server.document.graph;
|
|||||||
|
|
||||||
import static com.iqser.red.service.redaction.v1.server.utils.SeparatorUtils.boundaryIsSurroundedBySeparators;
|
import static com.iqser.red.service.redaction.v1.server.utils.SeparatorUtils.boundaryIsSurroundedBySeparators;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@ -109,10 +110,10 @@ public class DocumentPerformanceIntegrationTest extends BuildDocumentIntegration
|
|||||||
loadTypeForTest();
|
loadTypeForTest();
|
||||||
loadNerForTest();
|
loadNerForTest();
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, true)).thenReturn(getTypeResponse());
|
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTypeResponseForTemplate());
|
||||||
|
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, true)).thenReturn(List.of(Type.builder()
|
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(List.of(Type.builder()
|
||||||
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.iqser.red.service.redaction.v1.server.manualchanges;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.wildfly.common.Assert.assertTrue;
|
import static org.wildfly.common.Assert.assertTrue;
|
||||||
|
|
||||||
@ -122,20 +123,24 @@ public class ManualChangesEnd2EndTest extends AbstractRedactionIntegrationTest {
|
|||||||
loadTypeForTest();
|
loadTypeForTest();
|
||||||
loadNerForTest();
|
loadNerForTest();
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, false)).thenReturn(getTypeResponse());
|
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, any(), false)).thenReturn(getTypeResponseForTemplate());
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, true)).thenReturn(getTypeResponse());
|
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, any(), true)).thenReturn(getTypeResponseForTemplate());
|
||||||
|
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, false)).thenReturn(List.of(Type.builder()
|
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, any(), false)).thenReturn(List.of(Type.builder()
|
||||||
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
.id(DOSSIER_REDACTIONS_INDICATOR
|
||||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
+ ":"
|
||||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
+ TEST_DOSSIER_TEMPLATE_ID)
|
||||||
.hexColor("#ffe187")
|
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||||
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.hexColor("#ffe187")
|
||||||
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.isCaseInsensitive(caseInSensitiveMap.get(
|
||||||
.build()));
|
DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.isRecommendation(recommendationTypeMap.get(
|
||||||
|
DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.build()));
|
||||||
|
|
||||||
mockDictionaryCalls(null);
|
mockDictionaryCalls(null);
|
||||||
|
|
||||||
@ -240,7 +245,12 @@ public class ManualChangesEnd2EndTest extends AbstractRedactionIntegrationTest {
|
|||||||
|
|
||||||
String manualAddId = UUID.randomUUID().toString();
|
String manualAddId = UUID.randomUUID().toString();
|
||||||
|
|
||||||
manualRedactions.setIdsToRemove(Set.of(IdRemoval.builder().annotationId("5b940b2cb401ed9f5be6fc24f6e77bcf").fileId("fileId").user("user").requestDate(OffsetDateTime.now()).build()));
|
manualRedactions.setIdsToRemove(Set.of(IdRemoval.builder()
|
||||||
|
.annotationId("5b940b2cb401ed9f5be6fc24f6e77bcf")
|
||||||
|
.fileId("fileId")
|
||||||
|
.user("user")
|
||||||
|
.requestDate(OffsetDateTime.now())
|
||||||
|
.build()));
|
||||||
manualRedactions.setForceRedactions(Set.of(ManualForceRedaction.builder()
|
manualRedactions.setForceRedactions(Set.of(ManualForceRedaction.builder()
|
||||||
.annotationId("675eba69b0c2917de55462c817adaa05")
|
.annotationId("675eba69b0c2917de55462c817adaa05")
|
||||||
.fileId("fileId")
|
.fileId("fileId")
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.iqser.red.service.redaction.v1.server.realdata;
|
package com.iqser.red.service.redaction.v1.server.realdata;
|
||||||
|
|
||||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.nullable;
|
import static org.mockito.ArgumentMatchers.nullable;
|
||||||
@ -159,8 +160,8 @@ public class LiveDataIntegrationTest {
|
|||||||
t.setVersion(0L);
|
t.setVersion(0L);
|
||||||
});
|
});
|
||||||
|
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(anyString(), anyBoolean())).thenReturn(types);
|
when(dictionaryClient.getAllTypesForDossierTemplate(anyString(), any(), anyBoolean())).thenReturn(types);
|
||||||
when(dictionaryClient.getAllTypesForDossier(anyString(), anyBoolean())).thenReturn(new ArrayList<>());
|
when(dictionaryClient.getAllTypesForDossier(anyString(), any(), anyBoolean())).thenReturn(new ArrayList<>());
|
||||||
|
|
||||||
when(dictionaryClient.getColors(anyString())).thenReturn(objectMapper.readValue(new ClassPathResource(BASE_DIR + EFSA_SANITISATION_GFL_V1 + "colors.json").getInputStream(),
|
when(dictionaryClient.getColors(anyString())).thenReturn(objectMapper.readValue(new ClassPathResource(BASE_DIR + EFSA_SANITISATION_GFL_V1 + "colors.json").getInputStream(),
|
||||||
Colors.class));
|
Colors.class));
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.iqser.red.service.redaction.v1.server.service.document;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@ -98,19 +99,21 @@ public class UnprocessedChangesServiceTest extends AbstractRedactionIntegrationT
|
|||||||
loadTypeForTest();
|
loadTypeForTest();
|
||||||
loadNerForTest();
|
loadNerForTest();
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, true)).thenReturn(getTypeResponse());
|
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTypeResponseForTemplate());
|
||||||
|
|
||||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, true)).thenReturn(List.of(Type.builder()
|
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(List.of(Type.builder()
|
||||||
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||||
.hexColor("#ffe187")
|
.hexColor("#ffe187")
|
||||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||||
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.isCaseInsensitive(caseInSensitiveMap.get(
|
||||||
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
DOSSIER_REDACTIONS_INDICATOR))
|
||||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
.isRecommendation(recommendationTypeMap.get(
|
||||||
.build()));
|
DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||||
|
.build()));
|
||||||
|
|
||||||
mockDictionaryCalls(null);
|
mockDictionaryCalls(null);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user