Search in sources :

Example 1 with SmartItem

use of io.vertigo.dynamo.collections.data.domain.SmartItem in project vertigo by KleeGroup.

the class CollectionsManagerTest method testHeavySort.

@Test
public void testHeavySort() {
    // final DtList<Item> sortDtc;
    final DtList<SmartItem> dtc = createItems();
    // 
    for (int i = 0; i < 50000; i++) {
        final SmartItem mocka = new SmartItem();
        mocka.setLabel(String.valueOf(i % 100));
        dtc.add(mocka);
    }
    final DtList<SmartItem> sortedDtc = collectionsManager.sort(dtc, "LABEL", false);
    nop(sortedDtc);
}
Also used : SmartItem(io.vertigo.dynamo.collections.data.domain.SmartItem) Test(org.junit.Test)

Example 2 with SmartItem

use of io.vertigo.dynamo.collections.data.domain.SmartItem in project vertigo by KleeGroup.

the class CollectionsManagerTest method createItemsForRangeTest.

private static DtList<SmartItem> createItemsForRangeTest() {
    final DtList<SmartItem> dtc = createItems();
    final SmartItem mock1 = new SmartItem();
    mock1.setId(1L);
    mock1.setLabel("aaab");
    dtc.add(mock1);
    final SmartItem mock2 = new SmartItem();
    mock2.setId(10L);
    mock2.setLabel("aaac");
    dtc.add(mock2);
    final SmartItem mock3 = new SmartItem();
    mock3.setId(11L);
    mock3.setLabel("caaa");
    dtc.add(mock3);
    final SmartItem mock4 = new SmartItem();
    mock4.setId(12L);
    mock4.setLabel("aaa");
    dtc.add(mock4);
    final SmartItem mock5 = new SmartItem();
    mock5.setId(13L);
    mock5.setLabel("aaa");
    dtc.add(mock5);
    final SmartItem mock6 = new SmartItem();
    mock6.setId(3L);
    mock6.setLabel("c");
    dtc.add(mock6);
    return dtc;
}
Also used : SmartItem(io.vertigo.dynamo.collections.data.domain.SmartItem)

Example 3 with SmartItem

use of io.vertigo.dynamo.collections.data.domain.SmartItem in project vertigo by KleeGroup.

the class CollectionsManagerTest method testFilterFullTextMultiKeyword.

@Test
public void testFilterFullTextMultiKeyword() {
    final DtList<SmartItem> dtc = createItems();
    final Collection<DtField> searchedDtFields = dtDefinitionItem.getFields();
    final SmartItem mock1 = new SmartItem();
    mock1.setId(seqId++);
    mock1.setLabel("Agence de l'Ouest");
    dtc.add(mock1);
    final SmartItem mock2 = new SmartItem();
    mock2.setId(seqId++);
    mock2.setLabel("Hôpital et autres accents çava où ãpied");
    dtc.add(mock2);
    // mots proches
    Assert.assertTrue("La recherche ne supporte pas l'espace", filter(dtc, "agence de", 1000, searchedDtFields).size() == 1);
    // mots séparés
    Assert.assertTrue("La recherche ne supporte pas l'utilisation de plusieurs mots", filter(dtc, "hopital accent", 1000, searchedDtFields).size() == 1);
    // inversés
    Assert.assertTrue("La recherche ne supporte pas l'inversion des mots", filter(dtc, "accent hopital", 1000, searchedDtFields).size() == 1);
    // multi doc
    Assert.assertTrue("Les mots clés ne sont pas en 'ET'", filter(dtc, "agence hopital", 1000, searchedDtFields).size() == 0);
}
Also used : SmartItem(io.vertigo.dynamo.collections.data.domain.SmartItem) DtField(io.vertigo.dynamo.domain.metamodel.DtField) Test(org.junit.Test)

Example 4 with SmartItem

use of io.vertigo.dynamo.collections.data.domain.SmartItem in project vertigo by KleeGroup.

the class CollectionsManagerTest method testFilterFullTextTokenizer.

@Test
public void testFilterFullTextTokenizer() {
    final DtList<SmartItem> dtc = createItems();
    final Collection<DtField> searchedDtFields = dtDefinitionItem.getFields();
    final SmartItem mock1 = new SmartItem();
    mock1.setId(seqId++);
    mock1.setLabel("Agence de l'Ouest");
    dtc.add(mock1);
    final SmartItem mock2 = new SmartItem();
    mock2.setId(seqId++);
    mock2.setLabel("Hôpital et autres accents çava où ãpied");
    dtc.add(mock2);
    // majuscule/minuscule
    Assert.assertTrue("La recherche n'est pas case insensitive", filter(dtc, "agence", 1000, searchedDtFields).size() == 1);
    // tokenizer
    Assert.assertTrue("La recherche n'est pas plain text", filter(dtc, "l'ouest", 1000, searchedDtFields).size() == 1);
    // accents
    Assert.assertTrue("La recherche ne supporte pas les accents", filter(dtc, "hopital", 1000, searchedDtFields).size() == 1);
    // accents fr (ç)
    Assert.assertTrue("La recherche ne supporte pas les caractères spéciaux fr (ç)", filter(dtc, "cava", 1000, searchedDtFields).size() == 1);
    // accents autre (ã)
    Assert.assertTrue("La recherche ne supporte pas les caractères spéciaux latin1 (ã)", filter(dtc, "apied", 1000, searchedDtFields).size() == 1);
    // prefix
    Assert.assertTrue("La recherche ne supporte pas la recherche par préfix", filter(dtc, "apie", 1000, searchedDtFields).size() == 1);
}
Also used : SmartItem(io.vertigo.dynamo.collections.data.domain.SmartItem) DtField(io.vertigo.dynamo.domain.metamodel.DtField) Test(org.junit.Test)

Example 5 with SmartItem

use of io.vertigo.dynamo.collections.data.domain.SmartItem in project vertigo by KleeGroup.

the class CollectionsManagerTest method testFilterFullTextBigList.

/**
 * Vérifie le comportement quand la recherche en commence par addresse trop de term du dictionnaire.
 * Par défaut Lucene envoi une erreur TooMany...., le collectionsManager limite aux premiers terms.
 */
@Test
public void testFilterFullTextBigList() {
    final UnaryOperator<DtList<SmartItem>> filterFunction = collectionsManager.<SmartItem>createIndexDtListFunctionBuilder().filter("a", 2000, dtDefinitionItem.getFields()).build();
    Assert.assertNotNull(filterFunction);
    final DtList<SmartItem> bigFamillyList = new DtList<>(SmartItem.class);
    for (int i = 0; i < 50000; i++) {
        final SmartItem mocka = new SmartItem();
        mocka.setId(seqId++);
        mocka.setLabel("blabla a" + (char) ('a' + i % 26) + String.valueOf(i % 100));
        bigFamillyList.add(mocka);
    }
    final DtList<SmartItem> result = filterFunction.apply(bigFamillyList);
    Assert.assertEquals(2000, result.size(), 0);
}
Also used : SmartItem(io.vertigo.dynamo.collections.data.domain.SmartItem) DtList(io.vertigo.dynamo.domain.model.DtList) Test(org.junit.Test)

Aggregations

SmartItem (io.vertigo.dynamo.collections.data.domain.SmartItem)7 Test (org.junit.Test)5 DtField (io.vertigo.dynamo.domain.metamodel.DtField)3 DtList (io.vertigo.dynamo.domain.model.DtList)2