protected boolean isValidReference( AbstractJcrNode node, Name propertyName, boolean returnValueIfNoProperty ) throws RepositoryException { AbstractJcrProperty property = node.getProperty(propertyName); return property == null ? returnValueIfNoProperty : isValidReference(property); }
protected boolean isValidReference( AbstractJcrNode node, Name propertyName, boolean returnValueIfNoProperty ) throws RepositoryException { AbstractJcrProperty property = node.getProperty(propertyName); return property == null ? returnValueIfNoProperty : isValidReference(property); }
@Test( expected = ValueFormatException.class ) public void shouldNotProvideBooleanConversionForMultiValuedProperty() throws Exception { prop = cars.getProperty("booleanProperty"); prop.getAs(Boolean.class); }
@Test( expected = ValueFormatException.class ) public void shouldNotProvideDateForMultiValuedProperty() throws Exception { prop = cars.getProperty("dateProperty"); prop.getDate(); }
@Test( expected = ValueFormatException.class ) public void shouldNotProvideLongForMultiValuedProperty() throws Exception { prop = cars.getProperty("longProperty"); prop.getLong(); }
@Test( expected = ValueFormatException.class ) public void shouldNotProvideValue() throws Exception { prop = cars.getProperty("stringProperty"); prop.getValue(); }
@Test( expected = ValueFormatException.class ) public void shouldNotProvideStringForMultiValuedProperty() throws Exception { prop = cars.getProperty("stringProperty"); prop.getString(); }
@Test( expected = ValueFormatException.class ) public void shouldNotProvideLength() throws Exception { prop = cars.getProperty("stringProperty"); prop.getLength(); }
@Test( expected = ValueFormatException.class ) public void shouldNotProvideDoubleForMultiValuedProperty() throws Exception { prop = cars.getProperty("doubleProperty"); prop.getDouble(); }
@Test public void shouldReturnFalseFromIsSameIfTheWorkspaceNameIsDifferent() throws Exception { // Use the same id and location; use 'Toyota Prius' String priusUuid2 = prius2.getIdentifier(); String priusUuid = prius.getIdentifier(); assertThat(priusUuid, is(priusUuid2)); assertThat(prius2.isSame(prius), is(false)); // Check the properties ... javax.jcr.Property model = prius.getProperty("car:model"); javax.jcr.Property model2 = prius2.getProperty("car:model"); assertThat(model.isSame(model2), is(false)); }
@Test public void shouldIndicateHasSingleValue() throws Exception { prop = cars.getProperty("booleanProperty"); PropertyDefinition def = prop.getDefinition(); assertThat(def.isMultiple(), is(false)); }
@Test public void shouldIndicateHasMultipleValues() throws Exception { prop = cars.getProperty("booleanProperty"); PropertyDefinition def = prop.getDefinition(); assertThat(def.isMultiple(), is(true)); }
@Test public void shouldProvideString() throws Exception { prop = cars.getProperty("stringProperty"); assertThat(prop.getString(), is(stringValue)); assertThat(prop.getAs(String.class), is(stringValue)); assertThat(prop.getType(), is(PropertyType.STRING)); assertThat(prop.getLength(), is((long)stringValue.length())); checkValue(prop); }
@Test public void shouldAllowNameValue() throws Exception { prop = cars.getProperty("nameProperty"); assertThat(prop.getType(), is(PropertyType.NAME)); assertThat(prop.getString(), is(nameValue)); assertThat(prop.getAs(String.class), is(nameValue)); assertThat(prop.getLength(), is((long)nameValue.length())); // Change the namespace registry ... session.setNamespacePrefix("acme2", "http://example.com"); assertThat(prop.getString(), is("acme2:SomeName")); checkValue(prop); }
@Test public void shouldProvideLong() throws Exception { prop = cars.getProperty("longProperty"); assertThat(prop.getLong(), is(longValue)); assertThat(prop.getAs(Long.class), is(longValue)); assertThat(prop.getString(), is(stringFactory.create(longValue))); assertThat(prop.getType(), is(PropertyType.LONG)); assertThat(prop.getLength(), is((long)stringFactory.create(longValue).length())); checkValue(prop); }
@Test public void shouldAllowPathValue() throws Exception { prop = cars.getProperty("pathProperty"); assertThat(prop.getType(), is(PropertyType.PATH)); assertThat(prop.getString(), is(pathValue)); assertThat(prop.getAs(String.class), is(pathValue)); // Change the namespace registry ... session.setNamespacePrefix("acme2", "http://example.com"); assertThat(prop.getString(), is("/Cars/Hybrid/Toyota Highlander/acme2:SomethingElse")); checkValue(prop); }
@Test public void shouldProvideBoolean() throws Exception { prop = cars.getProperty("booleanProperty"); assertThat(prop.getBoolean(), is(booleanValue)); assertThat(prop.getAs(Boolean.class), is(booleanValue)); assertThat(prop.getType(), is(PropertyType.BOOLEAN)); assertThat(prop.getString(), is(stringFactory.create(booleanValue))); assertThat(prop.getLength(), is((long)stringFactory.create(booleanValue).length())); checkValue(prop); }
@Test public void shouldProvideBooleanValues() throws Exception { prop = cars.getProperty("booleanProperty"); Value[] vals = prop.getValues(); assertThat(vals, notNullValue()); assertThat(vals.length, is(2)); assertThat(vals[0].getBoolean(), is(true)); assertThat(vals[1].getBoolean(), is(false)); assertThat(prop.getAs(Boolean[].class), is(new Boolean[]{true, false})); assertThat(prop.getAs(Boolean.class, 0), is(true)); assertThat(prop.getAs(Boolean.class, 1), is(false)); }
@FixFor( "MODE-1720" ) @Test public void shouldPropertyDereferenceReferencePropertiesCreatedFromStringValues() throws Exception { prop = cars.getProperty("referenceProperty2"); Value[] vals = prop.getValues(); for (Value value : vals) { String str = value.getString(); Node node = cars.getSession().getNodeByIdentifier(str); assertThat(node, IsIn.isOneOf((Node)altima, (Node)aston)); } } }
@Test public void shouldProvideDate() throws Exception { prop = cars.getProperty("dateProperty"); // see ModeShape-527 for reasons asserts are commented // assertThat(prop.getDate(), is(dateValue.toCalendar())); assertThat(prop.getLong(), is(dateValue.getMilliseconds())); // assertThat(prop.getString(), is(stringFactory.create(dateValue))); assertThat(prop.getType(), is(PropertyType.DATE)); // assertThat(prop.getLength(), is((long)stringFactory.create(dateValue).length())); assertThat(prop.getAs(DateTime.class), notNullValue()); checkValue(prop); }