use of com.enonic.xp.index.IndexService in project xp by enonic.
the class AuditLogRepoInitializerTest method setUp.
@BeforeEach
public void setUp() {
RepositoryService repositoryService = Mockito.mock(RepositoryService.class);
IndexService indexService = Mockito.mock(IndexService.class);
AuditLogConfig config = Mockito.mock(AuditLogConfig.class);
Mockito.when(config.isEnabled()).thenReturn(true);
Mockito.when(config.isOutputLogs()).thenReturn(true);
auditLogService = new AuditLogServiceImpl(config, indexService, repositoryService, null);
Mockito.when(indexService.isMaster()).thenReturn(true);
Mockito.when(indexService.waitForYellowStatus()).thenReturn(true);
Mockito.when(repositoryService.createRepository(Mockito.any(CreateRepositoryParams.class))).thenReturn(null);
Mockito.when(repositoryService.isInitialized(Mockito.any(RepositoryId.class))).thenReturn(false);
}
use of com.enonic.xp.index.IndexService in project xp by enonic.
the class AuditLogServiceImplDisabledTest method setUp.
@BeforeEach
public void setUp() throws Exception {
AuditLogConfig config = Mockito.mock(AuditLogConfig.class);
Mockito.when(config.isEnabled()).thenReturn(false);
Mockito.when(config.isOutputLogs()).thenReturn(true);
IndexService indexService = Mockito.mock(IndexService.class);
Mockito.when(indexService.waitForYellowStatus()).thenReturn(true);
Mockito.when(indexService.isMaster()).thenReturn(true);
RepositoryService repositoryService = Mockito.mock(RepositoryService.class);
auditLogService = new AuditLogServiceImpl(config, indexService, repositoryService, null);
auditLogService.initialize();
}
use of com.enonic.xp.index.IndexService in project xp by enonic.
the class ExternalInitializerTest method testIsMaster.
@Test
public void testIsMaster() {
final IndexService indexService = Mockito.mock(IndexService.class);
final ExternalInitializer initializer = createExternalInitializer(indexService);
Mockito.when(indexService.isMaster()).thenReturn(true);
assertEquals(true, initializer.isMaster());
Mockito.when(indexService.isMaster()).thenReturn(false);
assertEquals(false, initializer.isMaster());
}
use of com.enonic.xp.index.IndexService in project xp by enonic.
the class AuditLogServiceImplTest method setUp.
@BeforeEach
public void setUp() throws Exception {
PropertyTree data = new PropertyTree();
data.setString("a", "b");
data.setBoolean("c", false);
auditLogParams = LogAuditLogParams.create().type("testType").source("testSource").objectUris(AuditLogUris.from("a:b:c", "d:e:f")).data(data).build();
CreateNodeParams createNodeParams = AuditLogSerializer.toCreateNodeParams(auditLogParams).setNodeId(new NodeId()).build();
Node node = Node.create().id(createNodeParams.getNodeId()).data(createNodeParams.getData()).build();
nodeService = mock(NodeService.class);
when(nodeService.create(any(CreateNodeParams.class))).thenReturn(node);
when(nodeService.getById(any(NodeId.class))).thenReturn(node);
when(nodeService.getByIds(any(NodeIds.class))).thenReturn(Nodes.from(node));
when(nodeService.findByQuery(any(NodeQuery.class))).thenReturn(FindNodesByQueryResult.create().addNodeHit(NodeHit.create().nodeId(node.id()).build()).totalHits(1).hits(1).build());
IndexService indexService = mock(IndexService.class);
when(indexService.isMaster()).thenReturn(true);
when(indexService.waitForYellowStatus()).thenReturn(true);
RepositoryService repositoryService = mock(RepositoryService.class);
config = mock(AuditLogConfig.class);
when(config.isEnabled()).thenReturn(true);
when(config.isOutputLogs()).thenReturn(true);
auditLogService = new AuditLogServiceImpl(config, indexService, repositoryService, nodeService);
auditLogService.initialize();
}
Aggregations