Search in sources :

Example 96 with Node

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

the class NodeEventsTest method testUpdated.

@Test
public void testUpdated() {
    final Node updated = createNode("updated", NodePath.create("/mynode1/child1").build(), "myId");
    Event event = NodeEvents.updated(updated);
    assertNotNull(event);
    assertTrue(event.isDistributed());
    assertEquals(NodeEvents.NODE_UPDATED_EVENT, event.getType());
    assertEquals("[{id=myId, path=/mynode1/child1/updated, branch=draft, repo=com.enonic.cms.default}]", event.getValue("nodes").get().toString());
}
Also used : Node(com.enonic.xp.node.Node) Event(com.enonic.xp.event.Event) Test(org.junit.jupiter.api.Test)

Example 97 with Node

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

the class NodeEventsTest method testDeleted.

@Test
public void testDeleted() {
    final Node deleted = createNode("deleted", NodePath.create("/mynode1/child1").build(), "myId");
    Event event = NodeEvents.created(deleted);
    assertNotNull(event);
    assertTrue(event.isDistributed());
    assertEquals("[{id=myId, path=/mynode1/child1/deleted, branch=draft, repo=com.enonic.cms.default}]", event.getValue("nodes").get().toString());
}
Also used : Node(com.enonic.xp.node.Node) Event(com.enonic.xp.event.Event) Test(org.junit.jupiter.api.Test)

Example 98 with Node

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

the class NodeEventsTest method testCreated.

@Test
public void testCreated() {
    final Node created = createNode("created", NodePath.create("/mynode1/child1").build(), "id");
    Event event = NodeEvents.created(created);
    assertNotNull(event);
    assertTrue(event.isDistributed());
    assertEquals("[{id=id, path=/mynode1/child1/created, branch=draft, repo=com.enonic.cms.default}]", event.getValue("nodes").get().toString());
}
Also used : Node(com.enonic.xp.node.Node) Event(com.enonic.xp.event.Event) Test(org.junit.jupiter.api.Test)

Example 99 with Node

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

the class NodeEventsTest method testPushed.

@Test
public void testPushed() {
    final Node pushed1 = createNode("pushed1", NodePath.create("/mynode1/pushed1").build(), "id1");
    final Node pushed2 = createNode("pushed2", NodePath.create("/mynode1/pushed2").build(), "id2");
    final Node pushed3 = createNode("pushed3Renamed", NodePath.create("/mynode1/pushed3").build(), "id3");
    final NodeBranchEntry nodeBranchEntry = NodeBranchEntry.create().nodeId(pushed1.id()).nodePath(pushed1.path()).nodeState(NodeState.DEFAULT).nodeVersionId(pushed1.getNodeVersionId()).build();
    final NodeBranchEntry nodeBranchEntry2 = NodeBranchEntry.create().nodeId(pushed2.id()).nodePath(pushed2.path()).nodeState(NodeState.DEFAULT).nodeVersionId(pushed2.getNodeVersionId()).build();
    final NodeBranchEntry nodeBranchEntry3 = NodeBranchEntry.create().nodeId(pushed3.id()).nodePath(pushed3.path()).nodeState(NodeState.DEFAULT).nodeVersionId(pushed3.getNodeVersionId()).build();
    final PushNodeEntries pushNodeEntries = PushNodeEntries.create().targetRepo(ContentConstants.CONTENT_REPO_ID).targetBranch(ContentConstants.BRANCH_MASTER).add(PushNodeEntry.create().nodeBranchEntry(nodeBranchEntry).build()).add(PushNodeEntry.create().nodeBranchEntry(nodeBranchEntry2).build()).add(PushNodeEntry.create().nodeBranchEntry(nodeBranchEntry3).currentTargetPath(NodePath.create("/mynode1/pushed3/pushed3").build()).build()).build();
    Event event = NodeEvents.pushed(pushNodeEntries);
    assertNotNull(event);
    assertTrue(event.isDistributed());
    assertTrue(event.hasValue("nodes"));
    assertEquals(NodeEvents.NODE_PUSHED_EVENT, event.getType());
    assertEquals("[{id=id1, path=/mynode1/pushed1/pushed1, branch=master, repo=com.enonic.cms.default}" + ", {id=id2, path=/mynode1/pushed2/pushed2, branch=master, repo=com.enonic.cms.default}" + ", {id=id3, path=/mynode1/pushed3/pushed3Renamed, branch=master, repo=com.enonic.cms.default, currentTargetPath=/mynode1/pushed3/pushed3}]", event.getValue("nodes").get().toString());
}
Also used : Node(com.enonic.xp.node.Node) Event(com.enonic.xp.event.Event) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) PushNodeEntries(com.enonic.xp.node.PushNodeEntries) Test(org.junit.jupiter.api.Test)

Example 100 with Node

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

the class NodeEventsTest method testDuplicated.

@Test
public void testDuplicated() {
    final Node duplicated = createNode("duplicated", NodePath.create("/mynode1/child1").build(), "myId");
    Event event = NodeEvents.duplicated(duplicated);
    assertNotNull(event);
    assertTrue(event.isDistributed());
    assertEquals(NodeEvents.NODE_DUPLICATED_EVENT, event.getType());
    assertEquals("[{id=myId, path=/mynode1/child1/duplicated, branch=draft, repo=com.enonic.cms.default}]", event.getValue("nodes").get().toString());
}
Also used : Node(com.enonic.xp.node.Node) Event(com.enonic.xp.event.Event) Test(org.junit.jupiter.api.Test)

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