SaveAndRenameCommandBuilder { RemoteCallback<Path> onSuccess() { return (Path path) -> { notifyRenameInProgress(); onSuccess.execute(path); hideRenamePopup(); hideBusyIndicator(); notifyItemRenamedSuccessfully(); }; } @Inject  SaveAndRenameCommandBuilder(final RenamePopUpPresenter renamePopUpPresenter,
                                       final BusyIndicatorView busyIndicatorView,
                                       final Event<NotificationEvent> notification,
                                       final Event<RenameInProgressEvent> renameInProgressEvent); SaveAndRenameCommandBuilder<T, M> addValidator(final Validator validator); SaveAndRenameCommandBuilder<T, M> addValidator(final Supplier<Boolean> validator); SaveAndRenameCommandBuilder<T, M> addRenameService(final Caller<? extends SupportsSaveAndRename<T, M>> renameCaller); SaveAndRenameCommandBuilder<T, M> addPathSupplier(final Supplier<Path> pathSupplier); SaveAndRenameCommandBuilder<T, M> addMetadataSupplier(final Supplier<M> metadataSupplier); SaveAndRenameCommandBuilder<T, M> addContentSupplier(final Supplier<T> contentSupplier); SaveAndRenameCommandBuilder<T, M> addIsDirtySupplier(final Supplier<Boolean> isDirtySupplier); SaveAndRenameCommandBuilder<T, M> addSuccessCallback(final ParameterizedCommand<Path> onSuccess); SaveAndRenameCommandBuilder<T, M> addErrorCallback(final Command onError); SaveAndRenameCommandBuilder<T, M> addBeforeSaveAndRenameCommand(final Command beforeSaveAndRenameCommand); Command build();  }
@Test public void testOnSuccess() throws Exception { final RenameInProgressEvent renameInProgressEvent = mock(RenameInProgressEvent.class); doReturn(renameInProgressEvent).when(builder).makeRenameInProgressEvent(); builder .addSuccessCallback(onSuccess) .onSuccess() .callback(path); final InOrder inOrder = inOrder(onSuccess, builder); inOrder.verify(builder).notifyRenameInProgress(); inOrder.verify(onSuccess).execute(path); inOrder.verify(builder).hideRenamePopup(); inOrder.verify(builder).hideBusyIndicator(); inOrder.verify(builder).notifyItemRenamedSuccessfully(); }