Pull request #307: RED-3105: Fixed change computation
Merge in RED/redaction-service from RED-3105 to master * commit '19dcf0a67434442b2dd578523bbc5efa49c644e8': RED-3105: Fixed change computation
This commit is contained in:
commit
c9e74f4ff9
@ -50,7 +50,13 @@ public class RedactionChangeLogService {
|
|||||||
.equals(ChangeType.REMOVED))
|
.equals(ChangeType.REMOVED))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
Set<RedactionLogEntry> added = new HashSet<>(currentRedactionLog.getRedactionLogEntry());
|
Set<RedactionLogEntry> added = new HashSet<>(currentRedactionLog.getRedactionLogEntry().stream()
|
||||||
|
.filter(entry -> entry.getChanges().isEmpty() || !entry.getChanges()
|
||||||
|
.get(entry.getChanges().size() - 1)
|
||||||
|
.getType()
|
||||||
|
.equals(ChangeType.REMOVED))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
added.removeAll(notRemovedPreviousEntries);
|
added.removeAll(notRemovedPreviousEntries);
|
||||||
|
|
||||||
Set<RedactionLogEntry> removed = new HashSet<>(notRemovedPreviousEntries);
|
Set<RedactionLogEntry> removed = new HashSet<>(notRemovedPreviousEntries);
|
||||||
|
|||||||
@ -850,6 +850,51 @@ public class RedactionIntegrationTest {
|
|||||||
System.out.println("Output file:" + outputFileName);
|
System.out.println("Output file:" + outputFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChangeComputation() throws IOException {
|
||||||
|
|
||||||
|
String fileName = "files/new/test1S1T1.pdf";
|
||||||
|
String outputFileName = OsUtils.getTemporaryDirectory() + "/Annotated.pdf";
|
||||||
|
|
||||||
|
ClassPathResource pdfFileResource = new ClassPathResource(fileName);
|
||||||
|
AnalyzeRequest request = prepareStorage(pdfFileResource.getInputStream());
|
||||||
|
|
||||||
|
analyzeService.analyzeDocumentStructure(new StructureAnalyzeRequest(request.getDossierId(), request.getFileId()));
|
||||||
|
analyzeService.analyze(request);
|
||||||
|
|
||||||
|
dictionary.get(AUTHOR).add("report");
|
||||||
|
reanlysisVersions.put("report", 2L);
|
||||||
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(2L);
|
||||||
|
when(dictionaryClient.getDictionaryForType(AUTHOR +":" + TEST_DOSSIER_TEMPLATE_ID)).thenReturn(getDictionaryResponse(AUTHOR, false));
|
||||||
|
analyzeService.reanalyze(request);
|
||||||
|
|
||||||
|
dictionary.get(AUTHOR).add("assessment report");
|
||||||
|
reanlysisVersions.put("assessment report", 3L);
|
||||||
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(3L);
|
||||||
|
when(dictionaryClient.getDictionaryForType(AUTHOR +":" + TEST_DOSSIER_TEMPLATE_ID)).thenReturn(getDictionaryResponse(AUTHOR, false));
|
||||||
|
analyzeService.reanalyze(request);
|
||||||
|
|
||||||
|
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(3L);
|
||||||
|
when(dictionaryClient.getDictionaryForType(AUTHOR +":" + TEST_DOSSIER_TEMPLATE_ID)).thenReturn(getDictionaryResponse(AUTHOR, false));
|
||||||
|
analyzeService.reanalyze(request);
|
||||||
|
|
||||||
|
var redactionLog = redactionStorageService.getRedactionLog(TEST_DOSSIER_ID, TEST_FILE_ID);
|
||||||
|
|
||||||
|
var changes = redactionLog.getRedactionLogEntry().stream().filter(entry ->
|
||||||
|
entry.getValue() != null && entry.getValue().equals("report"))
|
||||||
|
.findFirst().get().getChanges();
|
||||||
|
|
||||||
|
assertThat(changes.size()).isEqualTo(2);
|
||||||
|
|
||||||
|
AnnotateResponse annotateResponse = redactionController.annotate(AnnotateRequest.builder()
|
||||||
|
.dossierId(TEST_DOSSIER_ID)
|
||||||
|
.fileId(TEST_FILE_ID)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
try (FileOutputStream fileOutputStream = new FileOutputStream(outputFileName)) {
|
||||||
|
fileOutputStream.write(annotateResponse.getDocument());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void redactionTest() throws IOException {
|
public void redactionTest() throws IOException {
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user