RED-9140 - Correctly distinct between ChangeType REMOVED and IGNORED during EntityLog merge
This commit is contained in:
parent
2f35d2b218
commit
0c4ebbd6b9
@ -387,19 +387,22 @@ public class EntityLogMergeService {
|
|||||||
public void mergeIdToRemove(IdRemoval idRemoval, EntityLogEntry entityLogEntry, int analysisNumber) {
|
public void mergeIdToRemove(IdRemoval idRemoval, EntityLogEntry entityLogEntry, int analysisNumber) {
|
||||||
|
|
||||||
List<Change> changes = new ArrayList<>();
|
List<Change> changes = new ArrayList<>();
|
||||||
changes.add(ChangeFactory.toChange(ChangeType.REMOVED,
|
Change change = ChangeFactory.toChange(ChangeType.IGNORED,
|
||||||
OffsetDateTime.now(),
|
OffsetDateTime.now(),
|
||||||
analysisNumber,
|
analysisNumber,
|
||||||
PropertyChange.builder().property("state").oldValue(entityLogEntry.getState().name()).newValue(EntryState.IGNORED.name()).build()));
|
PropertyChange.builder().property("state").oldValue(entityLogEntry.getState().name()).newValue(EntryState.IGNORED.name()).build());
|
||||||
addChanges(entityLogEntry, changes);
|
|
||||||
|
|
||||||
entityLogEntry.setState(EntryState.IGNORED);
|
entityLogEntry.setState(EntryState.IGNORED);
|
||||||
//special case, only for add local and remove only
|
//special case, only for add local and remove only
|
||||||
if (!entityLogEntry.getEngines().isEmpty() && Set.of(Engine.MANUAL).containsAll(entityLogEntry.getEngines())) {
|
if (!entityLogEntry.getEngines().isEmpty() && Set.of(Engine.MANUAL).containsAll(entityLogEntry.getEngines())) {
|
||||||
entityLogEntry.setState(EntryState.REMOVED);
|
entityLogEntry.setState(EntryState.REMOVED);
|
||||||
|
change.setType(ChangeType.REMOVED);
|
||||||
}
|
}
|
||||||
entityLogEntry.getEngines().add(Engine.MANUAL);
|
entityLogEntry.getEngines().add(Engine.MANUAL);
|
||||||
entityLogEntry.getManualChanges().add(ManualChangeFactory.toLocalManualChange(idRemoval, 0));
|
entityLogEntry.getManualChanges().add(ManualChangeFactory.toLocalManualChange(idRemoval, 0));
|
||||||
|
|
||||||
|
changes.add(change);
|
||||||
|
addChanges(entityLogEntry, changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -172,7 +172,7 @@ public class EntityLogMergeTest {
|
|||||||
assertEquals(removeEntryLogEntry.getManualChanges()
|
assertEquals(removeEntryLogEntry.getManualChanges()
|
||||||
.get(0).getManualRedactionType(), ManualRedactionType.REMOVE);
|
.get(0).getManualRedactionType(), ManualRedactionType.REMOVE);
|
||||||
assertEquals(removeEntryLogEntry.getChanges()
|
assertEquals(removeEntryLogEntry.getChanges()
|
||||||
.get(0).getType(), ChangeType.REMOVED);
|
.get(0).getType(), ChangeType.IGNORED);
|
||||||
assertTrue(removeEntryLogEntry.getEngines().contains(Engine.MANUAL));
|
assertTrue(removeEntryLogEntry.getEngines().contains(Engine.MANUAL));
|
||||||
|
|
||||||
var optionalResizeEntryLogEntry = response.getEntityLogEntry()
|
var optionalResizeEntryLogEntry = response.getEntityLogEntry()
|
||||||
@ -672,6 +672,63 @@ public class EntityLogMergeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIgnoreType() {
|
||||||
|
|
||||||
|
String dossierId = "dossierId";
|
||||||
|
String dossierTemplateId = "dossierTemplateId";
|
||||||
|
|
||||||
|
String entryId = UUID.randomUUID().toString();
|
||||||
|
|
||||||
|
ManualRedactions manualRedactions = ManualRedactions.builder()
|
||||||
|
.idsToRemove(Set.of(IdRemoval.builder()
|
||||||
|
.annotationId(entryId)
|
||||||
|
.fileId("file")
|
||||||
|
.requestDate(OffsetDateTime.now())
|
||||||
|
.user("user")
|
||||||
|
.build()))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
var entityLog = new EntityLog(1,
|
||||||
|
1,
|
||||||
|
Lists.newArrayList(EntityLogEntry.builder()
|
||||||
|
.id(entryId)
|
||||||
|
.type("CBI_author")
|
||||||
|
.value("value")
|
||||||
|
.entryType(EntryType.ENTITY)
|
||||||
|
.state(EntryState.APPLIED)
|
||||||
|
.dictionaryEntry(true)
|
||||||
|
.positions(List.of(new Position(1, 1, 1, 1, 1)))
|
||||||
|
.build()),
|
||||||
|
Collections.emptyList(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
|
||||||
|
when(manualRedactionProviderService.getManualRedactions(any(), any())).thenReturn(manualRedactions);
|
||||||
|
when(fileStatusService.getStatus(FILE_ID)).thenReturn(FileModel.builder().excluded(false).dossierStatusId(dossierTemplateId).id(FILE_ID).build());
|
||||||
|
when(fileManagementStorageService.getEntityLog(dossierId, FILE_ID)).thenReturn(entityLog);
|
||||||
|
when(dossierService.getDossierById(dossierId)).thenReturn(DossierEntity.builder().dossierTemplateId(dossierTemplateId).build());
|
||||||
|
when(dictionaryPersistenceService.getType(anyString())).thenReturn(TypeEntity.builder().isHint(false).build());
|
||||||
|
when(fileStatusPersistenceService.getStatus(FILE_ID)).thenReturn(FileEntity.builder().id(FILE_ID).fileAttributes(Collections.emptyList()).build());
|
||||||
|
when(fileStatusService.convertAttributes(any(), anyString())).thenReturn(Collections.emptyList());
|
||||||
|
|
||||||
|
EntityLog response = entityLogMergeService.mergeEntityLog(manualRedactions, entityLog, DossierEntity.builder().dossierTemplateId(dossierTemplateId).build());
|
||||||
|
|
||||||
|
assertNotNull(response);
|
||||||
|
assertFalse(response.getEntityLogEntry().isEmpty());
|
||||||
|
|
||||||
|
var optionalEntityLogEntry = response.getEntityLogEntry()
|
||||||
|
.stream()
|
||||||
|
.filter(entityLogEntry -> entityLogEntry.getId().equals(entryId))
|
||||||
|
.findFirst();
|
||||||
|
assertTrue(optionalEntityLogEntry.isPresent());
|
||||||
|
assertEquals(optionalEntityLogEntry.get().getChanges().size(), 1);
|
||||||
|
assertEquals(optionalEntityLogEntry.get().getChanges().get(0).getType(), ChangeType.IGNORED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private EntityLog provideEntityLog(String entryToRemoveId,
|
private EntityLog provideEntityLog(String entryToRemoveId,
|
||||||
String entryToResizeId,
|
String entryToResizeId,
|
||||||
String entryLegalBasisId,
|
String entryLegalBasisId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user