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);
}
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();
}
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();
}
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);
}
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);
}
Aggregations