* returns true if value and its type are convertible to DoubleValue.
*/
public void testConversions()
throws NotExecutableException, RepositoryException {
PropertyDefinition propDef =
NodeTypeUtil.locatePropertyDef(session, PropertyType.DOUBLE, false, false, false, false);
if (propDef == null) {
throw new NotExecutableException("No double property def that meets the " +
"requirements of the test has been found");
}
NodeType nodeType = propDef.getDeclaringNodeType();
Value anyStringValue = NodeTypeUtil.getValueOfType(session, PropertyType.STRING);
assertFalse("canSetProperty(String propertyName, Value value) must return " +
"false if the property is of type Double and value is a StringValue " +
"that is not convertible to a DoubleValue",
nodeType.canSetProperty(propDef.getName(), anyStringValue));
Value doubleStringValue =
superuser.getValueFactory().createValue(NodeTypeUtil.getValueOfType(session, PropertyType.DOUBLE).getString());
assertTrue("canSetProperty(String propertyName, Value value) must return " +
"true if the property is of type Double and value is a StringValue " +
"that is convertible to a DoubleValue",
nodeType.canSetProperty(propDef.getName(), doubleStringValue));
Value anyBinaryValue = NodeTypeUtil.getValueOfType(session, PropertyType.BINARY);
assertFalse("canSetProperty(String propertyName, Value value) must return " +
"false if the property is of type Double and value is a UTF-8 " +
"BinaryValue that is not convertible to a DoubleValue",
nodeType.canSetProperty(propDef.getName(), anyBinaryValue));
Value doubleBinaryValue =
superuser.getValueFactory().createValue(NodeTypeUtil.getValueOfType(session, PropertyType.DOUBLE).getString(), PropertyType.BINARY);
assertTrue("canSetProperty(String propertyName, Value value) must return " +
"true if the property is of type Double and value is a UTF-8 " +
"BinaryValue that is convertible to a DoubleValue",
nodeType.canSetProperty(propDef.getName(), doubleBinaryValue));
Value dateValue = NodeTypeUtil.getValueOfType(session, PropertyType.DATE);
assertTrue("canSetProperty(String propertyName, Value value) must return " +
"true if the property is of type Double and value is a DateValue",
nodeType.canSetProperty(propDef.getName(), dateValue));
Value doubleValue = NodeTypeUtil.getValueOfType(session, PropertyType.DOUBLE);
assertTrue("canSetProperty(String propertyName, Value value) must return " +
"true if the property is of type Double and value is a DoubleValue",
nodeType.canSetProperty(propDef.getName(), doubleValue));
Value longValue = NodeTypeUtil.getValueOfType(session, PropertyType.LONG);
assertTrue("canSetProperty(String propertyName, Value value) must return " +
"true if the property is of type Double and value is a LongValue",
nodeType.canSetProperty(propDef.getName(), longValue));
Value booleanValue = NodeTypeUtil.getValueOfType(session, PropertyType.BOOLEAN);
assertFalse("canSetProperty(String propertyName, Value value) must return " +
"false if the property is of type Double and value is a BooleanValue",
nodeType.canSetProperty(propDef.getName(), booleanValue));
Value nameValue = NodeTypeUtil.getValueOfType(session, PropertyType.NAME);
assertFalse("canSetProperty(String propertyName, Value value) must return " +
"false if the property is of type Double and value is a NameValue",
nodeType.canSetProperty(propDef.getName(), nameValue));
Value pathValue = NodeTypeUtil.getValueOfType(session, PropertyType.PATH);
assertFalse("canSetProperty(String propertyName, Value value) must return " +
"false if the property is of type Double and value is a PathValue",
nodeType.canSetProperty(propDef.getName(), pathValue));
}