Search in sources :

Example 66 with PropertyTree

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

the class ScriptValueTranslatorTest method mapTest.

@Test
public void mapTest() throws Exception {
    final PropertyTree properties = getPropertyTree("map");
    assertNotNull(properties.getSet("myMap"));
    assertNotNull(properties.getSet("myMap.a"));
    assertNotNull(properties.getLong("myMap.a.b"));
    validateType(properties, "myMap", ValueTypes.PROPERTY_SET);
    validateType(properties, "myMap.a", ValueTypes.PROPERTY_SET);
    validateType(properties, "myMap.a.b", ValueTypes.LONG);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 67 with PropertyTree

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

the class ScriptValueTranslatorTest method localDateFromDate.

@Test
public void localDateFromDate() throws Exception {
    final PropertyTree properties = getPropertyTree("localDateFromDate");
    assertNotNull(properties.getLocalDate("myLocalDate"));
    assertEquals(properties.getLocalDate("myLocalDateExpected"), properties.getLocalDate("myLocalDate"));
    validateType(properties, "myLocalDate", ValueTypes.LOCAL_DATE);
    assertEquals(properties.getLocalDate("myLocalDateExpected"), properties.getLocalDate("myLocalDate"));
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 68 with PropertyTree

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

the class JsonToPropertyTreeTranslatorTest method map_array_values.

@Test
public void map_array_values() throws Exception {
    final JsonNode node = loadJson("allInputTypes");
    final PropertyTree data = new JsonToPropertyTreeTranslator(null, false).translate(node);
    final Property myArray = data.getProperty("stringArray");
    assertNotNull(myArray);
    assertEquals(ValueTypes.STRING.getName(), myArray.getType().getName());
    final Property myArray0 = data.getProperty("stringArray[0]");
    assertNotNull(myArray0);
    final Property myArray1 = data.getProperty("stringArray[1]");
    assertNotNull(myArray1);
    final Property myArray2 = data.getProperty("stringArray[2]");
    assertNotNull(myArray2);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) JsonNode(com.fasterxml.jackson.databind.JsonNode) Property(com.enonic.xp.data.Property) InputTypeProperty(com.enonic.xp.inputtype.InputTypeProperty) Test(org.junit.jupiter.api.Test)

Example 69 with PropertyTree

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

the class JsonToPropertyTreeTranslatorTest method all_input_types.

@Test
public void all_input_types() throws Exception {
    final JsonNode node = loadJson("allInputTypes");
    final PropertyTree data = new JsonToPropertyTreeTranslator(createFormForAllInputTypes(), true).translate(node);
    final Property media = data.getProperty("media");
    assertNotNull(media);
    assertEquals(ValueTypes.PROPERTY_SET.getName(), media.getType().getName());
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) JsonNode(com.fasterxml.jackson.databind.JsonNode) Property(com.enonic.xp.data.Property) InputTypeProperty(com.enonic.xp.inputtype.InputTypeProperty) Test(org.junit.jupiter.api.Test)

Example 70 with PropertyTree

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

the class ApplicationInfoServiceImplTest method mockIdProviderApplication.

private void mockIdProviderApplication(final ApplicationKey applicationKey) {
    final IdProviderDescriptor idProviderDescriptor = IdProviderDescriptor.create().config(Form.create().build()).key(applicationKey).mode(IdProviderDescriptorMode.EXTERNAL).build();
    final IdProvider idProvider1 = IdProvider.create().displayName("idProvider1").key(IdProviderKey.from("idProvider1")).idProviderConfig(IdProviderConfig.create().applicationKey(applicationKey).config(new PropertyTree()).build()).build();
    final IdProvider idProvider2 = IdProvider.create().displayName("idProvider2").key(IdProviderKey.from("idProvider2" + "")).idProviderConfig(IdProviderConfig.create().applicationKey(applicationKey).config(new PropertyTree()).build()).build();
    Mockito.when(this.idProviderDescriptorService.getDescriptor(applicationKey)).thenReturn(idProviderDescriptor);
    Mockito.when(this.securityService.getIdProviders()).thenReturn(IdProviders.from(idProvider1, idProvider2));
}
Also used : IdProviderDescriptor(com.enonic.xp.idprovider.IdProviderDescriptor) IdProvider(com.enonic.xp.security.IdProvider) PropertyTree(com.enonic.xp.data.PropertyTree)

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