@Test(expected = MissingUserPropertyException.class)
public void setUserPropertiesWithMissing() {

    // Mock field
    final UserFieldDescriptor field = Mockito.mock(UserFieldDescriptor.class);
    Mockito.when(field.getSystemName()).thenReturn("requiredProperty");
    Mockito.when(field.isRequired()).thenReturn(true);
    // Test required property
    JcrPropertyUtil.setUserProperties(Mockito.mock(Node.class), Collections.singleton(field), Collections.emptyMap(),true);
}