BaseEditor { protected ParameterizedCommand<Path> onSuccess() { return (path) -> { final T content = getContentSupplier().get(); final M metadata = getMetadataSupplier().get(); setOriginalHash(content.hashCode()); Optional<M> optionalMetadata = Optional.ofNullable(getMetadataSupplier().get()); if (optionalMetadata.isPresent()) { setMetadataOriginalHash(metadata.hashCode()); } }; } BaseEditor(VersionRecordManager versionRecordManager,
               BaseEditorView baseView,
               BasicFileMenuBuilder menuBuilder,
               Event<ChangeTitleWidgetEvent> changeTitleNotification); protected  BaseEditor(); protected  BaseEditor(final BaseEditorView baseView); Validator getRenameValidator(); Validator getCopyValidator(); void setOriginalHash(Integer originalHash); String getTitleText(); RemoteCallback<Path> getSaveSuccessCallback(final int newHash); void onRestore(@Observes RestoreEvent restore); void reload(); void disableMenuItem(final MenuItems menuItem); void enableMenuItem(final MenuItems menuItem); void getMenus(final Consumer<Menus> menusConsumer); Command getValidateCommand(); boolean mayClose(Integer currentHash); boolean isDirty(Integer currentHash); VersionRecordManager getVersionRecordManager(); void setMetadataOriginalHash(final Integer metadataOriginalHash);  }
@Test public void testOnSuccess() { final Path path = mock(Path.class); final String content = "content"; final int contentHash = content.hashCode(); final int metadataHash = 456; final Supplier<String> contentSupplier = () -> content; final Supplier<DefaultMetadata> metadataSupplier = () -> fakeMetadata(metadataHash); doReturn(contentSupplier).when(editor).getContentSupplier(); doReturn(metadataSupplier).when(editor).getMetadataSupplier(); editor.onSuccess().execute(path); verify(editor).setOriginalHash(contentHash); verify(editor).setMetadataOriginalHash(metadataHash); }