Search in sources :

Example 6 with IndexDescriptor

use of org.kie.kogito.persistence.api.schema.IndexDescriptor in project kogito-apps by kiegroup.

the class IndexManagerIT method testCreateCompoundIndex.

@Test
void testCreateCompoundIndex() {
    String indexName = "test";
    IndexDescriptor id = new IndexDescriptor(indexName, List.of("test1", "test2"));
    String parentField = "test";
    String prefixUUID = UUID.randomUUID().toString() + ".";
    Optional<IndexModel> index = indexManager.createIndex(id, parentField, prefixUUID);
    assertTrue(equalsIndexModels(List.of(index.get()), List.of(new IndexModel(Indexes.ascending(indexName + ".test1", indexName + ".test2"), new IndexOptions().name(prefixUUID + indexName).sparse(true)))));
}
Also used : IndexOptions(com.mongodb.client.model.IndexOptions) EntityIndexDescriptor(org.kie.kogito.persistence.api.schema.EntityIndexDescriptor) IndexDescriptor(org.kie.kogito.persistence.api.schema.IndexDescriptor) IndexModel(com.mongodb.client.model.IndexModel) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 7 with IndexDescriptor

use of org.kie.kogito.persistence.api.schema.IndexDescriptor in project kogito-apps by kiegroup.

the class IndexManagerIT method testCreateSingleIndex.

@Test
void testCreateSingleIndex() {
    String fieldName = "id";
    IndexDescriptor id = new IndexDescriptor(fieldName, List.of(fieldName));
    String parentField = "";
    String prefixUUID = UUID.randomUUID().toString() + ".";
    Optional<IndexModel> index = indexManager.createIndex(id, parentField, prefixUUID);
    assertTrue(equalsIndexModels(List.of(index.get()), List.of(new IndexModel(Indexes.ascending(fieldName), new IndexOptions().name(prefixUUID + fieldName).sparse(true)))));
}
Also used : IndexOptions(com.mongodb.client.model.IndexOptions) EntityIndexDescriptor(org.kie.kogito.persistence.api.schema.EntityIndexDescriptor) IndexDescriptor(org.kie.kogito.persistence.api.schema.IndexDescriptor) IndexModel(com.mongodb.client.model.IndexModel) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

EntityIndexDescriptor (org.kie.kogito.persistence.api.schema.EntityIndexDescriptor)7 IndexDescriptor (org.kie.kogito.persistence.api.schema.IndexDescriptor)7 IndexModel (com.mongodb.client.model.IndexModel)4 IndexOptions (com.mongodb.client.model.IndexOptions)3 QuarkusTest (io.quarkus.test.junit.QuarkusTest)3 Test (org.junit.jupiter.api.Test)3 AttributeDescriptor (org.kie.kogito.persistence.api.schema.AttributeDescriptor)3 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 Multimaps (com.google.common.collect.Multimaps)1 MongoCollection (com.mongodb.client.MongoCollection)1 Indexes (com.mongodb.client.model.Indexes)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Objects (java.util.Objects)1 Set (java.util.Set)1 UUID (java.util.UUID)1