Search in sources :

Example 61 with PropertyTree

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

the class ScriptValueTranslatorTest method localTimeFromDate.

@Test
public void localTimeFromDate() throws Exception {
    final PropertyTree properties = getPropertyTree("localTimeFromDate");
    assertNotNull(properties.getLocalTime("myLocalTime"));
    validateType(properties, "myLocalTime", ValueTypes.LOCAL_TIME);
    assertEquals(properties.getLocalTime("myLocalTimeExpected"), properties.getLocalTime("myLocalTime"));
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 62 with PropertyTree

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

the class ScriptValueTranslatorTest method doubleTest.

@Test
public void doubleTest() throws Exception {
    final PropertyTree properties = getPropertyTree("double");
    assertNotNull(properties.getDouble("myDouble"));
    validateType(properties, "myDouble", ValueTypes.DOUBLE);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 63 with PropertyTree

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

the class SubmitTaskHandler method submitTask.

public String submitTask() {
    descriptor = descriptor == null ? "" : descriptor;
    final DescriptorKey taskKey;
    if (descriptor.contains(":")) {
        taskKey = DescriptorKey.from(descriptor);
    } else {
        final ApplicationKey app = getApplication();
        if (app == null) {
            throw new RuntimeException("Could not resolve current application for descriptord task: '" + descriptor + "'");
        }
        taskKey = DescriptorKey.from(app, descriptor);
    }
    final TaskService taskService = taskServiceSupplier.get();
    PropertyTree data = propertyTreeMarshallerServiceSupplier.get().marshal(Optional.ofNullable(config).map(ScriptValue::getMap).orElse(Map.of()));
    final SubmitTaskParams params = SubmitTaskParams.create().descriptorKey(taskKey).data(data).build();
    final TaskId taskId = taskService.submitTask(params);
    return taskId.toString();
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) ScriptValue(com.enonic.xp.script.ScriptValue) TaskId(com.enonic.xp.task.TaskId) TaskService(com.enonic.xp.task.TaskService) PropertyTree(com.enonic.xp.data.PropertyTree) DescriptorKey(com.enonic.xp.page.DescriptorKey) SubmitTaskParams(com.enonic.xp.task.SubmitTaskParams)

Example 64 with PropertyTree

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

the class ScriptValueTranslatorTest method binary.

@Test
public void binary() throws Exception {
    final ScriptValueTranslatorResult params = getCreateNodeHandlerParams("binary");
    final PropertyTree properties = params.getPropertyTree();
    assertNotNull(properties.getBinaryReference("myBinary"));
    validateType(properties, "myBinary", ValueTypes.BINARY_REFERENCE);
    final BinaryAttachments binaryAttachments = params.getBinaryAttachments();
    assertEquals(1, binaryAttachments.getSize());
}
Also used : BinaryAttachments(com.enonic.xp.node.BinaryAttachments) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 65 with PropertyTree

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

the class ScriptValueTranslatorTest method integer.

@Test
public void integer() throws Exception {
    final PropertyTree properties = getPropertyTree("integer");
    assertNotNull(properties.getLong("myInteger"));
    validateType(properties, "myInteger", ValueTypes.LONG);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Aggregations

PropertyTree (com.enonic.xp.data.PropertyTree)660 Test (org.junit.jupiter.api.Test)405 PropertySet (com.enonic.xp.data.PropertySet)150 Content (com.enonic.xp.content.Content)126 Node (com.enonic.xp.node.Node)112 CreateContentParams (com.enonic.xp.content.CreateContentParams)64 Form (com.enonic.xp.form.Form)37 Page (com.enonic.xp.page.Page)32 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)31 DescriptorKey (com.enonic.xp.page.DescriptorKey)30 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)30 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)28 PrincipalKey (com.enonic.xp.security.PrincipalKey)28 BinaryReference (com.enonic.xp.util.BinaryReference)28 Property (com.enonic.xp.data.Property)26 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)24 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)23 ByteSource (com.google.common.io.ByteSource)22 ExtraData (com.enonic.xp.content.ExtraData)21 Instant (java.time.Instant)21