@Test public void testPageSelectedWithEmptyPath() { PageResponse<JarListPageRow> response = new PageResponse<JarListPageRow>(); JarListPageRow jarListPageRow = new JarListPageRow(); GAV gav = new GAV("test", "test", ""); jarListPageRow.setGav(gav); jarListPageRow.setPath(""); response.setPageRowList(Arrays.asList(jarListPageRow)); when(m2RepoService.listArtifacts(any())).thenReturn(response); when(newContainerFormPresenter.getCurrentGAV()).thenReturn(gav); newContainerWizard.pages.add(mock(WizardPage.class)); newContainerWizard.pages.add(mock(WizardPage.class)); newContainerWizard.pageSelected(1); verify(dependencyPathSelectedEvent, never()).fire(any()); verify(notification, never()).fire(any()); }
@Override public void pageSelected(final int pageNumber) { if (this.getSelectedPage() == pageNumber) { return; } if (pageNumber == 1 && !isSelected) { GAV gav = newContainerFormPresenter.getCurrentGAV(); JarListPageRequest request = new JarListPageRequest(0, Integer.MAX_VALUE, null, Arrays.asList("jar"), null, false); m2RepoService.call(response -> { List<JarListPageRow> jarListPageRowList = ((PageResponse<JarListPageRow>) response).getPageRowList(); Optional<JarListPageRow> optionalJarListPageRow = jarListPageRowList.stream().filter(jarListPageRow -> jarListPageRow.getGav().equals(gav)) .sorted(Comparator.comparing(JarListPageRow::getLastModified).reversed()).findFirst(); if (optionalJarListPageRow.isPresent()) { if (optionalJarListPageRow.get().getPath() != null && !optionalJarListPageRow.get().getPath().isEmpty()) { dependencyPathSelectedEvent.fire(new DependencyPathSelectedEvent(this, optionalJarListPageRow.get().getPath())); } } else { notification.fire(new NotificationEvent(newContainerFormPresenter.getView().getNewContainerGAVNotExist(gav.toString()), NotificationEvent.NotificationType.ERROR)); } }).listArtifacts(request); } super.pageSelected(pageNumber); }
NewContainerWizard extends AbstractMultiPageWizard { @Override public void pageSelected(final int pageNumber) { if (this.getSelectedPage() == pageNumber) { return; } if (pageNumber == 1 && !isSelected) { GAV gav = newContainerFormPresenter.getCurrentGAV(); JarListPageRequest request = new JarListPageRequest(0, Integer.MAX_VALUE, null, Arrays.asList("jar"), null, false); m2RepoService.call(response -> { List<JarListPageRow> jarListPageRowList = ((PageResponse<JarListPageRow>) response).getPageRowList(); Optional<JarListPageRow> optionalJarListPageRow = jarListPageRowList.stream().filter(jarListPageRow -> jarListPageRow.getGav().equals(gav)) .sorted(Comparator.comparing(JarListPageRow::getLastModified).reversed()).findFirst(); if (optionalJarListPageRow.isPresent()) { if (optionalJarListPageRow.get().getPath() != null && !optionalJarListPageRow.get().getPath().isEmpty()) { dependencyPathSelectedEvent.fire(new DependencyPathSelectedEvent(this, optionalJarListPageRow.get().getPath())); } } else { notification.fire(new NotificationEvent(newContainerFormPresenter.getView().getNewContainerGAVNotExist(gav.toString()), NotificationEvent.NotificationType.ERROR)); } }).listArtifacts(request); } super.pageSelected(pageNumber); } }
NewContainerWizard extends AbstractMultiPageWizard { @Override public void pageSelected(final int pageNumber) { if (this.getSelectedPage() == pageNumber) { return; } if (pageNumber == 1 && !isSelected) { GAV gav = newContainerFormPresenter.getCurrentGAV(); JarListPageRequest request = new JarListPageRequest(0, Integer.MAX_VALUE, null, Arrays.asList("jar"), null, false); m2RepoService.call(response -> { List<JarListPageRow> jarListPageRowList = ((PageResponse<JarListPageRow>) response).getPageRowList(); Optional<JarListPageRow> optionalJarListPageRow = jarListPageRowList.stream().filter(jarListPageRow -> jarListPageRow.getGav().equals(gav)) .sorted(Comparator.comparing(JarListPageRow::getLastModified).reversed()).findFirst(); if (optionalJarListPageRow.isPresent()) { if (optionalJarListPageRow.get().getPath() != null && !optionalJarListPageRow.get().getPath().isEmpty()) { dependencyPathSelectedEvent.fire(new DependencyPathSelectedEvent(this, optionalJarListPageRow.get().getPath())); } } else { notification.fire(new NotificationEvent(newContainerFormPresenter.getView().getNewContainerGAVNotExist(gav.toString()), NotificationEvent.NotificationType.ERROR)); } }).listArtifacts(request); } super.pageSelected(pageNumber); } @Inject  NewContainerWizard(final NewContainerFormPresenter newContainerFormPresenter,
                              final ProcessConfigPagePresenter processConfigPagePresenter,
                              final Caller<SpecManagementService> specManagementService,
                              final Event<NotificationEvent> notification,
                              final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
                              final Event<DependencyPathSelectedEvent> dependencyPathSelectedEvent,
                              final Caller<M2RepoService> m2RepoService,
                              final ConfirmPopup confirmPopup); }
NewContainerWizard extends AbstractMultiPageWizard { @Override public void pageSelected(final int pageNumber) { if (this.getSelectedPage() == pageNumber) { return; } if (pageNumber == 1 && !isSelected) { GAV gav = newContainerFormPresenter.getCurrentGAV(); JarListPageRequest request = new JarListPageRequest(0, Integer.MAX_VALUE, null, Arrays.asList("jar"), null, false); m2RepoService.call(response -> { List<JarListPageRow> jarListPageRowList = ((PageResponse<JarListPageRow>) response).getPageRowList(); Optional<JarListPageRow> optionalJarListPageRow = jarListPageRowList.stream().filter(jarListPageRow -> jarListPageRow.getGav().equals(gav)) .sorted(Comparator.comparing(JarListPageRow::getLastModified).reversed()).findFirst(); if (optionalJarListPageRow.isPresent()) { if (optionalJarListPageRow.get().getPath() != null && !optionalJarListPageRow.get().getPath().isEmpty()) { dependencyPathSelectedEvent.fire(new DependencyPathSelectedEvent(this, optionalJarListPageRow.get().getPath())); } } else { notification.fire(new NotificationEvent(newContainerFormPresenter.getView().getNewContainerGAVNotExist(gav.toString()), NotificationEvent.NotificationType.ERROR)); } }).listArtifacts(request); } super.pageSelected(pageNumber); } @Inject  NewContainerWizard(final NewContainerFormPresenter newContainerFormPresenter,
                              final ProcessConfigPagePresenter processConfigPagePresenter,
                              final Caller<SpecManagementService> specManagementService,
                              final Event<NotificationEvent> notification,
                              final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
                              final Event<DependencyPathSelectedEvent> dependencyPathSelectedEvent,
                              final Caller<M2RepoService> m2RepoService,
                              final ConfirmPopup confirmPopup); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void setServerTemplate( final ServerTemplate serverTemplate ); void clear(); @Override void close(); @Override void complete(); void onDependencyPathSelectedEvent(@Observes DependencyPathSelectedEvent event); @Override void pageSelected(final int pageNumber); }
NewContainerWizard extends AbstractMultiPageWizard { @Override public void pageSelected(final int pageNumber) { if (this.getSelectedPage() == pageNumber) { return; } if (pageNumber == 1 && !isSelected) { GAV gav = newContainerFormPresenter.getCurrentGAV(); JarListPageRequest request = new JarListPageRequest(0, Integer.MAX_VALUE, null, Arrays.asList("jar"), null, false); m2RepoService.call(response -> { List<JarListPageRow> jarListPageRowList = ((PageResponse<JarListPageRow>) response).getPageRowList(); Optional<JarListPageRow> optionalJarListPageRow = jarListPageRowList.stream().filter(jarListPageRow -> jarListPageRow.getGav().equals(gav)) .sorted(Comparator.comparing(JarListPageRow::getLastModified).reversed()).findFirst(); if (optionalJarListPageRow.isPresent()) { if (optionalJarListPageRow.get().getPath() != null && !optionalJarListPageRow.get().getPath().isEmpty()) { dependencyPathSelectedEvent.fire(new DependencyPathSelectedEvent(this, optionalJarListPageRow.get().getPath())); } } else { notification.fire(new NotificationEvent(newContainerFormPresenter.getView().getNewContainerGAVNotExist(gav.toString()), NotificationEvent.NotificationType.ERROR)); } }).listArtifacts(request); } super.pageSelected(pageNumber); } @Inject  NewContainerWizard(final NewContainerFormPresenter newContainerFormPresenter,
                              final ProcessConfigPagePresenter processConfigPagePresenter,
                              final Caller<SpecManagementService> specManagementService,
                              final Event<NotificationEvent> notification,
                              final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
                              final Event<DependencyPathSelectedEvent> dependencyPathSelectedEvent,
                              final Caller<M2RepoService> m2RepoService,
                              final ConfirmPopup confirmPopup); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void setServerTemplate( final ServerTemplate serverTemplate ); void clear(); @Override void close(); @Override void complete(); void onDependencyPathSelectedEvent(@Observes DependencyPathSelectedEvent event); @Override void pageSelected(final int pageNumber);  }