Search in sources :

Example 1 with RepositoryService

use of com.enonic.xp.repository.RepositoryService 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 RepositoryService

use of com.enonic.xp.repository.RepositoryService 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 RepositoryService

use of com.enonic.xp.repository.RepositoryService 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)

Example 4 with RepositoryService

use of com.enonic.xp.repository.RepositoryService in project xp by enonic.

the class ListRepositoriesScriptTest method initialize.

@Override
public void initialize() throws Exception {
    super.initialize();
    repositoryService = Mockito.mock(RepositoryService.class);
    Mockito.when(repositoryService.list()).thenAnswer(invocation -> {
        final Repository testRepository = Repository.create().id(RepositoryId.from("test-repo")).branches(Branches.from(RepositoryConstants.MASTER_BRANCH)).build();
        final Repository anotherRepository = Repository.create().id(RepositoryId.from("another-repo")).branches(Branches.from(RepositoryConstants.MASTER_BRANCH)).build();
        return Repositories.from(testRepository, anotherRepository);
    });
    addService(RepositoryService.class, repositoryService);
}
Also used : Repository(com.enonic.xp.repository.Repository) RepositoryService(com.enonic.xp.repository.RepositoryService)

Example 5 with RepositoryService

use of com.enonic.xp.repository.RepositoryService in project xp by enonic.

the class CreateRepositoryScriptTest method initialize.

@Override
public void initialize() throws Exception {
    super.initialize();
    repositoryService = Mockito.mock(RepositoryService.class);
    Mockito.when(repositoryService.createRepository(Mockito.isA(CreateRepositoryParams.class))).thenAnswer(invocation -> {
        final CreateRepositoryParams params = (CreateRepositoryParams) invocation.getArguments()[0];
        return Repository.create().id(params.getRepositoryId()).branches(Branches.from(RepositoryConstants.MASTER_BRANCH)).settings(params.getRepositorySettings()).build();
    });
    addService(RepositoryService.class, repositoryService);
}
Also used : CreateRepositoryParams(com.enonic.xp.repository.CreateRepositoryParams) RepositoryService(com.enonic.xp.repository.RepositoryService)

Aggregations

RepositoryService (com.enonic.xp.repository.RepositoryService)6 AuditLogConfig (com.enonic.xp.core.impl.audit.config.AuditLogConfig)3 IndexService (com.enonic.xp.index.IndexService)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 CreateRepositoryParams (com.enonic.xp.repository.CreateRepositoryParams)2 RepositoryId (com.enonic.xp.repository.RepositoryId)2 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 Repository (com.enonic.xp.repository.Repository)1