RED-6912: Entries not sorted correctly in the dossier dictionary #18

Merged
corina.olariu.ext1 merged 1 commits from RED-6912-backport3.6 into release/1.363.x 2023-06-22 11:44:47 +02:00
2 changed files with 18 additions and 3 deletions

View File

@ -2,7 +2,9 @@ package com.iqser.red.service.peristence.v1.server.controller;
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import javax.transaction.Transactional;
@ -98,9 +100,12 @@ public class DictionaryController implements DictionaryResource {
var entity = dictionaryPersistenceService.getType(typeId);
var target = convert(entity, Type.class);
target.setEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY, fromVersion), DictionaryEntry.class));
target.setFalsePositiveEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_POSITIVE, fromVersion), DictionaryEntry.class));
target.setFalseRecommendationEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_RECOMMENDATION, fromVersion), DictionaryEntry.class));
target.setEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY, fromVersion), DictionaryEntry.class)
.stream().sorted(Comparator.comparing(DictionaryEntry::getValue)).collect(Collectors.toList()));
target.setFalsePositiveEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_POSITIVE, fromVersion), DictionaryEntry.class)
.stream().sorted(Comparator.comparing(DictionaryEntry::getValue)).collect(Collectors.toList()));
target.setFalseRecommendationEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_RECOMMENDATION, fromVersion), DictionaryEntry.class)
.stream().sorted(Comparator.comparing(DictionaryEntry::getValue)).collect(Collectors.toList()));
return target;
}

View File

@ -376,6 +376,16 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
var existingEntries = dictionaryClient.getEntriesForType(createdType.getTypeId(), 0L, DictionaryEntryType.ENTRY);
assertThat(existingEntries.stream().filter(f -> !f.isDeleted()).count()).isEqualTo(5);
var dictionary = dictionaryClient.getDictionaryForType(createdType.getTypeId(), 0L);
var dictEntries = dictionary.getEntries();
assertThat(dictEntries).hasSize(5);
assertThat(dictEntries.get(0).getValue()).isEqualTo(word2);
assertThat(dictEntries.get(1).getValue()).isEqualTo(word1);
assertThat(dictEntries.get(2).getValue()).isEqualTo(word5);
assertThat(dictEntries.get(3).getValue()).isEqualTo(word4);
assertThat(dictEntries.get(4).getValue()).isEqualTo(word3);
}
}