use of com.enonic.xp.index.PurgeIndexParams in project xp by enonic.
the class IndexServiceImplTest method reindex_cms_repo.
@Test
public void reindex_cms_repo() throws Exception {
final Context cmsRepoContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(TEST_REPO_ID).branch(ContentConstants.BRANCH_DRAFT).build();
cmsRepoContext.callWith(this::createDefaultRootNode);
cmsRepoContext.callWith(() -> createNode(CreateNodeParams.create().setNodeId(NodeId.from("su")).name("su").parent(NodePath.ROOT).build()));
refresh();
assertEquals(2, cmsRepoContext.callWith(this::findAllNodes).getHits());
this.indexService.purgeSearchIndex(new PurgeIndexParams(cmsRepoContext.getRepositoryId()));
assertEquals(0, cmsRepoContext.callWith(this::findAllNodes).getHits());
this.indexService.reindex(ReindexParams.create().addBranch(cmsRepoContext.getBranch()).repositoryId(cmsRepoContext.getRepositoryId()).initialize(true).build());
refresh();
assertEquals(2, cmsRepoContext.callWith(this::findAllNodes).getHits());
}
use of com.enonic.xp.index.PurgeIndexParams in project xp by enonic.
the class IndexServiceImplTest method purge_then_reindex.
@Test
public void purge_then_reindex() throws Exception {
final Node node = createNode(CreateNodeParams.create().name("myNode").parent(NodePath.ROOT).build());
refresh();
this.indexService.purgeSearchIndex(new PurgeIndexParams(TEST_REPO_ID));
assertNull(queryForNode(node.id()));
final ReindexResult result = this.indexService.reindex(ReindexParams.create().addBranch(WS_DEFAULT).repositoryId(TEST_REPO_ID).initialize(false).build());
assertEquals(2, result.getReindexNodes().getSize());
refresh();
assertNotNull(queryForNode(node.id()));
assertNotNull(queryForNode(rootNode.id()));
}
use of com.enonic.xp.index.PurgeIndexParams in project xp by enonic.
the class IndexServiceImplTest method reindex_other_branch.
@Test
public void reindex_other_branch() throws Exception {
final Node node = createNode(CreateNodeParams.create().name("myNode").parent(NodePath.ROOT).build());
refresh();
PushNodesCommand.create().ids(NodeIds.from(node.id())).target(WS_OTHER).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
refresh();
assertNotNull(queryForNode(node.id()));
assertNotNull(ctxOther().callWith(() -> queryForNode(node.id())));
this.indexService.purgeSearchIndex(new PurgeIndexParams(TEST_REPO_ID));
refresh();
assertNull(queryForNode(node.id()));
this.indexService.reindex(ReindexParams.create().addBranch(WS_DEFAULT).repositoryId(TEST_REPO_ID).initialize(false).build());
refresh();
assertNotNull(queryForNode(node.id()));
assertNull(ctxOther().callWith(() -> queryForNode(node.id())));
this.indexService.reindex(ReindexParams.create().addBranch(WS_OTHER).repositoryId(TEST_REPO_ID).initialize(true).build());
refresh();
assertNull(queryForNode(node.id()));
assertNotNull(ctxOther().callWith(() -> queryForNode(node.id())));
}
use of com.enonic.xp.index.PurgeIndexParams in project xp by enonic.
the class IndexServiceImplTest method reindex_system_repo.
@Test
public void reindex_system_repo() throws Exception {
final Context systemRepoContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(SystemConstants.SYSTEM_REPO_ID).branch(SystemConstants.BRANCH_SYSTEM).build();
systemRepoContext.callWith(this::createDefaultRootNode);
systemRepoContext.callWith(() -> createNode(CreateNodeParams.create().setNodeId(NodeId.from("su")).name("su").parent(NodePath.ROOT).build()));
refresh();
final long nodesInSystemRepoCount = systemRepoContext.callWith(this::findAllNodes).getHits();
this.indexService.purgeSearchIndex(new PurgeIndexParams(systemRepoContext.getRepositoryId()));
assertEquals(0, systemRepoContext.callWith(this::findAllNodes).getHits());
this.indexService.reindex(ReindexParams.create().addBranch(systemRepoContext.getBranch()).repositoryId(systemRepoContext.getRepositoryId()).initialize(true).build());
refresh();
assertEquals(nodesInSystemRepoCount, systemRepoContext.callWith(this::findAllNodes).getHits());
}
Aggregations