SaveAndRenameCommandBuilder { protected void callSaveAndRename(final FileNameAndCommitMessage details) { final String newFileName = details.getNewFileName(); final String commitMessage = details.getCommitMessage(); beforeSaveAndRenameCommand.execute(); renameCaller.call(onSuccess(), onError()).saveAndRename(getPath(), newFileName, getMetadata(), getContent(), commitMessage); } @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 callSaveAndRename() { final String newFileName = "newFileName"; final String commitMessage = "commitMessage"; final FileNameAndCommitMessage message = new FileNameAndCommitMessage(newFileName, commitMessage); builder .addRenameService(renameCaller) .addPathSupplier(pathSupplierFake) .addMetadataSupplier(metadataSupplierFake) .addContentSupplier(contentSupplierFake) .addSuccessCallback(onSuccess) .addBeforeSaveAndRenameCommand(beforeSaveAndRenameCommand) .callSaveAndRename(message); verify(beforeSaveAndRenameCommand, only()).execute(); verify(renameCaller, only()).call(isA(RemoteCallback.class), isA(SaveAndRenameCommandBuilder.SaveAndRenameErrorCallback.class)); verify(service, only()).saveAndRename(eq(path), eq(newFileName), eq(metadata), eq(content), eq(commitMessage)); }