Search in sources :

Example 1 with NodeSearchService

use of com.enonic.xp.repo.impl.search.NodeSearchService in project xp by enonic.

the class CreateNodeCommand_path_integrity_test method create.

@Test
public void create() {
    final int concurrentAttempts = 5;
    final int expectedSuccessfulAttempts = 1;
    final AtomicInteger exceptionCounter = new AtomicInteger();
    CompletableFuture.allOf(IntStream.range(0, concurrentAttempts).mapToObj(i -> CompletableFuture.runAsync(CreateNodeTask.create().binaryService(this.binaryService).storageService(this.storageService).nodeSearchService(this.searchService).indexServiceInternal(this.indexServiceInternal).context(ContextAccessor.current()).build()).exceptionally(throwable -> {
        exceptionCounter.incrementAndGet();
        return null;
    })).toArray(CompletableFuture[]::new)).join();
    assertEquals(concurrentAttempts - expectedSuccessfulAttempts, exceptionCounter.get());
    refresh();
    final FindNodesByQueryResult result = doFindByQuery(NodeQuery.create().path(NodePath.create(NodePath.ROOT, "myNode").build()).build());
    assertEquals(expectedSuccessfulAttempts, result.getTotalHits());
}
Also used : IntStream(java.util.stream.IntStream) BeforeEach(org.junit.jupiter.api.BeforeEach) NodeStorageService(com.enonic.xp.repo.impl.storage.NodeStorageService) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) NodeSearchService(com.enonic.xp.repo.impl.search.NodeSearchService) NodePath(com.enonic.xp.node.NodePath) CompletableFuture(java.util.concurrent.CompletableFuture) Test(org.junit.jupiter.api.Test) BinaryService(com.enonic.xp.repo.impl.binary.BinaryService) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ContextAccessor(com.enonic.xp.context.ContextAccessor) IndexServiceInternal(com.enonic.xp.repo.impl.index.IndexServiceInternal) Context(com.enonic.xp.context.Context) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NodeQuery(com.enonic.xp.node.NodeQuery) FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) Test(org.junit.jupiter.api.Test)

Aggregations

Context (com.enonic.xp.context.Context)1 ContextAccessor (com.enonic.xp.context.ContextAccessor)1 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)1 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)1 NodePath (com.enonic.xp.node.NodePath)1 NodeQuery (com.enonic.xp.node.NodeQuery)1 BinaryService (com.enonic.xp.repo.impl.binary.BinaryService)1 IndexServiceInternal (com.enonic.xp.repo.impl.index.IndexServiceInternal)1 NodeSearchService (com.enonic.xp.repo.impl.search.NodeSearchService)1 NodeStorageService (com.enonic.xp.repo.impl.storage.NodeStorageService)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IntStream (java.util.stream.IntStream)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1