Search in sources :

Example 11 with StringValue

use of org.apache.jackrabbit.value.StringValue in project hippo by NHS-digital-website.

the class JcrNodeUtilsTest method getMultipleStringPropertyQuietly_returnsValuesOfGivenPropertyOnGivenNode.

@Test
public void getMultipleStringPropertyQuietly_returnsValuesOfGivenPropertyOnGivenNode() throws RepositoryException {
    // given
    final String expectedPropertyName = "expectedPropertyName";
    final List<String> expectedPropertyValues = asList("value-a", "value-b");
    final Property expectedProperty = mock(Property.class);
    final StringValue[] storedPropertyValues = fromStrings(expectedPropertyValues);
    given(expectedProperty.getValues()).willReturn(storedPropertyValues);
    final Node node = mock(Node.class);
    given(node.getProperty(expectedPropertyName)).willReturn(expectedProperty);
    given(node.hasProperty(expectedPropertyName)).willReturn(true);
    // when
    final List<String> actualPropertyValues = JcrNodeUtils.getMultipleStringPropertyQuietly(node, expectedPropertyName);
    // then
    assertThat("Value returned was read from the given node", actualPropertyValues, is(expectedPropertyValues));
}
Also used : MockNode(org.onehippo.repository.mock.MockNode) StringValue(org.apache.jackrabbit.value.StringValue) Test(org.junit.Test)

Example 12 with StringValue

use of org.apache.jackrabbit.value.StringValue in project hippo by NHS-digital-website.

the class SearchableTaxonomyTaskTest method addSubDocument.

private Node addSubDocument(Node documentNode, String state, String suffix) throws RepositoryException {
    String name = documentNode.getName() + suffix;
    Node document = documentNode.addNode(name);
    document.setProperty("hippostd:state", state);
    document.setProperty(TAXONOMY_KEYS_PROPERTY, new Value[] { new StringValue("taxonomy_1_1_1") });
    return document;
}
Also used : StringValue(org.apache.jackrabbit.value.StringValue)

Aggregations

StringValue (org.apache.jackrabbit.value.StringValue)12 Value (javax.jcr.Value)6 HashMap (java.util.HashMap)5 Node (javax.jcr.Node)2 RepositoryException (javax.jcr.RepositoryException)2 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)2 AccessControlManager (javax.jcr.security.AccessControlManager)2 Privilege (javax.jcr.security.Privilege)2 JackrabbitAccessControlEntry (org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry)2 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)2 NodeImpl (org.apache.jackrabbit.core.NodeImpl)2 BooleanValue (org.apache.jackrabbit.value.BooleanValue)2 Test (org.junit.Test)2 Session (javax.jcr.Session)1 Query (javax.jcr.query.Query)1 QueryManager (javax.jcr.query.QueryManager)1 QueryResult (javax.jcr.query.QueryResult)1 User (org.apache.jackrabbit.api.security.user.User)1 PropertyImpl (org.apache.jackrabbit.core.PropertyImpl)1 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)1