Search in sources :

Example 51 with Content

use of com.enonic.xp.content.Content in project xp by enonic.

the class ContentServiceImplTest_undoPendingDelete method not_deleted_not_resurrected.

@Test
public void not_deleted_not_resurrected() throws Exception {
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").name("myContent").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content content = this.contentService.create(createContentParams);
    int result = resurrect(ContentIds.from(ContentIds.from(content.getId())));
    assertEquals(0, result);
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 52 with Content

use of com.enonic.xp.content.Content in project xp by enonic.

the class ContentServiceImplTest_update method update_content_modified_time_updated.

@Test
public void update_content_modified_time_updated() throws Exception {
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content content = this.contentService.create(createContentParams);
    final UpdateContentParams updateContentParams = new UpdateContentParams();
    updateContentParams.contentId(content.getId()).editor(edit -> {
        edit.displayName = "new display name";
    });
    this.contentService.update(updateContentParams);
    final Content updatedContent = this.contentService.getById(content.getId());
    assertEquals("new display name", updatedContent.getDisplayName());
    assertNotNull(updatedContent.getCreator());
    assertNotNull(updatedContent.getCreatedTime());
    assertNotNull(updatedContent.getModifier());
    assertNotNull(updatedContent.getModifiedTime());
    assertTrue(updatedContent.getModifiedTime().isAfter(content.getModifiedTime()));
}
Also used : UpdateContentParams(com.enonic.xp.content.UpdateContentParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 53 with Content

use of com.enonic.xp.content.Content in project xp by enonic.

the class ContentServiceImplTest_update method update_workflow_info.

@Test
public void update_workflow_info() throws Exception {
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).workflowInfo(WorkflowInfo.inProgress()).build();
    final Content content = this.contentService.create(createContentParams);
    final UpdateContentParams updateContentParams = new UpdateContentParams();
    updateContentParams.contentId(content.getId()).editor(edit -> {
        edit.workflowInfo = WorkflowInfo.create().state(WorkflowState.PENDING_APPROVAL).checks(Map.of("Laywer review", WorkflowCheckState.PENDING)).build();
    });
    this.contentService.update(updateContentParams);
    final Content storedContent = this.contentService.getById(content.getId());
    assertNotNull(storedContent.getWorkflowInfo());
    assertNotNull(storedContent.getWorkflowInfo().getState());
    assertNotNull(storedContent.getWorkflowInfo().getChecks());
    assertEquals(WorkflowState.PENDING_APPROVAL, storedContent.getWorkflowInfo().getState());
    assertEquals(Map.of("Laywer review", WorkflowCheckState.PENDING), storedContent.getWorkflowInfo().getChecks());
}
Also used : UpdateContentParams(com.enonic.xp.content.UpdateContentParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 54 with Content

use of com.enonic.xp.content.Content in project xp by enonic.

the class ContentServiceImplTest_resolveRequiredDependencies method resolve_with_parent.

@Test
public void resolve_with_parent() throws Exception {
    Content content1 = createContent(ContentPath.ROOT);
    Content content2 = createContent(content1.getPath());
    refresh();
    final ContentIds result = this.contentService.resolveRequiredDependencies(ResolveRequiredDependenciesParams.create().contentIds(ContentIds.from(content1.getId(), content2.getId())).target(WS_OTHER).build());
    assertEquals(content1.getId(), result.first());
}
Also used : Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Example 55 with Content

use of com.enonic.xp.content.Content in project xp by enonic.

the class ContentServiceImplTest_resolveRequiredDependencies method resolve_hierarchy.

@Test
public void resolve_hierarchy() throws Exception {
    Content content1 = createContent(ContentPath.ROOT);
    Content content2 = createContent(content1.getPath());
    Content content3 = createContent(content2.getPath());
    refresh();
    final ContentIds result = this.contentService.resolveRequiredDependencies(ResolveRequiredDependenciesParams.create().contentIds(ContentIds.from(content1.getId(), content2.getId(), content3.getId())).target(WS_OTHER).build());
    assertTrue(result.getSize() == 2);
    assertTrue(result.contains(content1.getId()));
    assertTrue(result.contains(content2.getId()));
}
Also used : Content(com.enonic.xp.content.Content) ContentIds(com.enonic.xp.content.ContentIds) Test(org.junit.jupiter.api.Test)

Aggregations

Content (com.enonic.xp.content.Content)563 Test (org.junit.jupiter.api.Test)435 PropertyTree (com.enonic.xp.data.PropertyTree)131 CreateContentParams (com.enonic.xp.content.CreateContentParams)57 ContentId (com.enonic.xp.content.ContentId)50 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)48 ContentPath (com.enonic.xp.content.ContentPath)47 ValidationErrors (com.enonic.xp.content.ValidationErrors)47 Site (com.enonic.xp.site.Site)43 PropertySet (com.enonic.xp.data.PropertySet)31 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)27 Page (com.enonic.xp.page.Page)26 Contents (com.enonic.xp.content.Contents)25 Node (com.enonic.xp.node.Node)25 ContentIds (com.enonic.xp.content.ContentIds)24 ContentQuery (com.enonic.xp.content.ContentQuery)24 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)24 FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)23 DataValidationError (com.enonic.xp.content.DataValidationError)21 ContentType (com.enonic.xp.schema.content.ContentType)20