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");
}
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);
}
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);
}
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());
}
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);
}
Aggregations