use of com.enonic.xp.repo.impl.index.IndexServiceInternal 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());
}
use of com.enonic.xp.repo.impl.index.IndexServiceInternal in project xp by enonic.
the class RepositoryEntryServiceImpl method findRepositoryEntryIds.
@Override
public RepositoryIds findRepositoryEntryIds() {
final ImmutableList.Builder<RepositoryId> repositoryIds = ImmutableList.builder();
final FindNodesByParentParams findNodesByParentParams = FindNodesByParentParams.create().parentPath(RepositoryConstants.REPOSITORY_STORAGE_PARENT_PATH).size(-1).build();
final FindNodesByParentResult findNodesByParentResult = createContext().callWith(() -> FindNodesByParentCommand.create().params(findNodesByParentParams).indexServiceInternal(this.indexServiceInternal).storageService(this.nodeStorageService).searchService(this.nodeSearchService).build().execute());
findNodesByParentResult.getNodeIds().stream().map(nodeId -> RepositoryId.from(nodeId.toString())).forEach(repositoryIds::add);
return RepositoryIds.from(repositoryIds.build());
}
use of com.enonic.xp.repo.impl.index.IndexServiceInternal in project xp by enonic.
the class ProjectServiceImplTest method create_in_non_master_node.
@Test
void create_in_non_master_node() {
IndexServiceInternal indexServiceInternalMock = Mockito.mock(IndexServiceInternal.class);
when(indexServiceInternalMock.waitForYellowStatus()).thenReturn(true);
indexService.setIndexServiceInternal(indexServiceInternalMock);
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
final Project project = adminContext().callWith(() -> doCreateProject(ProjectName.from(projectRepoId), null, true, null));
assertNotNull(project);
assertEquals("test-project", project.getName().toString());
final NodeBranchEntry nodeBranchEntry = this.branchService.get(Node.ROOT_UUID, InternalContext.create(adminContext()).repositoryId(projectRepoId).build());
assertNotNull(nodeBranchEntry);
adminContext().runWith(() -> {
final Repository pro = repositoryService.get(projectRepoId);
assertNotNull(pro);
});
}
Aggregations