RED-6777: Added a test for a dictionary update and delete with a large number of entries
This commit is contained in:
parent
9787d1a0fd
commit
6a98c9229b
@ -3,8 +3,9 @@ package com.iqser.red.service.peristence.v1.server.integration.tests;
|
||||
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.Test;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@ -19,7 +20,6 @@ import com.iqser.red.service.peristence.v1.server.integration.utils.AbstractPers
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.CreateTypeValue;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.UpdateTypeValue;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.DictionaryEntryType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.Type;
|
||||
|
||||
import feign.FeignException;
|
||||
|
||||
@ -100,6 +100,7 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAddEntriesWithStopWord2() {
|
||||
|
||||
@ -285,7 +286,6 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
|
||||
|
||||
var type = CreateTypeValue.builder()
|
||||
.type("dossier_redaction")
|
||||
.label("Dossier Redactions")
|
||||
@ -297,7 +297,7 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
.dossierTemplateId(dossierTemplate.getId())
|
||||
.build();
|
||||
|
||||
var createdType = dictionaryClient.addType(type,null);
|
||||
var createdType = dictionaryClient.addType(type, null);
|
||||
|
||||
var word1 = "Luke Skywalker";
|
||||
var word2 = "Anakin Skywalker";
|
||||
@ -314,11 +314,12 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
var actualEntries = dictionary.getEntries();
|
||||
assertThat(actualEntries.size()).isEqualTo(3);
|
||||
assertThat(actualEntries).usingComparator(new ListContentWithoutOrderAndWithoutDuplicatesComparator<>()).isEqualTo(entries);
|
||||
|
||||
dictionaryClient.deleteType(createdType.getType(), createdType.getDossierTemplateId(),null);
|
||||
assertThat(dictionaryClient.getAllTypes(createdType.getDossierTemplateId(),null,false).getTypes().size()).isEqualTo(0);
|
||||
dictionaryClient.deleteType(createdType.getType(), createdType.getDossierTemplateId(), null);
|
||||
assertThat(dictionaryClient.getAllTypes(createdType.getDossierTemplateId(), null, false).getTypes().size()).isEqualTo(0);
|
||||
|
||||
dictionaryClient.addType(type,null);
|
||||
dictionaryClient.addType(type, null);
|
||||
|
||||
dictionary = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
|
||||
@ -374,4 +375,60 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(dictionary.getEntries().size()).isEqualTo(5);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateAndDeleteLargeDictionary() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
|
||||
var type = CreateTypeValue.builder()
|
||||
.type("dossier_redaction")
|
||||
.label("Dossier Redactions")
|
||||
.hexColor("#fcba03")
|
||||
.rank(100)
|
||||
.description("Something")
|
||||
.hasDictionary(true)
|
||||
.addToDictionaryAction(false)
|
||||
.dossierTemplateId(dossierTemplate.getId())
|
||||
.build();
|
||||
|
||||
var createdType = dictionaryClient.addType(type, null);
|
||||
|
||||
var entries = createDummyEntries(40_000);
|
||||
|
||||
dictionaryClient.addEntry(createdType.getType(), createdType.getDossierTemplateId(), entries, false, null, DictionaryEntryType.ENTRY);
|
||||
|
||||
var dictionary = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
|
||||
var actualEntries = dictionary.getEntries();
|
||||
assertThat(actualEntries.size()).isEqualTo(entries.size());
|
||||
assertThat(actualEntries).usingComparator(new ListContentWithoutOrderAndWithoutDuplicatesComparator<>()).isEqualTo(entries);
|
||||
|
||||
dictionaryClient.deleteEntries(type.getType(), dossierTemplate.getDossierTemplateId(), entries, null, null);
|
||||
|
||||
dictionary = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
|
||||
actualEntries = dictionary.getEntries();
|
||||
assertThat(actualEntries.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private List<String> createDummyEntries(int numberOfEntries) {
|
||||
|
||||
return IntStream.range(0, numberOfEntries).mapToObj(i -> "someWord" + i).toList();
|
||||
}
|
||||
|
||||
|
||||
private static final class ListContentWithoutOrderAndWithoutDuplicatesComparator<T> implements Comparator<List<? extends T>> {
|
||||
|
||||
@SuppressWarnings("SuspiciousMethodCalls")
|
||||
@Override
|
||||
public int compare(List<? extends T> l1, List<? extends T> l2) {
|
||||
|
||||
return l1.containsAll(l2) ? 0 : -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user