@Test
@SuppressWarnings("unchecked")
public void isRequired() throws Exception {

    // Mock property node
    final Property falseProperty = Mockito.when(Mockito.mock(Property.class).getString()).thenReturn("false").getMock();
    final Property trueProperty = Mockito.when(Mockito.mock(Property.class).getString()).thenReturn("true").getMock();
    final Node node = Mockito.mock(Node.class);
    Mockito.when(node.getProperty(JcrUserFieldDescriptor.REQUIRED))
        .thenReturn(falseProperty)
        .thenReturn(trueProperty)
        .thenThrow(PathNotFoundException.class);
    // Test required
    final JcrUserFieldDescriptor userField = new JcrUserFieldDescriptor(node, Mockito.mock(PropertyDefinition.class));
    Assert.assertFalse(userField.isRequired());
    Assert.assertTrue(userField.isRequired());
    Assert.assertFalse(userField.isRequired());
}