RED-9140 - Fixed and more tests
This commit is contained in:
parent
4a9297cfd7
commit
3dc11886ff
@ -449,14 +449,14 @@ public class EntityLogMergeService {
|
|||||||
|
|
||||||
if (!Strings.isNullOrEmpty(recategorization.getLegalBasis())) {
|
if (!Strings.isNullOrEmpty(recategorization.getLegalBasis())) {
|
||||||
boolean isHint = isHint(entityLogEntry.getType(), dossier);
|
boolean isHint = isHint(entityLogEntry.getType(), dossier);
|
||||||
entityLogEntry.setLegalBasis(recategorization.getLegalBasis());
|
|
||||||
entityLogEntry.setState(isHint ? EntryState.SKIPPED : EntryState.APPLIED);
|
|
||||||
ChangeFactory.addPropertyChanges(change,
|
ChangeFactory.addPropertyChanges(change,
|
||||||
PropertyChange.builder()
|
PropertyChange.builder()
|
||||||
.property("legalBasis")
|
.property("legalBasis")
|
||||||
.oldValue(entityLogEntry.getLegalBasis())
|
.oldValue(entityLogEntry.getLegalBasis())
|
||||||
.newValue(recategorization.getLegalBasis())
|
.newValue(recategorization.getLegalBasis())
|
||||||
.build());
|
.build());
|
||||||
|
entityLogEntry.setLegalBasis(recategorization.getLegalBasis());
|
||||||
|
entityLogEntry.setState(isHint ? EntryState.SKIPPED : EntryState.APPLIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeFactory.addPropertyChanges(change, PropertyChange.builder().property("state").oldValue(entryState.name()).newValue(entityLogEntry.getState().name()).build());
|
ChangeFactory.addPropertyChanges(change, PropertyChange.builder().property("state").oldValue(entryState.name()).newValue(entityLogEntry.getState().name()).build());
|
||||||
|
|||||||
@ -52,6 +52,7 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations
|
|||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.IdRemoval;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.IdRemoval;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualForceRedaction;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualForceRedaction;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualLegalBasisChange;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualLegalBasisChange;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualRecategorization;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualRedactionEntry;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualRedactionEntry;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualResizeRedaction;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualResizeRedaction;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileModel;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileModel;
|
||||||
@ -117,10 +118,11 @@ public class EntityLogMergeTest {
|
|||||||
String entryToResizeId = UUID.randomUUID().toString();
|
String entryToResizeId = UUID.randomUUID().toString();
|
||||||
String entryLegalBasisId = UUID.randomUUID().toString();
|
String entryLegalBasisId = UUID.randomUUID().toString();
|
||||||
String forceRedactionId = UUID.randomUUID().toString();
|
String forceRedactionId = UUID.randomUUID().toString();
|
||||||
|
String entryToRecategorizeId = UUID.randomUUID().toString();
|
||||||
|
|
||||||
ManualRedactions manualRedactions = provideManualRedactions(entryToAddId, entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, fileId, rectangleToAddId);
|
ManualRedactions manualRedactions = provideManualRedactions(entryToAddId, entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, fileId, rectangleToAddId, entryToRecategorizeId);
|
||||||
|
|
||||||
var entityLog = provideEntityLog(entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, false);
|
var entityLog = provideEntityLog(entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, entryToRecategorizeId, false);
|
||||||
|
|
||||||
when(manualRedactionProviderService.getManualRedactions(any(), any())).thenReturn(manualRedactions);
|
when(manualRedactionProviderService.getManualRedactions(any(), any())).thenReturn(manualRedactions);
|
||||||
when(fileStatusService.getStatus(fileId)).thenReturn(FileModel.builder().excluded(false).dossierStatusId(dossierTemplateId).id(fileId).build());
|
when(fileStatusService.getStatus(fileId)).thenReturn(FileModel.builder().excluded(false).dossierStatusId(dossierTemplateId).id(fileId).build());
|
||||||
@ -186,6 +188,8 @@ public class EntityLogMergeTest {
|
|||||||
.get(0).getManualRedactionType(), ManualRedactionType.RESIZE);
|
.get(0).getManualRedactionType(), ManualRedactionType.RESIZE);
|
||||||
assertEquals(resizeEntryLogEntry.getChanges()
|
assertEquals(resizeEntryLogEntry.getChanges()
|
||||||
.get(0).getType(), ChangeType.RESIZED);
|
.get(0).getType(), ChangeType.RESIZED);
|
||||||
|
assertEquals(resizeEntryLogEntry.getChanges().get(0).getPropertyChanges().get("value"), "Darth Vader -> Random");
|
||||||
|
assertEquals(resizeEntryLogEntry.getChanges().get(0).getPropertyChanges().get("positions"), "[1.0, 1.0, 1.0, 1.0, 1] -> [2.0, 2.0, 2.0, 2.0, 1]");
|
||||||
assertTrue(resizeEntryLogEntry.getEngines().contains(Engine.MANUAL));
|
assertTrue(resizeEntryLogEntry.getEngines().contains(Engine.MANUAL));
|
||||||
|
|
||||||
var optionalLegalBasisEntryLogEntry = response.getEntityLogEntry()
|
var optionalLegalBasisEntryLogEntry = response.getEntityLogEntry()
|
||||||
@ -201,6 +205,7 @@ public class EntityLogMergeTest {
|
|||||||
.get(0).getManualRedactionType(), ManualRedactionType.LEGAL_BASIS_CHANGE);
|
.get(0).getManualRedactionType(), ManualRedactionType.LEGAL_BASIS_CHANGE);
|
||||||
assertEquals(legalBasisEntryLogEntry.getChanges()
|
assertEquals(legalBasisEntryLogEntry.getChanges()
|
||||||
.get(0).getType(), ChangeType.LEGAL_BASIS_CHANGE);
|
.get(0).getType(), ChangeType.LEGAL_BASIS_CHANGE);
|
||||||
|
assertEquals(legalBasisEntryLogEntry.getChanges().get(0).getPropertyChanges().get("legalBasis"), "legalBasis -> New legal basis");
|
||||||
assertTrue(legalBasisEntryLogEntry.getEngines().contains(Engine.MANUAL));
|
assertTrue(legalBasisEntryLogEntry.getEngines().contains(Engine.MANUAL));
|
||||||
|
|
||||||
var optionalForceRedactionEntryLogEntry = response.getEntityLogEntry()
|
var optionalForceRedactionEntryLogEntry = response.getEntityLogEntry()
|
||||||
@ -216,6 +221,8 @@ public class EntityLogMergeTest {
|
|||||||
.get(0).getManualRedactionType(), ManualRedactionType.FORCE);
|
.get(0).getManualRedactionType(), ManualRedactionType.FORCE);
|
||||||
assertEquals(forceRedactionEntryLogEntry.getChanges()
|
assertEquals(forceRedactionEntryLogEntry.getChanges()
|
||||||
.get(0).getType(), ChangeType.FORCE_REDACT);
|
.get(0).getType(), ChangeType.FORCE_REDACT);
|
||||||
|
assertEquals(forceRedactionEntryLogEntry.getChanges().get(0).getPropertyChanges().get("legalBasis"), "null -> Force");
|
||||||
|
assertEquals(forceRedactionEntryLogEntry.getChanges().get(0).getPropertyChanges().get("state"), "SKIPPED -> APPLIED");
|
||||||
assertTrue(forceRedactionEntryLogEntry.getEngines().contains(Engine.MANUAL));
|
assertTrue(forceRedactionEntryLogEntry.getEngines().contains(Engine.MANUAL));
|
||||||
|
|
||||||
var optionalRectangleEntryLogEntry = response.getEntityLogEntry()
|
var optionalRectangleEntryLogEntry = response.getEntityLogEntry()
|
||||||
@ -233,6 +240,22 @@ public class EntityLogMergeTest {
|
|||||||
.get(0).getManualRedactionType(), ManualRedactionType.ADD);
|
.get(0).getManualRedactionType(), ManualRedactionType.ADD);
|
||||||
assertTrue(rectangleEntryLogEntry.getEngines().contains(Engine.MANUAL));
|
assertTrue(rectangleEntryLogEntry.getEngines().contains(Engine.MANUAL));
|
||||||
|
|
||||||
|
var optionalRecategorizationEntryLogEntry = response.getEntityLogEntry()
|
||||||
|
.stream()
|
||||||
|
.filter(entityLogEntry1 -> entityLogEntry1.getId().equals(entryToRecategorizeId))
|
||||||
|
.findFirst();
|
||||||
|
var recategorizationEntryLogEntry = optionalRecategorizationEntryLogEntry.get();
|
||||||
|
assertEquals(recategorizationEntryLogEntry.getLegalBasis(), "New legal basis");
|
||||||
|
assertEquals(recategorizationEntryLogEntry.getEntryType(), EntryType.ENTITY);
|
||||||
|
assertEquals(recategorizationEntryLogEntry.getType(), "PII");
|
||||||
|
assertEquals(recategorizationEntryLogEntry.getState(), EntryState.APPLIED);
|
||||||
|
assertEquals(recategorizationEntryLogEntry.getManualChanges()
|
||||||
|
.get(0).getManualRedactionType(), ManualRedactionType.RECATEGORIZE);
|
||||||
|
assertEquals(recategorizationEntryLogEntry.getChanges()
|
||||||
|
.get(0).getType(), ChangeType.RECATEGORIZE);
|
||||||
|
assertEquals(recategorizationEntryLogEntry.getChanges().get(0).getPropertyChanges().get("legalBasis"), "legalBasis -> New legal basis");
|
||||||
|
assertEquals(recategorizationEntryLogEntry.getChanges().get(0).getPropertyChanges().get("type"), "CBI_author -> PII");
|
||||||
|
assertTrue(recategorizationEntryLogEntry.getEngines().contains(Engine.MANUAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -248,6 +271,7 @@ public class EntityLogMergeTest {
|
|||||||
String entryToResizeId = UUID.randomUUID().toString();
|
String entryToResizeId = UUID.randomUUID().toString();
|
||||||
String entryLegalBasisId = UUID.randomUUID().toString();
|
String entryLegalBasisId = UUID.randomUUID().toString();
|
||||||
String forceRedactionId = UUID.randomUUID().toString();
|
String forceRedactionId = UUID.randomUUID().toString();
|
||||||
|
String entryToRecategorizeId = UUID.randomUUID().toString();
|
||||||
|
|
||||||
ManualRedactions manualRedactions = provideManualRedactions(entryLegalBasisId,
|
ManualRedactions manualRedactions = provideManualRedactions(entryLegalBasisId,
|
||||||
entryToRemoveId,
|
entryToRemoveId,
|
||||||
@ -255,9 +279,9 @@ public class EntityLogMergeTest {
|
|||||||
entryLegalBasisId,
|
entryLegalBasisId,
|
||||||
forceRedactionId,
|
forceRedactionId,
|
||||||
fileId,
|
fileId,
|
||||||
rectangleToAddId);
|
rectangleToAddId, entryToRecategorizeId);
|
||||||
|
|
||||||
var entityLog = provideEntityLog(entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, true);
|
var entityLog = provideEntityLog(entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, entryToRecategorizeId, true);
|
||||||
|
|
||||||
when(manualRedactionProviderService.getManualRedactions(any(), any())).thenReturn(manualRedactions);
|
when(manualRedactionProviderService.getManualRedactions(any(), any())).thenReturn(manualRedactions);
|
||||||
when(fileStatusService.getStatus(fileId)).thenReturn(FileModel.builder().excluded(false).dossierStatusId(dossierTemplateId).id(fileId).build());
|
when(fileStatusService.getStatus(fileId)).thenReturn(FileModel.builder().excluded(false).dossierStatusId(dossierTemplateId).id(fileId).build());
|
||||||
@ -307,6 +331,7 @@ public class EntityLogMergeTest {
|
|||||||
String entryToResizeId = UUID.randomUUID().toString();
|
String entryToResizeId = UUID.randomUUID().toString();
|
||||||
String entryLegalBasisId = UUID.randomUUID().toString();
|
String entryLegalBasisId = UUID.randomUUID().toString();
|
||||||
String forceRedactionId = UUID.randomUUID().toString();
|
String forceRedactionId = UUID.randomUUID().toString();
|
||||||
|
String entryToRecategorizeId = UUID.randomUUID().toString();
|
||||||
|
|
||||||
ManualRedactions manualRedactions = new ManualRedactions();
|
ManualRedactions manualRedactions = new ManualRedactions();
|
||||||
List<Rectangle> positions = new ArrayList<>();
|
List<Rectangle> positions = new ArrayList<>();
|
||||||
@ -322,7 +347,7 @@ public class EntityLogMergeTest {
|
|||||||
.fileId("file")
|
.fileId("file")
|
||||||
.build()));
|
.build()));
|
||||||
|
|
||||||
var entityLog = provideEntityLog(entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, false);
|
var entityLog = provideEntityLog(entryToRemoveId, entryToResizeId, entryLegalBasisId, forceRedactionId, entryToRecategorizeId, false);
|
||||||
|
|
||||||
when(manualRedactionProviderService.getManualRedactions(any(), any())).thenReturn(manualRedactions);
|
when(manualRedactionProviderService.getManualRedactions(any(), any())).thenReturn(manualRedactions);
|
||||||
when(fileStatusService.getStatus(fileId)).thenReturn(FileModel.builder().excluded(false).dossierStatusId(dossierTemplateId).id(fileId).build());
|
when(fileStatusService.getStatus(fileId)).thenReturn(FileModel.builder().excluded(false).dossierStatusId(dossierTemplateId).id(fileId).build());
|
||||||
@ -347,7 +372,7 @@ public class EntityLogMergeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private EntityLog provideEntityLog(String entryToRemoveId, String entryToResizeId, String entryLegalBasisId, String forceRedactionId, boolean dictEntry) {
|
private EntityLog provideEntityLog(String entryToRemoveId, String entryToResizeId, String entryLegalBasisId, String forceRedactionId, String entryToRecategorizeId, boolean dictEntry) {
|
||||||
|
|
||||||
List<Position> positions = new ArrayList<>();
|
List<Position> positions = new ArrayList<>();
|
||||||
positions.add(new Position(1, 1, 1, 1, 1));
|
positions.add(new Position(1, 1, 1, 1, 1));
|
||||||
@ -378,15 +403,27 @@ public class EntityLogMergeTest {
|
|||||||
.state(EntryState.APPLIED)
|
.state(EntryState.APPLIED)
|
||||||
.dictionaryEntry(dictEntry)
|
.dictionaryEntry(dictEntry)
|
||||||
.positions(positions)
|
.positions(positions)
|
||||||
|
.legalBasis("legalBasis")
|
||||||
.build(),
|
.build(),
|
||||||
EntityLogEntry.builder()
|
EntityLogEntry.builder()
|
||||||
.id(forceRedactionId)
|
.id(forceRedactionId)
|
||||||
.type("manual")
|
.type("manual")
|
||||||
.value("Darth Luke")
|
.value("Darth Luke")
|
||||||
.entryType(EntryType.ENTITY)
|
.entryType(EntryType.ENTITY)
|
||||||
|
.state(EntryState.SKIPPED)
|
||||||
|
.dictionaryEntry(dictEntry)
|
||||||
|
.positions(positions)
|
||||||
|
.build(),
|
||||||
|
EntityLogEntry.builder()
|
||||||
|
.id(entryToRecategorizeId)
|
||||||
|
.type("manual")
|
||||||
|
.value("Darth Luke")
|
||||||
|
.entryType(EntryType.ENTITY)
|
||||||
.state(EntryState.APPLIED)
|
.state(EntryState.APPLIED)
|
||||||
.dictionaryEntry(dictEntry)
|
.dictionaryEntry(dictEntry)
|
||||||
.positions(positions)
|
.positions(positions)
|
||||||
|
.legalBasis("legalBasis")
|
||||||
|
.type("CBI_author")
|
||||||
.build()),
|
.build()),
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
0,
|
0,
|
||||||
@ -402,7 +439,7 @@ public class EntityLogMergeTest {
|
|||||||
String entryLegalBasisId,
|
String entryLegalBasisId,
|
||||||
String forceRedactionId,
|
String forceRedactionId,
|
||||||
String fileId,
|
String fileId,
|
||||||
String rectangleToAddId) {
|
String rectangleToAddId, String entryToRecategorizeId) {
|
||||||
|
|
||||||
List<Rectangle> positions = new ArrayList<>();
|
List<Rectangle> positions = new ArrayList<>();
|
||||||
positions.add(new Rectangle(2, 2, 2, 2, 1));
|
positions.add(new Rectangle(2, 2, 2, 2, 1));
|
||||||
@ -465,6 +502,14 @@ public class EntityLogMergeTest {
|
|||||||
.user("User")
|
.user("User")
|
||||||
.fileId("file")
|
.fileId("file")
|
||||||
.build()))
|
.build()))
|
||||||
|
.recategorizations(Set.of(ManualRecategorization.builder()
|
||||||
|
.annotationId(entryToRecategorizeId)
|
||||||
|
.fileId(fileId)
|
||||||
|
.legalBasis("New legal basis")
|
||||||
|
.requestDate(OffsetDateTime.now())
|
||||||
|
.user("User")
|
||||||
|
.type("PII")
|
||||||
|
.build()))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user