@Test public void persist_duplication() { DbFileSources.Data dbData = DbFileSources.Data.newBuilder().addLines( DbFileSources.Line.newBuilder() .addDuplication(2) .build()) .build(); setComputedData(dbData); underTest.execute(new TestComputationStepContext()); assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectByFileUuid(session, FILE1_UUID); assertThat(fileSourceDto.getSourceData()).isEqualTo(dbData); verify(fileSourceDataWarnings).commitWarnings(); }
@Override public void read(DbFileSources.Line.Builder lineBuilder) { Predicate<Map.Entry<TextBlock, Integer>> containsLine = new TextBlockContainsLine(lineBuilder.getLine()); for (Integer textBlockIndex : from(duplicatedTextBlockIndexByTextBlock.entrySet()) .filter(containsLine) .transform(MapEntryToBlockId.INSTANCE) // list is sorted to cope with the non-guaranteed order of Map entries which would trigger false detection of changes // in {@link DbFileSources.Line#getDuplicationList()} .toSortedList(Ordering.natural())) { lineBuilder.addDuplication(textBlockIndex); } }