@Test
public void testRefresh() throws Exception {

    CompletableFuture<Boolean> latchDoKeepChanges = new CompletableFuture<>();
    CompletableFuture<Boolean> latchDontKeepChanges = new CompletableFuture<>();
    Session delegateSession = mock(Session.class);
    doAnswer(invoked -> latchDoKeepChanges.complete(invoked.getArgument(0)))
            .when(delegateSession).refresh(true);
    doAnswer(invoked -> latchDontKeepChanges.complete(invoked.getArgument(0)))
            .when(delegateSession).refresh(false);
    JcrSessionFacade sessionFacade = new JcrSessionFacade(delegateSession, true);
    Item delegate = mock(Item.class);
    ItemFacade<Item, Session> facade = new ItemFacade<>(delegate, sessionFacade);
    facade.refresh(true);
    facade.refresh(false);
    assertTrue("keepChanges true", latchDoKeepChanges.getNow(false));
    assertFalse("keepChanges false", latchDontKeepChanges.getNow(true));
}