use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.
the class BranchServiceImplTest method path_fetched_from_cache_after_stored.
@Test
public void path_fetched_from_cache_after_stored() throws Exception {
final InternalContext context = InternalContext.create().branch(Branch.from("myBranch")).repositoryId(RepositoryId.from("my-repo")).build();
final NodePath path = NodePath.create(NodePath.ROOT, "fisk").build();
Mockito.when(this.storageDao.store(Mockito.isA(StoreRequest.class))).thenReturn("123_myBranch");
this.branchService.store(NodeBranchEntry.create().nodeId(NodeId.from("123")).nodePath(path).nodeState(NodeState.DEFAULT).nodeVersionId(NodeVersionId.from("nodeVersionId")).nodeVersionKey(NodeVersionKey.from("nodeBlobKey", "indexConfigBlobKey", "accessControlBlobKey")).timestamp(Instant.now()).build(), context);
Mockito.when(this.storageDao.getById(Mockito.isA(GetByIdRequest.class))).thenReturn(GetResult.create().id("123_myBranch").resultFieldValues(ReturnValues.create().add(BranchIndexPath.PATH.getPath(), "/fisk").add(BranchIndexPath.STATE.getPath(), "default").add(BranchIndexPath.VERSION_ID.getPath(), "nodeVersionId").add(BranchIndexPath.NODE_BLOB_KEY.getPath(), "nodeBlobKey").add(BranchIndexPath.INDEX_CONFIG_BLOB_KEY.getPath(), "indexConfigBlobKey").add(BranchIndexPath.ACCESS_CONTROL_BLOB_KEY.getPath(), "accessControlBlobKey").add(BranchIndexPath.NODE_ID.getPath(), "123").add(BranchIndexPath.TIMESTAMP.getPath(), Instant.now().toString()).build()).build());
Mockito.when(this.searchDao.search(Mockito.isA(SearchRequest.class))).thenReturn(SearchResult.create().build());
final NodeBranchEntry fetchEntry = this.branchService.get(path, context);
assertNotNull(fetchEntry);
}
use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.
the class ProjectServiceImplTest method create.
@Test
void create() {
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
final Project project = doCreateProjectAsAdmin(ProjectName.from(projectRepoId));
assertNotNull(project);
assertEquals("test-project", project.getName().toString());
final NodeBranchEntry nodeBranchEntry = this.branchService.get(Node.ROOT_UUID, InternalContext.create(adminContext()).repositoryId(projectRepoId).build());
assertNotNull(nodeBranchEntry);
adminContext().runWith(() -> {
final Repository pro = repositoryService.get(projectRepoId);
assertNotNull(pro);
});
}
use of com.enonic.xp.node.NodeBranchEntry 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());
}
use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.
the class NodeStorageServiceImpl method get.
@Override
public Node get(final NodeId nodeId, final NodeVersionId nodeVersionId, final InternalContext context) {
final NodeVersionMetadata nodeVersionMetadata = versionService.getVersion(nodeId, nodeVersionId, context);
if (nodeVersionMetadata == null) {
return null;
}
final NodeVersion nodeVersion = nodeVersionService.get(nodeVersionMetadata.getNodeVersionKey(), context);
if (nodeVersion == null) {
return null;
}
final NodeBranchEntry nodeBranchEntry = branchService.get(nodeVersionMetadata.getNodeId(), context);
if (nodeBranchEntry == null) {
return null;
}
return constructNode(nodeBranchEntry, nodeVersion);
}
use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.
the class NodeStorageServiceImpl method push.
@Override
public void push(final Node node, final Branch target, final InternalContext context) {
final NodeBranchEntry entry = this.branchService.get(node.id(), context);
this.branchService.store(entry, InternalContext.create(context).branch(target).build());
this.indexDataService.push(IndexPushNodeParams.create().nodeIds(NodeIds.from(node.id())).targetBranch(target).targetRepo(context.getRepositoryId()).build(), context);
}
Aggregations