use of com.enonic.xp.node.NodeService in project xp by enonic.
the class ContentNodeTranslatorTest method setUp.
@BeforeEach
public void setUp() throws Exception {
this.nodeService = Mockito.mock(NodeService.class);
final PartDescriptorService partDescriptorService = Mockito.mock(PartDescriptorService.class);
final LayoutDescriptorService layoutDescriptorService = Mockito.mock(LayoutDescriptorService.class);
final PageDescriptorService pageDescriptorService = Mockito.mock(PageDescriptorService.class);
final ContentDataSerializer contentDataSerializer = ContentDataSerializer.create().layoutDescriptorService(layoutDescriptorService).pageDescriptorService(pageDescriptorService).partDescriptorService(partDescriptorService).build();
this.contentNodeTranslator = new ContentNodeTranslator(nodeService, contentDataSerializer);
}
use of com.enonic.xp.node.NodeService in project xp by enonic.
the class SchedulableTaskImpl method run.
@Override
public void run() {
try {
final TaskId taskId = taskContext().callWith(() -> OsgiSupport.withService(TaskService.class, taskService -> taskService.submitTask(SubmitTaskParams.create().descriptorKey(job.getDescriptor()).data(job.getConfig()).build())));
adminContext().runWith(() -> OsgiSupport.withService(NodeService.class, nodeService -> UpdateLastRunCommand.create().nodeService(nodeService).name(job.getName()).lastRun(Instant.now()).lastTaskId(taskId).build().execute()));
} catch (Exception e) {
LOG.warn("Error while running job [{}]", this.job.getName(), e);
} catch (Throwable t) {
LOG.error("Error while running job [{}], no further attempts will be made", this.job.getName(), t);
throw t;
}
}
use of com.enonic.xp.node.NodeService 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