### Question:
PomEditor extends KieTextEditorPresenter { @Override protected void save(final String commitMessage) { doSave(commitMessage, VALIDATED); } @Inject  PomEditor(final KieTextEditorView baseView,
                     final Caller<PomEditorService> pomEditorService,
                     final ConflictingRepositoriesPopup conflictingRepositoriesPopup,
                     final Event<NotificationEvent> notificationEvent,
                     final TranslationService translationService); @OnStartup void onStartup(final ObservablePath path,
                          final PlaceRequest place); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @WorkbenchPartTitleDecoration IsWidget getTitle(); @WorkbenchPartTitle String getTitleText(); @WorkbenchPartView IsWidget asWidget(); @Override AceEditorMode getAceEditorMode(); static final String EDITOR_ID; final Event<NotificationEvent> notificationEvent; final TranslationService translationService; }### Answer:
@Test public void testSaveNonClashingGAV() { presenter.save(comment); verify(service, times(1)).save(any(ObservablePath.class), eq(pomXml), any(Metadata.class), eq(comment), eq(DeploymentMode.VALIDATED)); verify(view, times(1)).showBusyIndicator(eq(CommonConstants.INSTANCE.Saving())); verify(view, times(1)).hideBusyIndicator(); }
@Test public void testSaveInvalid() { doThrow(new InvalidPomException(10, 10)) .when(service).save(any(ObservablePath.class), eq(pomXml), any(Metadata.class), eq(comment), eq(DeploymentMode.VALIDATED)); presenter.save(comment); verify(service, times(1)).save(any(ObservablePath.class), eq(pomXml), any(Metadata.class), eq(comment), eq(DeploymentMode.VALIDATED)); verify(view, times(1)).showBusyIndicator(eq(CommonConstants.INSTANCE.Saving())); verify(view, times(1)).hideBusyIndicator(); verify(notificationEvent, times(1)).fire(any()); }
@Test @SuppressWarnings("unchecked") public void testSaveClashingGAV() { final GAVAlreadyExistsException gae = new GAVAlreadyExistsException(gav, Collections.<MavenRepositoryMetadata>emptySet()); doThrow(gae).when(service).save(any(ObservablePath.class), eq(pomXml), any(Metadata.class), eq(comment), eq(DeploymentMode.VALIDATED)); presenter.save(comment); verify(service, times(1)).save(any(ObservablePath.class), eq(pomXml), any(Metadata.class), eq(comment), eq(DeploymentMode.VALIDATED)); verify(view, times(1)).showBusyIndicator(eq(CommonConstants.INSTANCE.Saving())); verify(view, times(1)).hideBusyIndicator(); final ArgumentCaptor<Command> commandArgumentCaptor = ArgumentCaptor.forClass(Command.class); verify(conflictingRepositoriesPopup, times(1)).setContent(eq(gav), any(Set.class), commandArgumentCaptor.capture()); verify(conflictingRepositoriesPopup, times(1)).show(); assertNotNull(commandArgumentCaptor.getValue()); commandArgumentCaptor.getValue().execute(); verify(service, times(1)).save(any(ObservablePath.class), eq(pomXml), any(Metadata.class), eq(comment), eq(DeploymentMode.FORCED)); verify(view, times(2)).showBusyIndicator(eq(CommonConstants.INSTANCE.Saving())); verify(view, times(2)).hideBusyIndicator(); }