Search in sources :

Example 66 with Content

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

the class GetCurrentContentScriptTest method currentContent.

@Test
public void currentContent() {
    final Content content = TestDataFixtures.newContent();
    this.portalRequest.setContent(content);
    runFunction("/test/getCurrentContent-test.js", "currentContent");
}
Also used : Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 67 with Content

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

the class WidgetHandlerTest method setupContentAndSite.

private void setupContentAndSite() {
    final Content content = createPage("id", "site/somepath/content", "myapplication:ctype", true);
    final ContentPath path = ContentPath.from("site/somepath/content").asAbsolute();
    Mockito.when(this.contentService.getByPath(path)).thenReturn(content);
    Mockito.when(this.contentService.findNearestSiteByPath(path)).thenReturn(createSite("id", "site", "myapplication:contenttypename"));
    Mockito.when(this.contentService.getById(content.getId())).thenReturn(content);
}
Also used : Content(com.enonic.xp.content.Content) ContentPath(com.enonic.xp.content.ContentPath)

Example 68 with Content

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

the class AbstractContentCommand method filterScheduledPublished.

protected Contents filterScheduledPublished(Contents contents) {
    final Instant now = Instant.now();
    final List<Content> filteredContentList = contents.stream().filter(content -> !this.contentPendingOrExpired(content, now)).collect(Collectors.toList());
    return Contents.from(filteredContentList);
}
Also used : ContentConstants(com.enonic.xp.content.ContentConstants) ContentIndexPath(com.enonic.xp.content.ContentIndexPath) EventPublisher(com.enonic.xp.event.EventPublisher) Node(com.enonic.xp.node.Node) LoggerFactory(org.slf4j.LoggerFactory) Callable(java.util.concurrent.Callable) ContentTypeName(com.enonic.xp.schema.content.ContentTypeName) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) ContentId(com.enonic.xp.content.ContentId) ContextAccessor(com.enonic.xp.context.ContextAccessor) ApplicationWildcardMatcher(com.enonic.xp.app.ApplicationWildcardMatcher) NodeService(com.enonic.xp.node.NodeService) ContextBuilder(com.enonic.xp.context.ContextBuilder) PropertyPath(com.enonic.xp.data.PropertyPath) GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) RangeFilter(com.enonic.xp.query.filter.RangeFilter) PropertyTree(com.enonic.xp.data.PropertyTree) Logger(org.slf4j.Logger) ContentPropertyNames(com.enonic.xp.content.ContentPropertyNames) ContentPath(com.enonic.xp.content.ContentPath) Predicate(java.util.function.Predicate) Content(com.enonic.xp.content.Content) ContentPublishInfo(com.enonic.xp.content.ContentPublishInfo) ValueFactory(com.enonic.xp.data.ValueFactory) Instant(java.time.Instant) ContentType(com.enonic.xp.schema.content.ContentType) Collectors(java.util.stream.Collectors) ContentNotFoundException(com.enonic.xp.content.ContentNotFoundException) ApplicationKey(com.enonic.xp.app.ApplicationKey) List(java.util.List) Contents(com.enonic.xp.content.Contents) BooleanFilter(com.enonic.xp.query.filter.BooleanFilter) Filters(com.enonic.xp.query.filter.Filters) Preconditions(com.google.common.base.Preconditions) Context(com.enonic.xp.context.Context) Content(com.enonic.xp.content.Content) Instant(java.time.Instant)

Example 69 with Content

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

the class OccurrenceValidatorTest method testOptionSetWithDefaultValue.

@Test
public void testOptionSetWithDefaultValue() {
    Form form = Form.create().addFormItem(FormOptionSet.create().name("checkOptionSet").label("Multi selection").expanded(true).helpText("Help Text").multiple(true).multiselection(Occurrences.create(1, 3)).occurrences(Occurrences.create(1, 1)).addOptionSetOption(FormOptionSetOption.create().name("option_1").label("option_1").helpText("Help text for Option_1").build()).addOptionSetOption(FormOptionSetOption.create().name("option_2").label("option_2").helpText("Help text for Option_2").build()).addOptionSetOption(FormOptionSetOption.create().name("option_3").label("option_3").defaultOption(true).helpText("Help text for Option_3").addFormItem(Input.create().name("htmlAreaField").label("Input").inputType(InputTypeName.HTML_AREA).occurrences(Occurrences.create(2, 4)).build()).build()).build()).build();
    ContentType contentType = ContentType.create().name("myapplication:my_type").superType(ContentTypeName.structured()).form(form).build();
    Content content = Content.create().path(MY_CONTENT_PATH).type(contentType.getName()).build();
    content.getData().setSet("checkOptionSet.option_3", new PropertySet());
    final ValidationErrors validationResults = validate(content);
    assertFalse(validationResults.hasErrors());
}
Also used : ContentType(com.enonic.xp.schema.content.ContentType) Form(com.enonic.xp.form.Form) ValidationErrors(com.enonic.xp.content.ValidationErrors) Content(com.enonic.xp.content.Content) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 70 with Content

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

the class OccurrenceValidatorTest method given_input_with_minOccur1_with_one_null_value_when_validate_then_hasErrors_returns_MinimumOccurrencesValidationError.

@Test
public void given_input_with_minOccur1_with_one_null_value_when_validate_then_hasErrors_returns_MinimumOccurrencesValidationError() {
    contentType.getForm().getFormItems().add(Input.create().name("myInput").label("Input").inputType(InputTypeName.TEXT_LINE).minimumOccurrences(1).build());
    Content content = Content.create().path(MY_CONTENT_PATH).type(contentType.getName()).build();
    content.getData().setString("myInput[0]", null);
    // exercise
    final ValidationErrors validationResults = validate(content);
    assertTrue(validationResults.hasErrors());
    assertThat(validationResults.stream()).allMatch(ve -> ve instanceof DataValidationError);
}
Also used : ValidationErrors(com.enonic.xp.content.ValidationErrors) Content(com.enonic.xp.content.Content) DataValidationError(com.enonic.xp.content.DataValidationError) 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