@Test public void testComplete() { final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateId", "ServerTemplateName" ); serverTemplate.getCapabilities().add( Capability.PROCESS.toString() ); final ContainerSpec containerSpec = new ContainerSpec(); containerSpec.setId( "containerSpecId" ); PageResponse<JarListPageRow> response = new PageResponse<JarListPageRow>(); JarListPageRow jarListPageRow = new JarListPageRow(); GAV gav = new GAV("test", "test", "1.0"); containerSpec.setReleasedId(new ReleaseId(gav.getGroupId(), gav.getArtifactId(), gav.getVersion())); jarListPageRow.setGav(gav); jarListPageRow.setPath("test_path"); response.setPageRowList(Arrays.asList(jarListPageRow)); when(m2RepoService.listArtifacts(any())).thenReturn(response); when( newContainerFormPresenter.buildContainerSpec( eq( serverTemplate.getId() ), anyMap() ) ).thenReturn( containerSpec ); when( newContainerFormPresenter.getServerTemplate() ).thenReturn( serverTemplate ); final String successMessage = "SUCCESS"; when( newContainerFormPresenterView.getNewContainerWizardSaveSuccess() ).thenReturn( successMessage ); newContainerWizard.setServerTemplate( serverTemplate ); newContainerWizard.complete(); verify( processConfigPagePresenter ).buildProcessConfig(); verify( newContainerFormPresenter ).buildContainerSpec( eq( serverTemplate.getId() ), anyMap() ); verify(newContainerFormPresenter).showBusyIndicator(containerSpec.getReleasedId().toString()); verify(newContainerFormPresenter).hideBusyIndicator(); final ArgumentCaptor<NotificationEvent> eventCaptor = ArgumentCaptor.forClass( NotificationEvent.class ); verify( notification ).fire( eventCaptor.capture() ); final NotificationEvent event = eventCaptor.getValue(); assertEquals( successMessage, event.getNotification() ); assertEquals( NotificationEvent.NotificationType.SUCCESS, event.getType() ); final ArgumentCaptor<ServerTemplateSelected> serverTemplateEventCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( serverTemplateEventCaptor.capture() ); final ServerTemplateSelected serverEvent = serverTemplateEventCaptor.getValue(); assertEquals( serverTemplate, serverEvent.getServerTemplateKey() ); assertEquals( containerSpec.getId(), serverEvent.getContainerId() ); verifyClear(); doThrow( new RuntimeException() ).when( specManagementService ).saveContainerSpec( anyString(), any( ContainerSpec.class ) ); final String errorMessage = "ERROR"; when( newContainerFormPresenterView.getNewContainerWizardSaveError() ).thenReturn( errorMessage ); newContainerWizard.complete(); verify( notification ).fire( new NotificationEvent( errorMessage, NotificationEvent.NotificationType.ERROR ) ); verify( newContainerWizard ).pageSelected( 0 ); verify( newContainerWizard ).start(); verify( newContainerFormPresenter ).initialise(); }
@Override public void complete() { final Map<Capability, ContainerConfig> mapConfig = new HashMap<Capability, ContainerConfig>(); if (getPages().size() == 2) { mapConfig.put(Capability.PROCESS, processConfigPagePresenter.buildProcessConfig()); } mapConfig.put(Capability.RULE, new RuleConfig(null, KieScannerStatus.STOPPED)); final ContainerSpec newContainer = newContainerFormPresenter.buildContainerSpec(newContainerFormPresenter.getServerTemplate().getId(), mapConfig); GAV gav = new GAV(newContainer.getReleasedId().getGroupId(), newContainer.getReleasedId().getArtifactId(), newContainer.getReleasedId().getVersion()); 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)).findFirst(); if (optionalJarListPageRow.isPresent()) { saveContainerSpec(newContainer); } else { confirmPopup.show(newContainerFormPresenter.getView().getNewContainerSaveContainerSpec(), newContainerFormPresenter.getView().getNewContainerSave(), newContainerFormPresenter.getView().getNewContainerGAVNotExistSave(gav.toString()), () -> saveContainerSpec(newContainer)); } }).listArtifacts(request); }
NewContainerWizard extends AbstractMultiPageWizard { @Override public void complete() { final Map<Capability, ContainerConfig> mapConfig = new HashMap<Capability, ContainerConfig>(); if (getPages().size() == 2) { mapConfig.put(Capability.PROCESS, processConfigPagePresenter.buildProcessConfig()); } mapConfig.put(Capability.RULE, new RuleConfig(null, KieScannerStatus.STOPPED)); final ContainerSpec newContainer = newContainerFormPresenter.buildContainerSpec(newContainerFormPresenter.getServerTemplate().getId(), mapConfig); GAV gav = new GAV(newContainer.getReleasedId().getGroupId(), newContainer.getReleasedId().getArtifactId(), newContainer.getReleasedId().getVersion()); 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)).findFirst(); if (optionalJarListPageRow.isPresent()) { saveContainerSpec(newContainer); } else { confirmPopup.show(newContainerFormPresenter.getView().getNewContainerSaveContainerSpec(), newContainerFormPresenter.getView().getNewContainerSave(), newContainerFormPresenter.getView().getNewContainerGAVNotExistSave(gav.toString()), () -> saveContainerSpec(newContainer)); } }).listArtifacts(request); } }
NewContainerWizard extends AbstractMultiPageWizard { @Override public void complete() { final Map<Capability, ContainerConfig> mapConfig = new HashMap<Capability, ContainerConfig>(); if (getPages().size() == 2) { mapConfig.put(Capability.PROCESS, processConfigPagePresenter.buildProcessConfig()); } mapConfig.put(Capability.RULE, new RuleConfig(null, KieScannerStatus.STOPPED)); final ContainerSpec newContainer = newContainerFormPresenter.buildContainerSpec(newContainerFormPresenter.getServerTemplate().getId(), mapConfig); GAV gav = new GAV(newContainer.getReleasedId().getGroupId(), newContainer.getReleasedId().getArtifactId(), newContainer.getReleasedId().getVersion()); 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)).findFirst(); if (optionalJarListPageRow.isPresent()) { saveContainerSpec(newContainer); } else { confirmPopup.show(newContainerFormPresenter.getView().getNewContainerSaveContainerSpec(), newContainerFormPresenter.getView().getNewContainerSave(), newContainerFormPresenter.getView().getNewContainerGAVNotExistSave(gav.toString()), () -> saveContainerSpec(newContainer)); } }).listArtifacts(request); } @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 complete() { final Map<Capability, ContainerConfig> mapConfig = new HashMap<Capability, ContainerConfig>(); if (getPages().size() == 2) { mapConfig.put(Capability.PROCESS, processConfigPagePresenter.buildProcessConfig()); } mapConfig.put(Capability.RULE, new RuleConfig(null, KieScannerStatus.STOPPED)); final ContainerSpec newContainer = newContainerFormPresenter.buildContainerSpec(newContainerFormPresenter.getServerTemplate().getId(), mapConfig); GAV gav = new GAV(newContainer.getReleasedId().getGroupId(), newContainer.getReleasedId().getArtifactId(), newContainer.getReleasedId().getVersion()); 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)).findFirst(); if (optionalJarListPageRow.isPresent()) { saveContainerSpec(newContainer); } else { confirmPopup.show(newContainerFormPresenter.getView().getNewContainerSaveContainerSpec(), newContainerFormPresenter.getView().getNewContainerSave(), newContainerFormPresenter.getView().getNewContainerGAVNotExistSave(gav.toString()), () -> saveContainerSpec(newContainer)); } }).listArtifacts(request); } @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 complete() { final Map<Capability, ContainerConfig> mapConfig = new HashMap<Capability, ContainerConfig>(); if (getPages().size() == 2) { mapConfig.put(Capability.PROCESS, processConfigPagePresenter.buildProcessConfig()); } mapConfig.put(Capability.RULE, new RuleConfig(null, KieScannerStatus.STOPPED)); final ContainerSpec newContainer = newContainerFormPresenter.buildContainerSpec(newContainerFormPresenter.getServerTemplate().getId(), mapConfig); GAV gav = new GAV(newContainer.getReleasedId().getGroupId(), newContainer.getReleasedId().getArtifactId(), newContainer.getReleasedId().getVersion()); 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)).findFirst(); if (optionalJarListPageRow.isPresent()) { saveContainerSpec(newContainer); } else { confirmPopup.show(newContainerFormPresenter.getView().getNewContainerSaveContainerSpec(), newContainerFormPresenter.getView().getNewContainerSave(), newContainerFormPresenter.getView().getNewContainerGAVNotExistSave(gav.toString()), () -> saveContainerSpec(newContainer)); } }).listArtifacts(request); } @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);  }