RED-7848 - Sorting in merged dictionary differs from template dictionary in terms of capitalization
- update the sorting to natural order - update junit tests
This commit is contained in:
parent
f250c6b961
commit
8a50f6c0a2
@ -14,7 +14,6 @@ import static com.iqser.red.service.persistence.management.v1.processor.roles.Ac
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.TypeIdUtils.toTypeId;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -272,19 +271,19 @@ public class DictionaryService {
|
||||
.stream()
|
||||
.filter(e -> !e.isDeleted())
|
||||
.map(DictionaryEntry::getValue)
|
||||
.sorted(Comparator.comparing(String::toLowerCase))
|
||||
.sorted()
|
||||
.collect(Collectors.toList()))
|
||||
.falsePositiveEntries(dictionaryForType.getFalsePositiveEntries()
|
||||
.stream()
|
||||
.filter(e -> !e.isDeleted())
|
||||
.map(DictionaryEntry::getValue)
|
||||
.sorted(Comparator.comparing(String::toLowerCase))
|
||||
.sorted()
|
||||
.collect(Collectors.toList()))
|
||||
.falseRecommendationEntries(dictionaryForType.getFalseRecommendationEntries()
|
||||
.stream()
|
||||
.filter(e -> !e.isDeleted())
|
||||
.map(DictionaryEntry::getValue)
|
||||
.sorted(Comparator.comparing(String::toLowerCase))
|
||||
.sorted()
|
||||
.collect(Collectors.toList()))
|
||||
.hexColor(dictionaryForType.getHexColor())
|
||||
.recommendationHexColor(dictionaryForType.getRecommendationHexColor())
|
||||
@ -340,19 +339,19 @@ public class DictionaryService {
|
||||
.stream()
|
||||
.filter(e -> !e.isDeleted())
|
||||
.map(DictionaryEntry::getValue)
|
||||
.sorted(Comparator.comparing(String::toLowerCase))
|
||||
.sorted()
|
||||
.collect(Collectors.toList()))
|
||||
.falsePositiveEntries(cdm.getFalsePositives()
|
||||
.stream()
|
||||
.filter(e -> !e.isDeleted())
|
||||
.map(DictionaryEntry::getValue)
|
||||
.sorted(Comparator.comparing(String::toLowerCase))
|
||||
.sorted()
|
||||
.collect(Collectors.toList()))
|
||||
.falseRecommendationEntries(cdm.getFalseRecommendations()
|
||||
.stream()
|
||||
.filter(e -> !e.isDeleted())
|
||||
.map(DictionaryEntry::getValue)
|
||||
.sorted(Comparator.comparing(String::toLowerCase))
|
||||
.sorted()
|
||||
.collect(Collectors.toList()))
|
||||
.hexColor(entity.getHexColor())
|
||||
.recommendationHexColor(entity.getRecommendationHexColor())
|
||||
|
||||
@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@ -404,9 +405,9 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate, "Dossier");
|
||||
var type = typeProvider.testAndProvideType(dossierTemplate);
|
||||
|
||||
Assertions.assertThrows(FeignException.BadRequest.class, () -> dictionaryClient.getAllTypes(dossierTemplate1.getDossierTemplateId(), dossier.getDossierId(), false));
|
||||
Assertions.assertThrows(FeignException.BadRequest.class, () -> dictionaryClient.getAllTypes(dossierTemplate1.getId(), dossier.getId(), false));
|
||||
|
||||
Assertions.assertThrows(FeignException.BadRequest.class, () -> dictionaryClient.getDictionaryForType(type.getType(), dossierTemplate1.getDossierTemplateId(), dossier.getDossierId()));
|
||||
Assertions.assertThrows(FeignException.BadRequest.class, () -> dictionaryClient.getDictionaryForType(type.getType(), dossierTemplate1.getId(), dossier.getId()));
|
||||
|
||||
}
|
||||
|
||||
@ -435,18 +436,18 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(loadedType1.getFalsePositiveEntries()).hasSize(2);
|
||||
assertThat(loadedType1.getFalseRecommendationEntries()).hasSize(2);
|
||||
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("word1", "word4"), false, dossier.getDossierId(), DictionaryEntryType.ENTRY);
|
||||
dictionaryClient.deleteEntries(type.getType(), type.getDossierTemplateId(), List.of("word2"), dossier.getDossierId(), DictionaryEntryType.ENTRY);
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("false_positive1", "false_positive3"), false, dossier.getDossierId(), DictionaryEntryType.FALSE_POSITIVE);
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("word1", "word4"), false, dossier.getId(), DictionaryEntryType.ENTRY);
|
||||
dictionaryClient.deleteEntries(type.getType(), type.getDossierTemplateId(), List.of("word2"), dossier.getId(), DictionaryEntryType.ENTRY);
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("false_positive1", "false_positive3"), false, dossier.getId(), DictionaryEntryType.FALSE_POSITIVE);
|
||||
dictionaryClient.addEntry(type.getType(),
|
||||
type.getDossierTemplateId(),
|
||||
List.of("false_recommendation3", "false_recommendation4"),
|
||||
false,
|
||||
dossier.getDossierId(),
|
||||
dossier.getId(),
|
||||
DictionaryEntryType.FALSE_RECOMMENDATION);
|
||||
Assertions.assertThrows(FeignException.Unauthorized.class, () -> dictionaryClient.getMergedDictionaries(type.getType() + ";", dossierTemplate.getDossierTemplateId(), dossier.getDossierId()));
|
||||
Assertions.assertThrows(FeignException.Unauthorized.class, () -> dictionaryClient.getMergedDictionaries(type.getType() + ";", dossierTemplate.getId(), dossier.getId()));
|
||||
|
||||
Dictionary mergedDict = dictionaryClient.getMergedDictionaries(type.getType(), dossierTemplate.getDossierTemplateId(), dossier.getDossierId());
|
||||
Dictionary mergedDict = dictionaryClient.getMergedDictionaries(type.getType(), dossierTemplate.getId(), dossier.getId());
|
||||
assertThat(mergedDict).isNotNull();
|
||||
assertThat(mergedDict.getEntries().size()).isEqualTo(3);
|
||||
assertThat(mergedDict.getFalsePositiveEntries().size()).isEqualTo(3);
|
||||
@ -475,17 +476,17 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(loadedType1.getFalsePositiveEntries()).hasSize(2);
|
||||
assertThat(loadedType1.getFalseRecommendationEntries()).hasSize(2);
|
||||
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("word1", "word4"), false, dossier.getDossierId(), DictionaryEntryType.ENTRY);
|
||||
dictionaryClient.deleteEntries(type.getType(), type.getDossierTemplateId(), List.of("word2"), dossier.getDossierId(), DictionaryEntryType.ENTRY);
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("false_positive1", "false_positive3"), false, dossier.getDossierId(), DictionaryEntryType.FALSE_POSITIVE);
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("word1", "word4"), false, dossier.getId(), DictionaryEntryType.ENTRY);
|
||||
dictionaryClient.deleteEntries(type.getType(), type.getDossierTemplateId(), List.of("word2"), dossier.getId(), DictionaryEntryType.ENTRY);
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("false_positive1", "false_positive3"), false, dossier.getId(), DictionaryEntryType.FALSE_POSITIVE);
|
||||
dictionaryClient.addEntry(type.getType(),
|
||||
type.getDossierTemplateId(),
|
||||
List.of("false_recommendation3", "false_recommendation4"),
|
||||
false,
|
||||
dossier.getDossierId(),
|
||||
dossier.getId(),
|
||||
DictionaryEntryType.FALSE_RECOMMENDATION);
|
||||
|
||||
var loadedType2 = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), dossier.getDossierId());
|
||||
var loadedType2 = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), dossier.getId());
|
||||
|
||||
assertThat(loadedType2.getEntries()).hasSize(2);
|
||||
assertThat(loadedType2.getFalsePositiveEntries()).hasSize(2);
|
||||
@ -505,7 +506,7 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(type.getSkippedHexColor()).isEqualTo("#aaaaaa");
|
||||
assertThat(type.isDossierDictionaryOnly()).isFalse();
|
||||
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("Charalampos", "Carina Wilson", "carlsen"), false, null, DictionaryEntryType.ENTRY);
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("William c. Spare", "Charalampos", "Carina Wilson", "William C. Spare" ,"carlsen"), false, null, DictionaryEntryType.ENTRY);
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("false_positive1", "false_positive"), false, null, DictionaryEntryType.FALSE_POSITIVE);
|
||||
dictionaryClient.addEntry(type.getType(),
|
||||
type.getDossierTemplateId(),
|
||||
@ -517,10 +518,12 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
var loadedType1 = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
|
||||
var entries = loadedType1.getEntries();
|
||||
assertThat(entries).hasSize(3);
|
||||
assertThat(entries).hasSize(5);
|
||||
assertThat(entries.get(0)).isEqualTo("Carina Wilson");
|
||||
assertThat(entries.get(1)).isEqualTo("carlsen");
|
||||
assertThat(entries.get(2)).isEqualTo("Charalampos");
|
||||
assertThat(entries.get(3)).isEqualTo("William C. Spare");
|
||||
assertThat(entries.get(4)).isEqualTo("William c. Spare");
|
||||
assertThat(loadedType1.getFalsePositiveEntries()).hasSize(2);
|
||||
assertThat(loadedType1.getFalsePositiveEntries().get(0)).isEqualTo("false_positive");
|
||||
assertThat(loadedType1.getFalsePositiveEntries().get(1)).isEqualTo("false_positive1");
|
||||
@ -529,7 +532,16 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(loadedType1.getFalseRecommendationEntries().get(1)).isEqualTo("false_recommendation1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSortedEntriesTest() {
|
||||
|
||||
var testList1 = List.of("William c. Spare", "PATRICIA A. SHEEHY", "William C. Spare", "Patricia A. Sheehy");
|
||||
var sortedList12 = testList1.stream().sorted().collect(Collectors.toList());
|
||||
|
||||
var testList2 = List.of("William C. Spare", "Patricia A. Sheehy", "William c. Spare" , "PATRICIA A. SHEEHY");
|
||||
var sortedList21 = testList2.stream().sorted().collect(Collectors.toList());
|
||||
assertThat(sortedList12).isEqualTo(sortedList21);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndDeleteLargeDictionary() {
|
||||
@ -559,7 +571,7 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(actualEntries.size()).isEqualTo(entries.size());
|
||||
assertThat(actualEntries).usingComparator(new ListContentWithoutOrderAndWithoutDuplicatesComparator<>()).isEqualTo(entries);
|
||||
|
||||
dictionaryClient.deleteEntries(type.getType(), dossierTemplate.getDossierTemplateId(), entries, null, null);
|
||||
dictionaryClient.deleteEntries(type.getType(), dossierTemplate.getId(), entries, null, null);
|
||||
|
||||
dictionary = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user