Search in sources :

Example 6 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class VersionTableVacuumTaskTest method version_not_deleted_in_all_branches.

@Test
void version_not_deleted_in_all_branches() {
    final Node node1 = createNode(NodePath.ROOT, "node1");
    pushNodes(NodeIds.from(node1.id()), WS_OTHER);
    refresh();
    this.nodeService.deleteById(node1.id());
    refresh();
    assertVersions(node1.id(), 1);
    final VacuumTaskResult result = NodeHelper.runAsAdmin(() -> this.task.execute(VacuumTaskParams.create().ageThreshold(NEGATIVE_AGE_THRESHOLD_MILLIS).build()));
    refresh();
    assertEquals(12, result.getProcessed());
    // Old version of CMS repository entry is also delete. Set to 0 when config to specify repository is implemented
    assertEquals(1, result.getDeleted());
    assertVersions(node1.id(), 1);
}
Also used : VacuumTaskResult(com.enonic.xp.vacuum.VacuumTaskResult) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 7 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class VersionTableVacuumTaskTest method version_deleted_in_all_branches.

@Test
void version_deleted_in_all_branches() {
    final Node node1 = createNode(NodePath.ROOT, "node1");
    pushNodes(NodeIds.from(node1.id()), WS_OTHER);
    refresh();
    this.nodeService.deleteById(node1.id());
    ctxOther().runWith(() -> this.nodeService.deleteById(node1.id()));
    refresh();
    assertVersions(node1.id(), 1);
    final VacuumTaskResult result = NodeHelper.runAsAdmin(() -> this.task.execute(VacuumTaskParams.create().ageThreshold(NEGATIVE_AGE_THRESHOLD_MILLIS).build()));
    refresh();
    assertEquals(12, result.getProcessed());
    // Old version of CMS repository entry is also delete. Set to 1 when config to specify repository is implemented
    assertEquals(2, result.getDeleted());
    assertVersions(node1.id(), 0);
}
Also used : VacuumTaskResult(com.enonic.xp.vacuum.VacuumTaskResult) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 8 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class VersionTableVacuumTaskTest method age_threshold.

@Test
void age_threshold() {
    final Node node1 = createNode(NodePath.ROOT, "node1");
    updateNode(node1.id(), 2);
    doDeleteNode(node1.id());
    refresh();
    assertVersions(node1.id(), 3);
    final VacuumTaskResult result = NodeHelper.runAsAdmin(() -> this.task.execute(VacuumTaskParams.create().ageThreshold(Duration.of(1, ChronoUnit.HOURS).toMillis()).build()));
    refresh();
    assertEquals(0, result.getProcessed());
    assertEquals(0, result.getDeleted());
    assertVersions(node1.id(), 3);
}
Also used : VacuumTaskResult(com.enonic.xp.vacuum.VacuumTaskResult) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 9 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class ConnectNodeTest method mockCreateNode.

private void mockCreateNode() {
    final Node node = createNode();
    Mockito.when(this.nodeService.create(Mockito.isA(CreateNodeParams.class))).thenReturn(node);
}
Also used : Node(com.enonic.xp.node.Node) CreateNodeParams(com.enonic.xp.node.CreateNodeParams)

Example 10 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class GetBinaryStreamHandlerTest method mockGetBinary.

private void mockGetBinary() {
    final Node node = createNode();
    Mockito.when(this.nodeService.getByPath(NodePath.create("/myNode").build())).thenReturn(node);
    Mockito.when(this.nodeService.getBinary(Mockito.isA(NodeId.class), Mockito.isA(BinaryReference.class))).thenReturn(ByteSource.wrap("this is a binary file".getBytes()));
}
Also used : Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) BinaryReference(com.enonic.xp.util.BinaryReference)

Aggregations

Node (com.enonic.xp.node.Node)521 Test (org.junit.jupiter.api.Test)371 PropertyTree (com.enonic.xp.data.PropertyTree)114 NodeId (com.enonic.xp.node.NodeId)52 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)51 NodePath (com.enonic.xp.node.NodePath)45 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)42 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)34 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)32 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)29 NodeQuery (com.enonic.xp.node.NodeQuery)27 AccessControlList (com.enonic.xp.security.acl.AccessControlList)27 BinaryReference (com.enonic.xp.util.BinaryReference)26 ByteSource (com.google.common.io.ByteSource)24 Content (com.enonic.xp.content.Content)23 PropertySet (com.enonic.xp.data.PropertySet)20 NodeIds (com.enonic.xp.node.NodeIds)18 Context (com.enonic.xp.context.Context)17 InternalContext (com.enonic.xp.repo.impl.InternalContext)17 Application (com.enonic.xp.app.Application)16