use of com.enonic.xp.form.Input in project xp by enonic.
the class JsonToPropertyTreeTranslator method mapValue.
private void mapValue(final PropertySet parent, final String key, final JsonNode value) {
final Property parentProperty = parent.getProperty();
final Input input = getInput(parentProperty, key);
if (input == null) {
if (this.strictMode) {
throw new IllegalArgumentException("No mapping defined for property " + key + " with value " + resolveStringValue(value));
}
parent.addProperty(key, resolveCoreValue(value));
} else {
final InputType type = this.inputTypeResolver.resolve(input.getInputType());
final Value mappedPropertyValue = type.createValue(resolveCoreValue(value), input.getInputTypeConfig());
parent.addProperty(key, mappedPropertyValue);
}
}
use of com.enonic.xp.form.Input in project xp by enonic.
the class DateTypeTest method testCreateDefaultValue_invalid.
@Test
public void testCreateDefaultValue_invalid() {
final Input input = getDefaultInputBuilder(InputTypeName.DATE, "2014-18-16").build();
assertThrows(IllegalArgumentException.class, () -> this.type.createDefaultValue(input));
}
use of com.enonic.xp.form.Input in project xp by enonic.
the class DateTypeTest method testRelativeDefaultValue.
@Test
public void testRelativeDefaultValue() {
final Input input = getDefaultInputBuilder(InputTypeName.DATE, "+1year -5months -36d").build();
final Value value = this.type.createDefaultValue(input);
assertNotNull(value);
assertSame(ValueTypes.LOCAL_DATE, value.getType());
assertEquals(value.getObject(), LocalDate.now().plusYears(1).plusMonths(-5).plusDays(-36));
}
use of com.enonic.xp.form.Input in project xp by enonic.
the class GeoPointTypeTest method testCreateDefaultValue.
@Test
public void testCreateDefaultValue() {
final Input input = getDefaultInputBuilder(InputTypeName.GEO_POINT, "41.387588,2.169994").build();
final Value value = this.type.createDefaultValue(input);
assertNotNull(value);
assertEquals("41.387588,2.169994", value.toString());
}
use of com.enonic.xp.form.Input in project xp by enonic.
the class GeoPointTypeTest method testCreateDefaultValue_invalid.
@Test
public void testCreateDefaultValue_invalid() {
final Input input = getDefaultInputBuilder(InputTypeName.GEO_POINT, "41.387588;2.169994").build();
assertThrows(IllegalArgumentException.class, () -> this.type.createDefaultValue(input));
}
Aggregations