JcrPropertyDefinition extends JcrItemDefinition implements PropertyDefinition { boolean satisfiesConstraints( Value value, JcrSession session ) { if (value == null) return false; if (valueConstraints == null || valueConstraints.length == 0) { return true; } int type = requiredType == PropertyType.UNDEFINED ? value.getType() : requiredType; ConstraintChecker checker = this.checker; if (checker == null || checker.getType() != type) { checker = createChecker(context, type, valueConstraints); this.checker = checker; } try { return checker.matches(value, session); } catch (ValueFormatException vfe) { return false; } } JcrPropertyDefinition( ExecutionContext context,
                           JcrNodeType declaringNodeType,
                           NodeKey prototypeKey,
                           Name name,
                           int onParentVersion,
                           boolean autoCreated,
                           boolean mandatory,
                           boolean protectedItem,
                           JcrValue[] defaultValues,
                           int requiredType,
                           String[] valueConstraints,
                           boolean multiple,
                           boolean fullTextSearchable,
                           boolean queryOrderable,
                           String[] queryOperators ); PropertyDefinitionId getId(); @Override JcrValue[] getDefaultValues(); boolean hasDefaultValues(); @Override int getRequiredType(); @Override String[] getValueConstraints(); @Override boolean isMultiple(); @Override boolean isFullTextSearchable(); @Override boolean isQueryOrderable(); @Override String[] getAvailableQueryOperators(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj );  }
@Test public void shouldAllowNullValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_BINARY); assertThat(prop.satisfiesConstraints((Value)null, session), is(false)); }
@Test public void shouldAllowValidBinaryValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_BINARY); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(0), PropertyType.BINARY), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(4), PropertyType.BINARY), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(10), PropertyType.BINARY), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(19), PropertyType.BINARY), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(31), PropertyType.BINARY), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(40), PropertyType.BINARY), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(50), PropertyType.BINARY), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(99), PropertyType.BINARY), session), is(true)); }
@Test public void shouldAllowValidBinaryValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_BINARY); Value[] values = new Value[] {valueFor(stringOfLength(4), PropertyType.BINARY), valueFor(stringOfLength(10), PropertyType.BINARY), valueFor(stringOfLength(19), PropertyType.BINARY),}; assertThat(satisfiesConstraints(prop, new Value[] {}), is(true)); assertThat(satisfiesConstraints(prop, new Value[] {valueFor(stringOfLength(0), PropertyType.BINARY)}), is(true)); assertThat(satisfiesConstraints(prop, values), is(true)); }
@Test public void shouldNotAllowInvalidBinaryValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_BINARY); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(5), PropertyType.BINARY), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(9), PropertyType.BINARY), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(20), PropertyType.BINARY), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(30), PropertyType.BINARY), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(41), PropertyType.BINARY), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(stringOfLength(49), PropertyType.BINARY), session), is(false)); }
@Test public void shouldNotAllowInvalidBinaryValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_BINARY); Value[] values = new Value[] {valueFor(stringOfLength(4), PropertyType.BINARY), valueFor(stringOfLength(10), PropertyType.BINARY), valueFor(stringOfLength(20), PropertyType.BINARY),}; assertThat(satisfiesConstraints(prop, new Value[] {valueFor(stringOfLength(9), PropertyType.BINARY)}), is(false)); assertThat(satisfiesConstraints(prop, values), is(false)); }
@Test public void shouldAllowValidDateValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DATE); assertThat(prop.satisfiesConstraints(valueFor("-1945-08-01T01:30:00.000Z", PropertyType.DATE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("+1945-07-31T01:30:00.000Z", PropertyType.DATE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("+0001-08-01T01:30:00.000Z", PropertyType.DATE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("+1975-08-01T01:30:00.000Z", PropertyType.DATE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("+1975-08-01T01:31:00.000Z", PropertyType.DATE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("+2009-08-01T01:30:00.000Z", PropertyType.DATE), session), is(true)); }
@Test public void shouldAllowValidDateValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DATE); Value[] values = new Value[] {valueFor("-1945-08-01T01:30:00.000Z", PropertyType.DATE), valueFor("+2009-08-01T01:30:00.000Z", PropertyType.DATE),}; assertThat(satisfiesConstraints(prop, new Value[] {}), is(true)); assertThat(satisfiesConstraints(prop, new Value[] {valueFor("+1975-08-01T01:31:00.000Z", PropertyType.DATE)}), is(true)); assertThat(satisfiesConstraints(prop, values), is(true)); }
@Test public void shouldNotAllowInvalidDateValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DATE); assertThat(prop.satisfiesConstraints(valueFor("+1945-08-01T01:30:00.001Z", PropertyType.DATE), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor("+1975-08-01T01:29:59.999Z", PropertyType.DATE), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor("+1945-08-01T01:30:00.000-05:00", PropertyType.DATE), session), is(false)); }
@Test public void shouldNotAllowInvalidDateValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DATE); Value[] values = new Value[] {valueFor("-1945-08-01T01:30:00.000", PropertyType.DATE), valueFor("+1945-08-01T01:30:00.000-05:00", PropertyType.DATE),}; assertThat(satisfiesConstraints(prop, new Value[] {valueFor("+1945-08-01T01:30:00.001Z", PropertyType.DATE)}), is(false)); assertThat(satisfiesConstraints(prop, values), is(false)); }
@Test public void shouldAllowValidDoubleValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DOUBLE); assertThat(prop.satisfiesConstraints(valueFor(Double.MIN_VALUE, PropertyType.DOUBLE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(0, PropertyType.DOUBLE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(0.1, PropertyType.DOUBLE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(4.99, PropertyType.DOUBLE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(10.100, PropertyType.DOUBLE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(20.19, PropertyType.DOUBLE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(30.31, PropertyType.DOUBLE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(40.4, PropertyType.DOUBLE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(50.5, PropertyType.DOUBLE), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(Double.MAX_VALUE, PropertyType.DOUBLE), session), is(true)); }
@Test public void shouldAllowValidDoubleValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DOUBLE); Value[] values = new Value[] {valueFor(0.1, PropertyType.DOUBLE), valueFor(20.19, PropertyType.DOUBLE), valueFor(50.5, PropertyType.DOUBLE)}; assertThat(satisfiesConstraints(prop, new Value[] {}), is(true)); assertThat(satisfiesConstraints(prop, new Value[] {valueFor(4.99, PropertyType.DOUBLE)}), is(true)); assertThat(satisfiesConstraints(prop, values), is(true)); }
@Test public void shouldNotAllowInvalidDoubleValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DOUBLE); assertThat(prop.satisfiesConstraints(valueFor(5, PropertyType.DOUBLE), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(9.99999999, PropertyType.DOUBLE), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(20.2, PropertyType.DOUBLE), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(30.3, PropertyType.DOUBLE), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(40.41, PropertyType.DOUBLE), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(49.9, PropertyType.DOUBLE), session), is(false)); }
@Test public void shouldNotAllowInvalidDoubleValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_DOUBLE); Value[] values = new Value[] {valueFor(0.1, PropertyType.DOUBLE), valueFor(20.19, PropertyType.DOUBLE), valueFor(50.49, PropertyType.DOUBLE)}; assertThat(satisfiesConstraints(prop, new Value[] {valueFor(20.2, PropertyType.DOUBLE)}), is(false)); assertThat(satisfiesConstraints(prop, values), is(false)); }
@Test public void shouldAllowValidLongValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_LONG); assertThat(prop.satisfiesConstraints(valueFor(Long.MIN_VALUE, PropertyType.LONG), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(0, PropertyType.LONG), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(0.1, PropertyType.LONG), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(4.99, PropertyType.LONG), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(10, PropertyType.LONG), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(10.100, PropertyType.LONG), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(19, PropertyType.LONG), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(31, PropertyType.LONG), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(40, PropertyType.LONG), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(50, PropertyType.LONG), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor(Long.MAX_VALUE, PropertyType.LONG), session), is(true)); }
@Test public void shouldAllowValidLongValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_LONG); Value[] values = new Value[] {valueFor(0.1, PropertyType.LONG), valueFor(10, PropertyType.LONG), valueFor(50, PropertyType.LONG)}; assertThat(satisfiesConstraints(prop, new Value[] {}), is(true)); assertThat(satisfiesConstraints(prop, new Value[] {valueFor(4.99, PropertyType.LONG)}), is(true)); assertThat(satisfiesConstraints(prop, values), is(true)); }
@Test public void shouldNotAllowInvalidLongValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_LONG); assertThat(prop.satisfiesConstraints(valueFor(5, PropertyType.LONG), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(9, PropertyType.LONG), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(20, PropertyType.LONG), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(30, PropertyType.LONG), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(41, PropertyType.LONG), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor(49, PropertyType.LONG), session), is(false)); }
@Test public void shouldNotAllowInvalidLongValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_LONG); Value[] values = new Value[] {valueFor(0.1, PropertyType.LONG), valueFor(10, PropertyType.LONG), valueFor(49, PropertyType.LONG)}; assertThat(satisfiesConstraints(prop, new Value[] {valueFor(30, PropertyType.LONG)}), is(false)); assertThat(satisfiesConstraints(prop, values), is(false)); }
@Test public void shouldAllowValidNameValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_NAME); assertThat(prop.satisfiesConstraints(valueFor("jcr:system", PropertyType.NAME), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("modetest:constrainedType", PropertyType.NAME), session), is(true)); session.setNamespacePrefix("newprefix", TestLexicon.Namespace.URI); assertThat(prop.satisfiesConstraints(valueFor("newprefix:constrainedType", PropertyType.NAME), session), is(true)); }
@Test public void shouldAllowValidNameValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_NAME); Value[] values = new Value[] {valueFor("jcr:system", PropertyType.NAME), valueFor("modetest:constrainedType", PropertyType.NAME),}; assertThat(satisfiesConstraints(prop, new Value[] {}), is(true)); assertThat(satisfiesConstraints(prop, new Value[] {valueFor("jcr:system", PropertyType.NAME)}), is(true)); assertThat(satisfiesConstraints(prop, values), is(true)); }
@Test( expected = ValueFormatException.class ) public void shouldNotAllowInvalidNameValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_NAME); assertThat(prop.satisfiesConstraints(valueFor("system", PropertyType.NAME), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor("jcr:system2", PropertyType.NAME), session), is(false)); session.setNamespacePrefix("newprefix", TestLexicon.Namespace.URI); assertThat(prop.satisfiesConstraints(valueFor("modetest:constrainedType", PropertyType.NAME), session), is(false)); }
@Test public void shouldNotAllowInvalidNameValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_NAME); Value[] values = new Value[] {valueFor("jcr:system", PropertyType.NAME), valueFor("modetest:constrainedType2", PropertyType.NAME),}; assertThat(satisfiesConstraints(prop, new Value[] {valueFor("jcr:system2", PropertyType.NAME)}), is(false)); assertThat(satisfiesConstraints(prop, values), is(false)); }
@Test public void shouldAllowValidStringValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_STRING); assertThat(prop.satisfiesConstraints(valueFor("foo", PropertyType.STRING), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("bar", PropertyType.STRING), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("barr", PropertyType.STRING), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("barrrrrrrrr", PropertyType.STRING), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("baz", PropertyType.STRING), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("shabaz", PropertyType.STRING), session), is(true)); }
@Test public void shouldAllowValidStringValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_STRING); Value[] values = new Value[] {valueFor("foo", PropertyType.STRING), valueFor("barr", PropertyType.STRING),}; assertThat(satisfiesConstraints(prop, new Value[] {}), is(true)); assertThat(satisfiesConstraints(prop, new Value[] {valueFor("baz", PropertyType.STRING)}), is(true)); assertThat(satisfiesConstraints(prop, values), is(true)); }
@Test public void shouldNotAllowInvalidStringValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_STRING); assertThat(prop.satisfiesConstraints(valueFor("", PropertyType.STRING), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor("foot", PropertyType.STRING), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor("abar", PropertyType.STRING), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor("bard", PropertyType.STRING), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor("baz!", PropertyType.STRING), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor("bazzat", PropertyType.STRING), session), is(false)); }
@Test public void shouldNotAllowInvalidStringValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_STRING); Value[] values = new Value[] {valueFor("foo", PropertyType.STRING), valueFor("bard", PropertyType.STRING),}; assertThat(satisfiesConstraints(prop, new Value[] {valueFor("bazzat", PropertyType.STRING)}), is(false)); assertThat(satisfiesConstraints(prop, values), is(false)); }
@Test public void shouldAllowValidPathValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_PATH); assertThat(prop.satisfiesConstraints(valueFor("b", PropertyType.PATH), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("/a/b/c", PropertyType.PATH), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("/jcr:system/mode:namespace", PropertyType.PATH), session), is(true)); assertThat(prop.satisfiesConstraints(valueFor("/a/b/c/", PropertyType.PATH), session), is(true)); session.setNamespacePrefix("jcr2", JcrLexicon.Namespace.URI); assertThat(prop.satisfiesConstraints(valueFor("/jcr2:system/mode:foo", PropertyType.PATH), session), is(true)); }
@Test public void shouldAllowValidPathValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_PATH); Value[] values = new Value[] {valueFor("b", PropertyType.PATH), valueFor("/a/b/c", PropertyType.PATH),}; assertThat(satisfiesConstraints(prop, new Value[] {}), is(true)); assertThat(satisfiesConstraints(prop, new Value[] {valueFor("/a/b/c", PropertyType.PATH)}), is(true)); assertThat(satisfiesConstraints(prop, values), is(true)); }
@Test public void shouldNotAllowInvalidPathValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_PATH); assertThat(prop.satisfiesConstraints(valueFor("a", PropertyType.PATH), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor("/a/b", PropertyType.PATH), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor("/jcr:system", PropertyType.PATH), session), is(false)); assertThat(prop.satisfiesConstraints(valueFor("/a/b/c/d", PropertyType.PATH), session), is(false)); }
@Test public void shouldNotAllowInvalidPathValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_PATH); Value[] values = new Value[] {valueFor("b", PropertyType.PATH), valueFor("/a/b/c/d", PropertyType.PATH),}; assertThat(satisfiesConstraints(prop, new Value[] {valueFor("/a", PropertyType.PATH)}), is(false)); assertThat(satisfiesConstraints(prop, values), is(false)); }
@Test public void shouldAllowValidReferenceValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_REFERENCE); Value value = session.getValueFactory().createValue(session.getRootNode()); assertThat(prop.satisfiesConstraints(value, session), is(true)); }
@Test public void shouldAllowValidReferenceValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_REFERENCE); Value value = session.getValueFactory().createValue(session.getRootNode()); assertThat(satisfiesConstraints(prop, new Value[] {}), is(true)); assertThat(satisfiesConstraints(prop, new Value[] {value}), is(true)); }
@Test public void shouldNotAllowInvalidReferenceValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_REFERENCE); Value value = session.getValueFactory().createValue(session.getRootNode().getNode("a")); assertThat(prop.satisfiesConstraints(value, session), is(false)); }
@Test public void shouldNotAllowInvalidReferenceValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_REFERENCE); Value value = session.getValueFactory().createValue(session.getRootNode().getNode("a")); assertThat(satisfiesConstraints(prop, new Value[] {value}), is(false)); }