ItemFacade implements Item { @Override public final void refresh(boolean keepChanges) throws RepositoryException { session.refresh(keepChanges); } @SuppressWarnings("WeakerAccess")  ItemFacade(final @NotNull J delegate, final @NotNull SessionFacade<S> session); @SuppressWarnings("WeakerAccess") static @NotNull Item ensureBestWrapper(final @NotNull Item primaryItem, final @NotNull SessionFacade<?> session); @Override final String getPath(); @Override final String getName(); @Override final Item getAncestor(int depth); @Override final Node getParent(); @Override final int getDepth(); @Override final Session getSession(); @Override final boolean isNode(); @Override final boolean isNew(); @Override final boolean isModified(); @Override final boolean isSame(Item otherItem); @Override final void accept(ItemVisitor visitor); @Override final void refresh(boolean keepChanges); @Override final void save(); @Override final void remove();  }
@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)); }