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());
}
Aggregations