Search in sources :

Example 41 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class IssueNodeTranslatorTest method createItemSet.

private static PropertySet createItemSet(final String id, final boolean recursive) {
    final PropertySet itemSet = new PropertySet();
    itemSet.addString(PublishRequestPropertyNames.ITEM_ID, id);
    itemSet.addBoolean(PublishRequestPropertyNames.ITEM_RECURSIVE, recursive);
    return itemSet;
}
Also used : PropertySet(com.enonic.xp.data.PropertySet)

Example 42 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class UpdateIssueCommandTest method createMockData.

private PropertyTree createMockData() {
    final PropertyTree propertyTree = new PropertyTree();
    final PropertySet issueAsData = propertyTree.getRoot();
    issueAsData.ifNotNull().addString(STATUS, IssueStatus.OPEN.toString());
    issueAsData.ifNotNull().addString(CREATOR, PrincipalKey.from("user:myStore:me").toString());
    issueAsData.ifNotNull().addString(TITLE, "title");
    issueAsData.ifNotNull().addLong(INDEX, 1L);
    return propertyTree;
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 43 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class PageDataSerializerTest method component_config.

@Test
public void component_config() {
    final Page page = createPage();
    final PropertyTree pageAsData = new PropertyTree();
    pageDataSerializer.toData(page, pageAsData.getRoot());
    final PropertySet componentOnlyData = pageAsData.getRoot().getProperties(COMPONENTS).get(1).getSet();
    assertTrue(componentOnlyData.hasProperty("part.config.app-descriptor-x.name-x"));
    assertEquals("somevalue", componentOnlyData.getString("part.config.app-descriptor-x.name-x.some"));
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Page(com.enonic.xp.page.Page) Test(org.junit.jupiter.api.Test) AbstractDataSerializerTest(com.enonic.xp.core.impl.content.page.AbstractDataSerializerTest)

Example 44 with PropertySet

use of com.enonic.xp.data.PropertySet 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 45 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class InputValidatorTest method validate_incorrect_input_types.

@Test
public void validate_incorrect_input_types() {
    // Validates an incorrect value
    PropertyTree invalidData = new PropertyTree();
    invalidData.addLong("textLine", 1L);
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addLong("double", 1L);
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addDouble("long", 1.0d);
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addBoolean("comboBox", true);
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addString("comboBox", "value4");
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addDouble("checkbox", 1.0d);
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addDouble("tag", 1.0d);
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addDouble("contentSelector", 1.0d);
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addDouble("contentTypeFilter", 1.0d);
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addLocalDateTime("date", LocalDateTime.of(2015, 03, 13, 10, 00, 0));
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addInstant("time", Instant.now());
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addString("geoPoint", "59.9127300, 10.7460900");
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addDouble("htmlArea", 1.0d);
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addLocalDate("localDateTime", LocalDate.of(2015, 03, 13));
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidData.addLocalDate("dateTime", LocalDate.of(2015, 03, 13));
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    PropertySet invalidSet = new PropertySet();
    invalidSet.addDouble("setString", 1.0d);
    invalidData.addSet("set", invalidSet);
    validateIncorrectInputType(invalidData);
    // Validates an incorrect value
    invalidData = new PropertyTree();
    invalidSet = new PropertySet();
    invalidSet.addLong("setDouble", 1L);
    invalidData.addSet("set", invalidSet);
    validateIncorrectInputType(invalidData);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Aggregations

PropertySet (com.enonic.xp.data.PropertySet)225 PropertyTree (com.enonic.xp.data.PropertyTree)150 Test (org.junit.jupiter.api.Test)69 Content (com.enonic.xp.content.Content)30 Node (com.enonic.xp.node.Node)20 CreateContentParams (com.enonic.xp.content.CreateContentParams)12 ContentId (com.enonic.xp.content.ContentId)11 Property (com.enonic.xp.data.Property)11 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)10 PrincipalKey (com.enonic.xp.security.PrincipalKey)9 ContentQuery (com.enonic.xp.content.ContentQuery)7 DescriptorKey (com.enonic.xp.page.DescriptorKey)7 ExtraDatas (com.enonic.xp.content.ExtraDatas)6 Form (com.enonic.xp.form.Form)6 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)6 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)5 ContentPropertyNames (com.enonic.xp.content.ContentPropertyNames)5 ExtraData (com.enonic.xp.content.ExtraData)5 PropertyPath (com.enonic.xp.data.PropertyPath)5 Page (com.enonic.xp.page.Page)5