Bert Leunis pushed to branch feature/CHANNELMGR-1388 at cms-community / hippo-addon-channel-manager
Commits: ef71d457 by Bert Leunis at 2018-03-05T16:30:12+01:00 CHANNELMGR-1388 Revert "CHANNELMGR-1391 boolean field type now correctly treats invalid input" This reverts commit 70c3ca73ab5c449247416a8749b41fab564024e8. - - - - - 2 changed files: - content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/BooleanFieldType.java - content-service/src/test/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/BooleanFieldTypeTest.java Changes: ===================================== content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/BooleanFieldType.java ===================================== --- a/content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/BooleanFieldType.java +++ b/content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/BooleanFieldType.java @@ -17,6 +17,10 @@ package org.onehippo.cms.channelmanager.content.documenttype.field.type; import javax.jcr.PropertyType; +import javax.jcr.ValueFormatException; + +import org.onehippo.cms.channelmanager.content.error.BadRequestException; +import org.onehippo.cms.channelmanager.content.error.ErrorWithPayloadException; public class BooleanFieldType extends PrimitiveFieldType { private static final String DEFAULT_VALUE = "false"; @@ -37,9 +41,6 @@ public class BooleanFieldType extends PrimitiveFieldType { @Override protected String fieldSpecificConversion(final String input) { - if (!"true".equalsIgnoreCase(input) && !"false".equalsIgnoreCase(input)) { - throw new IllegalArgumentException("BooleanFieldType value must be 'true' or 'false'."); - } return Boolean.parseBoolean(input) + ""; } } ===================================== content-service/src/test/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/BooleanFieldTypeTest.java ===================================== --- a/content-service/src/test/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/BooleanFieldTypeTest.java +++ b/content-service/src/test/java/org/onehippo/cms/channelmanager/content/documenttype/field/type/BooleanFieldTypeTest.java @@ -22,8 +22,6 @@ import java.util.List; import java.util.Optional; import javax.jcr.Node; -import javax.jcr.PropertyType; -import javax.jcr.Value; import org.hippoecm.repository.util.JcrUtils; import org.junit.Before; @@ -93,43 +91,6 @@ public class BooleanFieldTypeTest { assertThat(node.getProperty(PROPERTY).getString(), equalTo("" + newValue)); } - @Test - public void writeIncorrectValueDoesNotOverwriteExistingValue() throws Exception { - final Node node = MockNode.root(); - final PrimitiveFieldType fieldType = new BooleanFieldType(); - final Boolean oldValue = Boolean.TRUE; - final String invalidValue = "foo"; - - fieldType.setId(PROPERTY); - node.setProperty(PROPERTY, oldValue); - - fieldType.writeTo(node, Optional.of(listOf(valueOf(invalidValue)))); - assertThat(node.getProperty(PROPERTY).getBoolean(), equalTo(oldValue)); - } - - @Test - public void writeIncorrectValuesDoesNotOverwriteExistingValues() throws Exception { - final Node node = MockNode.root(); - final PrimitiveFieldType fieldType = new BooleanFieldType(); - - fieldType.setId(PROPERTY); - fieldType.setMultiple(true); - fieldType.setMaxValues(2); - - final Boolean oldValue1 = Boolean.TRUE; - final Boolean oldValue2 = Boolean.TRUE; - node.setProperty(PROPERTY, new String[] {oldValue1 + "", oldValue2 + ""}, PropertyType.BOOLEAN); - - final String invalidValue1 = "foo"; - final List<FieldValue> es = Arrays.asList(valueOf(invalidValue1), valueOf(oldValue2 + "")); - fieldType.writeTo(node, Optional.of(es)); - - final Value[] values = node.getProperty(PROPERTY).getValues(); - assertThat(values[0].getBoolean(), equalTo(oldValue1)); - assertThat(values[1].getBoolean(), equalTo(oldValue2)); - } - - private static List<FieldValue> listOf(final FieldValue value) { return Collections.singletonList(value); } View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/ef71d45781c70fc72d5babebda47ccbe77cc54f9 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/ef71d45781c70fc72d5babebda47ccbe77cc54f9 You're receiving this email because of your account on code.onehippo.org.
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn