RED-10200: update test

This commit is contained in:
maverickstuder 2024-12-03 11:55:37 +01:00
parent 8126e7f81e
commit bd97e60e0f

View File

@ -1653,7 +1653,17 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
.findFirst()
.get();
List<Rectangle> positions = List.of(Rectangle.builder().topLeftX(56.8f).topLeftY(293.564f).width(29.2922f).height(15.408f).page(1).build());
request.setManualRedactions(ManualRedactions.builder()
.entriesToAdd(Set.of(ManualRedactionEntry.builder()
.annotationId("newId")
.fileId(TEST_FILE_ID)
.user("user")
.requestDate(OffsetDateTime.now())
.value("David")
.type("CBI_author")
.positions(positions)
.build()))
.resizeRedactions(Set.of(ManualResizeRedaction.builder()
.updateDictionary(false)
.annotationId(davidKsenia.getId())
@ -1661,28 +1671,30 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
.user("user")
.requestDate(OffsetDateTime.now())
.value("David")
.positions(List.of(Rectangle.builder()
.topLeftX(56.8f)
.topLeftY(293.564f)
.width(29.2922f)
.height(15.408f)
.page(1)
.build()))
.positions(positions)
.addToAllDossiers(false)
.build()))
.build());
analyzeService.reanalyze(request);
entityLog = redactionStorageService.getEntityLog(TEST_DOSSIER_ID, TEST_FILE_ID);
var resizedEntity = entityLog.getEntityLogEntry()
.stream()
.filter(e -> e.getId().equals("newId"))
.findFirst()
.get();
var removedEntity = entityLog.getEntityLogEntry()
.stream()
.filter(e -> e.getId().equals(davidKsenia.getId()))
.findFirst()
.get();
assertEquals(resizedEntity.getState(), EntryState.APPLIED);
assertEquals(resizedEntity.getValue(), "David");
assertEquals(EntryState.APPLIED, resizedEntity.getState());
assertEquals("David", resizedEntity.getValue());
assertEquals(1, resizedEntity.getManualChanges().size());
assertEquals(resizedEntity.getManualChanges()
.get(0).getManualRedactionType(), ManualRedactionType.RESIZE);
assertEquals(1, resizedEntity.getEngines().size());
assertEquals(EntryState.REMOVED, removedEntity.getState());
}
@ -2353,8 +2365,10 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
assertEquals(entityLog.getEntityLogEntry().size(), 3);
}
@Test
public void testPurityRule() {
String EFSA_SANITISATION_RULES = loadFromClassPath("drools/efsa_sanitisation.drl");
when(rulesClient.getRules(TEST_DOSSIER_TEMPLATE_ID, RuleFileType.ENTITY)).thenReturn(JSONPrimitive.of(EFSA_SANITISATION_RULES));
@ -2363,7 +2377,10 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
analyzeService.analyze(request);
var entityLog = redactionStorageService.getEntityLog(TEST_DOSSIER_ID, TEST_FILE_ID);
var entriesCount = entityLog.getEntityLogEntry().stream().filter(e -> e.getValue().toLowerCase(Locale.ENGLISH).startsWith("purity")).collect(Collectors.toList()).size();
var entriesCount = entityLog.getEntityLogEntry()
.stream()
.filter(e -> e.getValue().toLowerCase(Locale.ENGLISH).startsWith("purity"))
.collect(Collectors.toList()).size();
assertEquals(7, entriesCount);
}