### Question:
JcrUserFieldDescriptor implements UserFieldDescriptor { @Nullable @Override public String getDescription() { try { return node.getProperty(JcrExtensibleType.DESCRIPTION).getString(); } catch (PathNotFoundException e) { return null; } catch (RepositoryException e) { throw new MetadataRepositoryException("Unable to access field node: " + node, e); } } JcrUserFieldDescriptor(final Node node, final PropertyDefinition definition); @Nullable @Override String getDescription(); @Nullable @Override String getDisplayName(); @Override int getOrder(); @Override boolean isRequired(); @Nonnull @Override String getSystemName(); @Override int hashCode(); @Override String toString(); static final String ORDER; static final String REQUIRED; }### Answer:
@Test @SuppressWarnings("unchecked") public void getDescription() throws Exception { final Property description = Mockito.when(Mockito.mock(Property.class).getString()).thenReturn("Node for testing").getMock(); final Node node = Mockito.mock(Node.class); Mockito.when(node.getProperty(JcrExtensibleType.DESCRIPTION)) .thenReturn(description) .thenThrow(PathNotFoundException.class); final JcrUserFieldDescriptor userField = new JcrUserFieldDescriptor(node, Mockito.mock(PropertyDefinition.class)); Assert.assertEquals("Node for testing", userField.getDescription()); Assert.assertNull(userField.getDescription()); }