@Test public void testAccept() throws Exception { Node delegate = mock(Node.class); ItemFacade<Item, Session> facade = getFacade(delegate); CompletableFuture<String> pathLatch = new CompletableFuture<>(); final String expectedPath = "/correct/path"; when(delegate.getPath()).thenReturn(expectedPath); doAnswer(invoked -> { ((ItemVisitor) invoked.getArgument(0)).visit(delegate); return true; }).when(delegate).accept(any(ItemVisitor.class)); facade.accept(new ItemVisitor() { @Override public void visit(final Property property) throws RepositoryException { } @Override public void visit(final Node node) throws RepositoryException { assertTrue("is facade", node instanceof NodeFacade); assertSame("is same as delegate", delegate, NodeFacade.unwrap(node)); pathLatch.complete(node.getPath()); } }); assertEquals("expect path after visitor", expectedPath, pathLatch.getNow("")); }
@Override public final void accept(ItemVisitor visitor) throws RepositoryException { delegate.accept(new ItemWrappingVisitor<>(visitor, session)); }
ItemFacade implements Item { @Override public final void accept(ItemVisitor visitor) throws RepositoryException { delegate.accept(new ItemWrappingVisitor<>(visitor, session)); } }
ItemFacade implements Item { @Override public final void accept(ItemVisitor visitor) throws RepositoryException { delegate.accept(new ItemWrappingVisitor<>(visitor, session)); } @SuppressWarnings("WeakerAccess")  ItemFacade(final @NotNull J delegate, final @NotNull SessionFacade<S> session); }
ItemFacade implements Item { @Override public final void accept(ItemVisitor visitor) throws RepositoryException { delegate.accept(new ItemWrappingVisitor<>(visitor, session)); } @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(); }
ItemFacade implements Item { @Override public final void accept(ItemVisitor visitor) throws RepositoryException { delegate.accept(new ItemWrappingVisitor<>(visitor, session)); } @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();  }