Search in sources :

Example 1 with IndexService

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);
}
Also used : CreateRepositoryParams(com.enonic.xp.repository.CreateRepositoryParams) IndexService(com.enonic.xp.index.IndexService) RepositoryId(com.enonic.xp.repository.RepositoryId) AuditLogConfig(com.enonic.xp.core.impl.audit.config.AuditLogConfig) RepositoryService(com.enonic.xp.repository.RepositoryService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with IndexService

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();
}
Also used : IndexService(com.enonic.xp.index.IndexService) AuditLogConfig(com.enonic.xp.core.impl.audit.config.AuditLogConfig) RepositoryService(com.enonic.xp.repository.RepositoryService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with IndexService

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());
}
Also used : IndexService(com.enonic.xp.index.IndexService) Test(org.junit.jupiter.api.Test)

Example 4 with IndexService

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();
}
Also used : IndexService(com.enonic.xp.index.IndexService) NodeIds(com.enonic.xp.node.NodeIds) PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) NodeService(com.enonic.xp.node.NodeService) NodeQuery(com.enonic.xp.node.NodeQuery) NodeId(com.enonic.xp.node.NodeId) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) AuditLogConfig(com.enonic.xp.core.impl.audit.config.AuditLogConfig) RepositoryService(com.enonic.xp.repository.RepositoryService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

IndexService (com.enonic.xp.index.IndexService)4 AuditLogConfig (com.enonic.xp.core.impl.audit.config.AuditLogConfig)3 RepositoryService (com.enonic.xp.repository.RepositoryService)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 PropertyTree (com.enonic.xp.data.PropertyTree)1 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)1 Node (com.enonic.xp.node.Node)1 NodeId (com.enonic.xp.node.NodeId)1 NodeIds (com.enonic.xp.node.NodeIds)1 NodeQuery (com.enonic.xp.node.NodeQuery)1 NodeService (com.enonic.xp.node.NodeService)1 CreateRepositoryParams (com.enonic.xp.repository.CreateRepositoryParams)1 RepositoryId (com.enonic.xp.repository.RepositoryId)1 Test (org.junit.jupiter.api.Test)1