ServiceTaskUploadFormPresenter implements ServiceTaskUploadFormView.Presenter { @Override public void handleSubmitComplete(final AbstractForm.SubmitCompleteEvent event) { view.hideUploadingBusy(); if (UPLOAD_MISSING_POM.equalsIgnoreCase(event.getResults())) { view.showInvalidJarNoPomWarning(); view.hide(); } else if (UPLOAD_UNABLE_TO_PARSE_POM.equalsIgnoreCase(event.getResults())) { view.showInvalidPomWarning(); view.hide(); } else if (UPLOAD_FAILED.equalsIgnoreCase(event.getResults())) { view.showUploadFailedError(); view.hide(); } else { serviceTaskService.call((Map<String, List<String>> serviceTasks) -> { String addTaskSuccessMsg = view.getSuccessInstallMessage(); String skippedServiceTasks = view.getSkippedMessage(serviceTasks.get(SKIPPED).stream().collect(Collectors.joining(","))); String addedServiceTasks = serviceTasks.get(CREATED).stream().collect(Collectors.joining(",")); notificationEvent.fire(new NotificationEvent(addTaskSuccessMsg + addedServiceTasks + "/n" + skippedServiceTasks, NotificationEvent.NotificationType.SUCCESS)); onUploadCompleted.execute(); view.hide(); }).addServiceTasks(event.getResults()); } } @Inject  ServiceTaskUploadFormPresenter(final ServiceTaskUploadFormView view,
                                          final Caller<ServiceTaskService> serviceTaskService,
                                          Event<NotificationEvent> notificationEvent,
                                          final SyncBeanManager iocManager); @PostConstruct void init(); @Override void handleSubmitComplete(final AbstractForm.SubmitCompleteEvent event); @Override boolean isFileNameValid(); void showView(Command onUploadCompleted); @Override Command onCloseCommand(); static final String UPLOAD_FAILED; }
@Test public void testUploadMissingPom() { AbstractForm.SubmitCompleteEvent event = mock(AbstractForm.SubmitCompleteEvent.class); when(event.getResults()).thenReturn(UPLOAD_MISSING_POM); presenter.handleSubmitComplete(event); verify(view, times(1)).showInvalidJarNoPomWarning(); verify(view, times(1)).hide(); verify(serviceTaskService, never()).addServiceTasks(any()); }
@Test public void testUploadInvalidPom() { AbstractForm.SubmitCompleteEvent event = mock(AbstractForm.SubmitCompleteEvent.class); when(event.getResults()).thenReturn(UPLOAD_UNABLE_TO_PARSE_POM); presenter.handleSubmitComplete(event); verify(view, times(1)).showInvalidPomWarning(); verify(view, times(1)).hide(); verify(serviceTaskService, never()).addServiceTasks(any()); }
@Test public void testUploadFailed() { AbstractForm.SubmitCompleteEvent event = mock(AbstractForm.SubmitCompleteEvent.class); when(event.getResults()).thenReturn(UPLOAD_FAILED); presenter.handleSubmitComplete(event); verify(view, times(1)).showUploadFailedError(); verify(view, times(1)).hide(); verify(serviceTaskService, never()).addServiceTasks(any()); }