use of com.enonic.xp.node.NodeId in project xp by enonic.
the class DiffBranchesHandler method execute.
@Override
public Object execute() {
final NodeId nodeId = getNodeId(this.nodeKey);
if (nodeId == null) {
throw new NodeNotFoundException("Node with key [" + this.nodeKey + "] not found");
}
final ResolveSyncWorkResult result = this.nodeService.resolveSyncWork(SyncWorkResolverParams.create().includeChildren(includeChildren).nodeId(nodeId).branch(targetBranch).build());
return new ResolveSyncWorkResultMapper(result);
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class SetActiveVersionHandlerTest method testSetActiveVersionHandler.
@Test
public void testSetActiveVersionHandler() {
final NodeVersionId nodeVersionId = NodeVersionId.from("90398ddd1");
final ArgumentCaptor<NodeId> nodeIdCaptor = ArgumentCaptor.forClass(NodeId.class);
final ArgumentCaptor<NodeVersionId> nodeVersionIdCaptor = ArgumentCaptor.forClass(NodeVersionId.class);
Mockito.when(nodeService.setActiveVersion(Mockito.any(), Mockito.any())).thenReturn(nodeVersionId);
runScript("/lib/xp/examples/node/setActiveVersion.js");
Mockito.verify(nodeService).setActiveVersion(nodeIdCaptor.capture(), nodeVersionIdCaptor.capture());
assertEquals("nodeId", nodeIdCaptor.getValue().toString());
assertEquals(nodeVersionId, nodeVersionIdCaptor.getValue());
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class PushNodesResultMapper method addDeleted.
private void addDeleted(final MapGenerator gen) {
gen.array("deleted");
for (final NodeId entry : deleted) {
gen.value(entry);
}
gen.end();
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class CreateAuditLogCommand method createNode.
private Node createNode() {
NodeId id = new NodeId();
CreateNodeParams createNodeParams = AuditLogSerializer.toCreateNodeParams(params).setNodeId(id).name(id.toString()).parent(NodePath.ROOT).childOrder(AuditLogConstants.AUDIT_LOG_REPO_DEFAULT_CHILD_ORDER).build();
Node node = nodeService.create(createNodeParams);
nodeService.refresh(RefreshMode.ALL);
return node;
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class AuditLogServiceImplTest method cleanUpOneBatch.
@Test
public void cleanUpOneBatch() {
when(nodeService.deleteById(ArgumentMatchers.isA(NodeId.class))).thenAnswer(answer -> NodeIds.from((NodeId) answer.getArgument(0)));
when(config.ageThreshold()).thenReturn("PT1s");
final FindNodesByQueryResult.Builder queryResult = FindNodesByQueryResult.create().totalHits(3).hits(3);
createHits(3).forEach(queryResult::addNodeHit);
when(nodeService.findByQuery(any(NodeQuery.class))).thenReturn(queryResult.build()).thenReturn(FindNodesByQueryResult.create().build());
final CleanUpAuditLogListener listener = mock(CleanUpAuditLogListener.class);
final CleanUpAuditLogResult result = auditLogService.cleanUp(CleanUpAuditLogParams.create().listener(listener).build());
assertEquals(3, result.getDeleted());
verify(listener, times(1)).start(10_000);
verify(listener, times(3)).processed();
verify(listener, times(1)).finished();
}
Aggregations