src_fm_fc_ms_ff
stringlengths 43
86.8k
| target
stringlengths 20
276k
|
|---|---|
ServerManagementPerspective { public void onNewTemplate( @Observes final AddNewServerTemplate addNewServerTemplate ) { if ( addNewServerTemplate != null ) { newServerTemplateWizard.clear(); newServerTemplateWizard.start(); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerManagementPerspective( final Logger logger,
final NewServerTemplateWizard newServerTemplateWizard,
final NewContainerWizard newContainerWizard ); @Perspective PerspectiveDefinition buildPerspective(); void onNewTemplate( @Observes final AddNewServerTemplate addNewServerTemplate ); void onNewContainer( @Observes final AddNewContainer addNewContainer ); }
|
@Test public void testOnNewTemplate() { perspective.onNewTemplate( new AddNewServerTemplate() ); verify( newServerTemplateWizard ).clear(); verify( newServerTemplateWizard ).start(); }
|
ServerEmptyPresenter { @PostConstruct public void init() { view.init( this ); } @Inject ServerEmptyPresenter( final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent ); @PostConstruct void init(); View getView(); void addTemplate(); }
|
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); }
|
ServerEmptyPresenter { public void addTemplate() { addNewServerTemplateEvent.fire( new AddNewServerTemplate() ); } @Inject ServerEmptyPresenter( final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent ); @PostConstruct void init(); View getView(); void addTemplate(); }
|
@Test public void testAddTemplate() { presenter.addTemplate(); verify( addNewServerTemplateEvent ).fire( any( AddNewServerTemplate.class ) ); }
|
ProcessConfigPagePresenter implements WizardPage { public void clear() { processConfigPresenter.clear(); } @Inject ProcessConfigPagePresenter( final ProcessConfigPresenter processConfigPresenter ); @Override String getTitle(); @Override void isComplete( final Callback<Boolean> callback ); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); ProcessConfig buildProcessConfig(); void clear(); }
|
@Test public void testClear() { presenter.clear(); verify( processConfigPresenter ).clear(); }
|
ProcessConfigPagePresenter implements WizardPage { public ProcessConfig buildProcessConfig(){ return processConfigPresenter.buildProcessConfig(); } @Inject ProcessConfigPagePresenter( final ProcessConfigPresenter processConfigPresenter ); @Override String getTitle(); @Override void isComplete( final Callback<Boolean> callback ); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); ProcessConfig buildProcessConfig(); void clear(); }
|
@Test public void testBuildProcessConfig() { presenter.buildProcessConfig(); verify( processConfigPresenter ).buildProcessConfig(); }
|
ProcessConfigPagePresenter implements WizardPage { @Override public void isComplete( final Callback<Boolean> callback ) { callback.callback( true ); } @Inject ProcessConfigPagePresenter( final ProcessConfigPresenter processConfigPresenter ); @Override String getTitle(); @Override void isComplete( final Callback<Boolean> callback ); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); ProcessConfig buildProcessConfig(); void clear(); }
|
@Test public void testIsComplete() { final Callback<Boolean> callback = mock( Callback.class ); presenter.isComplete( callback ); verify( callback ).callback( true ); }
|
NewServerTemplateWizard extends AbstractMultiPageWizard { @Override public String getTitle() { return newTemplatePresenter.getView().getNewServerTemplateWizardTitle(); } NewServerTemplateWizard(); @Inject NewServerTemplateWizard( final NewTemplatePresenter newTemplatePresenter,
final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void clear(); @Override void close(); @Override void complete(); }
|
@Test public void testTitle() { final String title = "title"; when( newTemplatePresenterView.getNewServerTemplateWizardTitle() ).thenReturn( title ); assertEquals( title, newServerTemplateWizard.getTitle() ); verify( newTemplatePresenterView ).getNewServerTemplateWizardTitle(); }
|
NewServerTemplateWizard extends AbstractMultiPageWizard { @Override public void complete() { final ServerTemplate newServerTemplate = buildServerTemplate(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void o ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveSuccess(), NotificationEvent.NotificationType.SUCCESS ) ); clear(); NewServerTemplateWizard.super.complete(); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh( newServerTemplate.getId() ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( newTemplatePresenter.getView().getNewServerTemplateWizardSaveError(), NotificationEvent.NotificationType.ERROR ) ); NewServerTemplateWizard.this.pageSelected( 0 ); NewServerTemplateWizard.this.start(); return false; } } ).saveServerTemplate( newServerTemplate ); } NewServerTemplateWizard(); @Inject NewServerTemplateWizard( final NewTemplatePresenter newTemplatePresenter,
final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void clear(); @Override void close(); @Override void complete(); }
|
@Test public void testComplete() { ServerTemplate serverTemplate = new ServerTemplate("template-name", "template-name"); serverTemplate.setMode(KieServerMode.DEVELOPMENT); serverTemplate.setCapabilities(singletonList(Capability.PROCESS.toString())); when( newTemplatePresenter.isProcessCapabilityChecked() ).thenReturn( true ); when( newContainerFormPresenter.isEmpty() ).thenReturn( true ); when( newContainerFormPresenter.isEmpty() ).thenReturn( true ); when( newTemplatePresenter.getTemplateName() ).thenReturn( "template-name" ); final String successMessage = "SUCCESS"; when( newTemplatePresenterView.getNewServerTemplateWizardSaveSuccess() ).thenReturn( successMessage ); newServerTemplateWizard.complete(); ArgumentCaptor<ServerTemplate> serverTemplateCapture = ArgumentCaptor.forClass(ServerTemplate.class); verify(specManagementService).saveServerTemplate(serverTemplateCapture.capture()); assertEquals(KieServerMode.DEVELOPMENT, serverTemplateCapture.getValue().getMode()); verify( notification ).fire( new NotificationEvent( successMessage, NotificationEvent.NotificationType.SUCCESS ) ); verifyClear(); verify( serverTemplateListRefreshEvent ).fire( new ServerTemplateListRefresh( "template-name" ) ); doThrow( new RuntimeException() ).when( specManagementService ).saveServerTemplate( any( ServerTemplate.class ) ); final String errorMessage = "ERROR"; when( newTemplatePresenterView.getNewServerTemplateWizardSaveError() ).thenReturn( errorMessage ); newServerTemplateWizard.complete(); verify( notification ).fire( new NotificationEvent( errorMessage, NotificationEvent.NotificationType.ERROR ) ); verify( newServerTemplateWizard ).pageSelected( 0 ); verify( newServerTemplateWizard ).start(); verify( newContainerFormPresenter ).initialise(); }
|
NewServerTemplateWizard extends AbstractMultiPageWizard { public void clear() { newTemplatePresenter.clear(); newContainerFormPresenter.clear(); processConfigPagePresenter.clear(); pages.clear(); pages.add( newTemplatePresenter ); pages.add( newContainerFormPresenter ); } NewServerTemplateWizard(); @Inject NewServerTemplateWizard( final NewTemplatePresenter newTemplatePresenter,
final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void clear(); @Override void close(); @Override void complete(); }
|
@Test public void testClear() { newServerTemplateWizard.clear(); verifyClear(); }
|
FindAllDmnAssetsQuery extends AbstractFindQuery implements NamedQuery { @Override public ResponseBuilder getResponseBuilder() { return responseBuilder; } @Inject FindAllDmnAssetsQuery(final FileDetailsResponseBuilder responseBuilder); @Override String getName(); @Override Query toQuery(final Set<ValueIndexTerm> terms); @Override Sort getSortOrder(); @Override ResponseBuilder getResponseBuilder(); @Override void validateTerms(final Set<ValueIndexTerm> queryTerms); static String NAME; }
|
@Test public void testGetResponseBuilder() { assertEquals(responseBuilder, query.getResponseBuilder()); }
|
NewServerTemplateWizard extends AbstractMultiPageWizard { @Override public void close() { super.close(); clear(); } NewServerTemplateWizard(); @Inject NewServerTemplateWizard( final NewTemplatePresenter newTemplatePresenter,
final NewContainerFormPresenter newContainerFormPresenter,
final ProcessConfigPagePresenter processConfigPagePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @Override void start(); @Override String getTitle(); @Override int getPreferredHeight(); @Override int getPreferredWidth(); void clear(); @Override void close(); @Override void complete(); }
|
@Test public void testClose() { newServerTemplateWizard.close(); verifyClear(); }
|
NewContainerWizard extends AbstractMultiPageWizard { @Override public String getTitle() { return newContainerFormPresenter.getView().getNewContainerWizardTitle(); } @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); }
|
@Test public void testTitle() { final String title = "title"; when( newContainerFormPresenterView.getNewContainerWizardTitle() ).thenReturn( title ); assertEquals( title, newContainerWizard.getTitle() ); verify( newContainerFormPresenterView ).getNewContainerWizardTitle(); }
|
NewContainerWizard extends AbstractMultiPageWizard { public void clear() { newContainerFormPresenter.clear(); processConfigPagePresenter.clear(); pages.clear(); pages.add( newContainerFormPresenter ); isSelected = false; } @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); }
|
@Test public void testClear() { newContainerWizard.clear(); verifyClear(); }
|
NewContainerWizard extends AbstractMultiPageWizard { public void setServerTemplate( final ServerTemplate serverTemplate ) { this.serverTemplate = serverTemplate; newContainerFormPresenter.setServerTemplate( serverTemplate ); pages.clear(); pages.add( newContainerFormPresenter ); if ( serverTemplate.getCapabilities().contains( Capability.PROCESS.toString() ) ) { pages.add( processConfigPagePresenter ); } } @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); }
|
@Test public void testSetServerTemplate() { final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateId", "ServerTemplateName" ); serverTemplate.getCapabilities().add( Capability.PROCESS.toString() ); newContainerWizard.setServerTemplate( serverTemplate ); verify( newContainerFormPresenter ).setServerTemplate( serverTemplate ); assertEquals( 2, newContainerWizard.getPages().size() ); assertTrue( newContainerWizard.getPages().contains( newContainerFormPresenter ) ); assertTrue( newContainerWizard.getPages().contains( processConfigPagePresenter ) ); }
|
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); }
|
@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(); }
|
NewContainerWizard extends AbstractMultiPageWizard { @Override public void close() { super.close(); clear(); } @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); }
|
@Test public void testClose() { newContainerWizard.close(); verifyClear(); }
|
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); }
|
@Test public void testPageSelectedPageTwo() { preparePageSelected(); newContainerWizard.pageSelected(1); verify(dependencyPathSelectedEvent).fire(any()); }
@Test public void testPageSelectedPageOne() { preparePageSelected(); newContainerWizard.pageSelected(0); verify(dependencyPathSelectedEvent, never()).fire(any()); verify(notification, never()).fire(any()); }
@Test public void testPageSelectedIsSelected() { preparePageSelected(); newContainerWizard.isSelected = true; newContainerWizard.pageSelected(1); verify(dependencyPathSelectedEvent, never()).fire(any()); verify(notification, never()).fire(any()); }
@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()); }
@Test public void testPageSelectedWithNullPath() { PageResponse<JarListPageRow> response = new PageResponse<JarListPageRow>(); JarListPageRow jarListPageRow = new JarListPageRow(); GAV gav = new GAV("test", "test", ""); jarListPageRow.setGav(gav); jarListPageRow.setPath(null); 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()); }
@Test public void testPageSelectedCanNotFind() { PageResponse<JarListPageRow> response = new PageResponse<JarListPageRow>(); JarListPageRow jarListPageRow = new JarListPageRow(); GAV gav = new GAV("test", "test", ""); jarListPageRow.setGav(new GAV("test1", "test1", "1.0")); jarListPageRow.setPath("test_path"); response.setPageRowList(Arrays.asList(jarListPageRow)); when(m2RepoService.listArtifacts(any())).thenReturn(response); when(newContainerFormPresenter.getCurrentGAV()).thenReturn(gav); final String gavNotFind = "NOTFIND"; when(newContainerFormPresenterView.getNewContainerGAVNotExist(any())).thenReturn(gavNotFind); newContainerWizard.pages.add(mock(WizardPage.class)); newContainerWizard.pages.add(mock(WizardPage.class)); newContainerWizard.pageSelected(1); final ArgumentCaptor<NotificationEvent> eventCaptor = ArgumentCaptor.forClass(NotificationEvent.class); verify(notification).fire(eventCaptor.capture()); final NotificationEvent event = eventCaptor.getValue(); assertEquals(gavNotFind, event.getNotification()); }
|
AddRelationColumnCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler handler) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler handler) { if (!uiModelColumn.isPresent()) { uiModelColumn = Optional.of(uiModelColumnSupplier.get()); } uiModel.insertColumn(uiColumnIndex, uiModelColumn.get()); for (int rowIndex = 0; rowIndex < relation.getRow().size(); rowIndex++) { uiModelMapper.fromDMNModel(rowIndex, uiColumnIndex); } updateParentInformation(); executeCanvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler handler) { uiModelColumn.ifPresent(uiModel::deleteColumn); updateParentInformation(); undoCanvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } AddRelationColumnCommand(final Relation relation,
final InformationItem informationItem,
final GridData uiModel,
final Supplier<RelationColumn> uiModelColumnSupplier,
final int uiColumnIndex,
final RelationUIModelMapper uiModelMapper,
final org.uberfire.mvp.Command executeCanvasOperation,
final org.uberfire.mvp.Command undoCanvasOperation); void updateParentInformation(); }
|
@Test public void testCanvasCommandAllow() { final Command<AbstractCanvasHandler, CanvasViolation> c = command.newCanvasCommand(handler); assertEquals(CanvasCommandResultBuilder.SUCCESS, c.allow(handler)); }
|
NewContainerWizard extends AbstractMultiPageWizard { public void onDependencyPathSelectedEvent(@Observes DependencyPathSelectedEvent event){ this.isSelected = true; } @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); }
|
@Test public void testOnDependencyPathSelectedEvent() { assertFalse(newContainerWizard.isSelected); newContainerWizard.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent("null", "test")); assertTrue(newContainerWizard.isSelected); }
|
NewContainerFormPresenter implements WizardPage { @PostConstruct public void init() { view.init(this); view.addContentChangeHandler(new ContentChangeHandler() { @Override public void onContentChange() { wizardPageStatusChangeEvent.fire(new WizardPageStatusChangeEvent(NewContainerFormPresenter.this)); } }); } @Inject NewContainerFormPresenter(final Logger logger,
final View view,
final ManagedInstance<ArtifactListWidgetPresenter> artifactListWidgetPresenterProvider,
final Caller<M2RepoService> m2RepoService,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); @PostConstruct void init(); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); @Override void initialise(); @Override void prepareView(); Mode getMode(); @Override Widget asWidget(); void clear(); boolean isContainerNameValid(); boolean isGroupIdValid(); boolean isArtifactIdValid(); boolean isVersionValid(); boolean isArtifactSupportedByServer(); boolean isValid(); boolean isEmpty(); ServerTemplate getServerTemplate(); void setServerTemplate(final ServerTemplate serverTemplate); ContainerSpec buildContainerSpec(final String serverTemplateId,
final Map<Capability, ContainerConfig> configs); View getView(); void showBusyIndicator(String deploymentId); void hideBusyIndicator(); GAV getCurrentGAV(); static final String SNAPSHOT; }
|
@Test public void testInit() { presenter.init(); final ContentChangeHandler contentChangeHandler = mock(ContentChangeHandler.class); presenter.addContentChangeHandler(contentChangeHandler); view.setVersion("1.0"); view.setArtifactId("artifact"); view.setGroupId("group"); verify(view).init(presenter); verify(wizardPageStatusChangeEvent, times(3)).fire(any(WizardPageStatusChangeEvent.class)); verify(contentChangeHandler, times(3)).onContentChange(); }
|
NewContainerFormPresenter implements WizardPage { public void clear() { serverTemplate = null; mode = Mode.OPTIONAL; view.clear(); } @Inject NewContainerFormPresenter(final Logger logger,
final View view,
final ManagedInstance<ArtifactListWidgetPresenter> artifactListWidgetPresenterProvider,
final Caller<M2RepoService> m2RepoService,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); @PostConstruct void init(); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); @Override void initialise(); @Override void prepareView(); Mode getMode(); @Override Widget asWidget(); void clear(); boolean isContainerNameValid(); boolean isGroupIdValid(); boolean isArtifactIdValid(); boolean isVersionValid(); boolean isArtifactSupportedByServer(); boolean isValid(); boolean isEmpty(); ServerTemplate getServerTemplate(); void setServerTemplate(final ServerTemplate serverTemplate); ContainerSpec buildContainerSpec(final String serverTemplateId,
final Map<Capability, ContainerConfig> configs); View getView(); void showBusyIndicator(String deploymentId); void hideBusyIndicator(); GAV getCurrentGAV(); static final String SNAPSHOT; }
|
@Test public void testClear() { presenter.clear(); verify(view).clear(); assertEquals(NewContainerFormPresenter.Mode.OPTIONAL, presenter.getMode()); assertNull(presenter.getServerTemplate()); }
|
NewContainerFormPresenter implements WizardPage { public boolean isEmpty() { return view.getContainerName().trim().isEmpty() && view.getGroupId().trim().isEmpty() && view.getArtifactId().trim().isEmpty() && view.getVersion().trim().isEmpty(); } @Inject NewContainerFormPresenter(final Logger logger,
final View view,
final ManagedInstance<ArtifactListWidgetPresenter> artifactListWidgetPresenterProvider,
final Caller<M2RepoService> m2RepoService,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); @PostConstruct void init(); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); @Override void initialise(); @Override void prepareView(); Mode getMode(); @Override Widget asWidget(); void clear(); boolean isContainerNameValid(); boolean isGroupIdValid(); boolean isArtifactIdValid(); boolean isVersionValid(); boolean isArtifactSupportedByServer(); boolean isValid(); boolean isEmpty(); ServerTemplate getServerTemplate(); void setServerTemplate(final ServerTemplate serverTemplate); ContainerSpec buildContainerSpec(final String serverTemplateId,
final Map<Capability, ContainerConfig> configs); View getView(); void showBusyIndicator(String deploymentId); void hideBusyIndicator(); GAV getCurrentGAV(); static final String SNAPSHOT; }
|
@Test public void testIsEmpty() { when(view.getContainerName()).thenReturn(" "); when(view.getGroupId()).thenReturn(" "); when(view.getArtifactId()).thenReturn(" "); when(view.getVersion()).thenReturn(" "); assertTrue(presenter.isEmpty()); }
|
NewContainerFormPresenter implements WizardPage { public boolean isValid() { if (mode.equals(Mode.OPTIONAL) && isEmpty()) { view.noErrors(); return true; } boolean hasError = false; if (isContainerNameValid()) { view.noErrorOnContainerName(); } else { view.errorOnContainerName(); hasError = true; } if (isGroupIdValid()) { view.noErrorOnGroupId(); } else { view.errorOnGroupId(); hasError = true; } if (isArtifactIdValid()) { view.noErrorOnArtifactId(); } else { view.errorOnArtifactId(); hasError = true; } if (isVersionValid()) { if (isArtifactSupportedByServer()) { view.noErrorOnVersion(); } else { view.errorOnVersion(); view.errorProductionModeSupportsDoesntSnapshots(); hasError = true; } } else { view.errorOnVersion(); hasError = true; } return !hasError; } @Inject NewContainerFormPresenter(final Logger logger,
final View view,
final ManagedInstance<ArtifactListWidgetPresenter> artifactListWidgetPresenterProvider,
final Caller<M2RepoService> m2RepoService,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); @PostConstruct void init(); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); @Override void initialise(); @Override void prepareView(); Mode getMode(); @Override Widget asWidget(); void clear(); boolean isContainerNameValid(); boolean isGroupIdValid(); boolean isArtifactIdValid(); boolean isVersionValid(); boolean isArtifactSupportedByServer(); boolean isValid(); boolean isEmpty(); ServerTemplate getServerTemplate(); void setServerTemplate(final ServerTemplate serverTemplate); ContainerSpec buildContainerSpec(final String serverTemplateId,
final Map<Capability, ContainerConfig> configs); View getView(); void showBusyIndicator(String deploymentId); void hideBusyIndicator(); GAV getCurrentGAV(); static final String SNAPSHOT; }
|
@Test public void testIsValid() { when(view.getContainerName()).thenReturn(" ").thenReturn("containerName").thenReturn(""); when(view.getGroupId()).thenReturn(" ").thenReturn("groupId").thenReturn(""); when(view.getArtifactId()).thenReturn(" ").thenReturn("artifactId").thenReturn(""); when(view.getVersion()).thenReturn(" ").thenReturn("1.0").thenReturn(""); assertTrue(presenter.isValid()); verify(view).noErrors(); presenter.setServerTemplate(new ServerTemplate()); assertTrue(presenter.isValid()); verify(view).noErrorOnContainerName(); verify(view).noErrorOnGroupId(); verify(view).noErrorOnArtifactId(); verify(view).noErrorOnVersion(); assertFalse(presenter.isValid()); verify(view).errorOnContainerName(); verify(view).errorOnGroupId(); verify(view).errorOnArtifactId(); verify(view).errorOnVersion(); }
|
NewContainerFormPresenter implements WizardPage { void onDependencyPathSelectedEvent(@Observes final DependencyPathSelectedEvent event) { if (event != null && event.getContext() != null && event.getPath() != null) { if (event.getContext().equals(artifactListWidgetPresenter)) { m2RepoService.call(new RemoteCallback<GAV>() { @Override public void callback(GAV gav) { setAValidContainerName(gav.toString()); view.setGroupId(gav.getGroupId()); view.setArtifactId(gav.getArtifactId()); view.setVersion(gav.getVersion()); wizardPageStatusChangeEvent.fire(new WizardPageStatusChangeEvent(NewContainerFormPresenter.this)); } }).loadGAVFromJar(event.getPath()); } } else { logger.warn("Illegal event argument."); } } @Inject NewContainerFormPresenter(final Logger logger,
final View view,
final ManagedInstance<ArtifactListWidgetPresenter> artifactListWidgetPresenterProvider,
final Caller<M2RepoService> m2RepoService,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); @PostConstruct void init(); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); @Override void initialise(); @Override void prepareView(); Mode getMode(); @Override Widget asWidget(); void clear(); boolean isContainerNameValid(); boolean isGroupIdValid(); boolean isArtifactIdValid(); boolean isVersionValid(); boolean isArtifactSupportedByServer(); boolean isValid(); boolean isEmpty(); ServerTemplate getServerTemplate(); void setServerTemplate(final ServerTemplate serverTemplate); ContainerSpec buildContainerSpec(final String serverTemplateId,
final Map<Capability, ContainerConfig> configs); View getView(); void showBusyIndicator(String deploymentId); void hideBusyIndicator(); GAV getCurrentGAV(); static final String SNAPSHOT; }
|
@Test public void testOnDependencyPathSelectedEvent() { final String path = "org:kie:1.0"; final GAV gav = new GAV(path); when(m2RepoService.loadGAVFromJar(path)).thenReturn(gav); when(view.getContainerName()).thenReturn("containerName"); when(view.getContainerAlias()).thenReturn("containerAlias"); when(view.getGroupId()).thenReturn(gav.getGroupId()); when(view.getArtifactId()).thenReturn(gav.getArtifactId()); when(view.getVersion()).thenReturn(gav.getVersion()); presenter.asWidget(); presenter.onDependencyPathSelectedEvent(new DependencyPathSelectedEvent(artifactListWidgetPresenter, path)); verify(m2RepoService).loadGAVFromJar(path); verify(view).setGroupId(gav.getGroupId()); verify(view).setArtifactId(gav.getArtifactId()); verify(view).setVersion(gav.getVersion()); verify(wizardPageStatusChangeEvent).fire(any(WizardPageStatusChangeEvent.class)); final ContainerSpec containerSpec = presenter.buildContainerSpec("templateId", Collections.<Capability, ContainerConfig>emptyMap()); assertEquals(new ReleaseId(gav.getGroupId(), gav.getArtifactId(), gav.getVersion()), containerSpec.getReleasedId()); assertEquals(KieContainerStatus.STOPPED, containerSpec.getStatus()); assertEquals("containerAlias", containerSpec.getContainerName()); assertEquals("containerName", containerSpec.getId()); }
|
NewTemplatePresenter implements WizardPage { @PostConstruct public void init() { this.view.init(this); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view.asWidget(), presenter.asWidget() ); assertEquals( view, presenter.getView() ); }
|
NewTemplatePresenter implements WizardPage { public boolean isTemplateNameValid() { final String templateName = view.getTemplateName(); return templateName == null ? false : !templateName.trim().isEmpty(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testIsTemplateNameValid() { when( view.getTemplateName() ) .thenReturn( null ) .thenReturn( "" ) .thenReturn( "test" ); assertFalse( presenter.isTemplateNameValid() ); assertFalse( presenter.isTemplateNameValid() ); assertTrue( presenter.isTemplateNameValid() ); }
|
DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { relation.getRow().remove(uiRowIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().add(uiRowIndex, oldRow); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); }
|
@Test public void testGraphCommandAllow() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.allow(gce)); }
@Test public void testGraphCommandExecuteWithColumns() { relation.getColumn().add(new InformationItem()); relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression())); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(0, relation.getRow().size()); assertEquals(1, relation.getColumn().size()); }
@Test public void testGraphCommandExecuteRemoveMiddleWithColumns() { uiModel.appendRow(new BaseGridRow()); uiModel.appendRow(new BaseGridRow()); final List firstRow = new List(); final List lastRow = new List(); relation.getRow().add(0, firstRow); relation.getRow().add(lastRow); relation.getColumn().add(new InformationItem()); relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression())); makeCommand(1); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(2, relation.getRow().size()); assertEquals(firstRow, relation.getRow().get(0)); assertEquals(lastRow, relation.getRow().get(1)); assertEquals(1, relation.getColumn().size()); }
@Test public void testGraphCommandExecuteWithNoColumns() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(0, relation.getRow().size()); }
@Test public void testGraphCommandUndoWithColumns() { relation.getColumn().add(new InformationItem()); final LiteralExpression literalExpression = new LiteralExpression(); literalExpression.getText().setValue(VALUE); relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, literalExpression)); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertEquals(1, relation.getColumn().size()); assertEquals(1, relation.getRow().size()); assertEquals(1, relation.getRow().get(0).getExpression().size()); assertEquals(VALUE, ((LiteralExpression) relation.getRow().get(0).getExpression().get(0).getExpression()).getText().getValue()); }
@Test public void testGraphCommandUndoWithNoColumns() { final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce)); assertEquals(0, relation.getColumn().size()); assertEquals(1, relation.getRow().size()); }
|
NewTemplatePresenter implements WizardPage { public boolean isCapabilityValid() { if (view.isPlanningCapabilityChecked() && view.isRuleCapabilityChecked()) { return true; } if (view.isProcessCapabilityChecked() || view.isRuleCapabilityChecked()) { return true; } return false; } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testIsCapabilityValid() { when( view.isPlanningCapabilityChecked() ).thenReturn( true, false, true, false ); when( view.isRuleCapabilityChecked() ).thenReturn( true, false, false ); when( view.isProcessCapabilityChecked() ).thenReturn( true, true, false ); assertTrue( presenter.isCapabilityValid() ); assertTrue( presenter.isCapabilityValid() ); assertTrue( presenter.isCapabilityValid() ); assertFalse( presenter.isCapabilityValid() ); }
|
NewTemplatePresenter implements WizardPage { public boolean isValid() { boolean hasError = false; if (isTemplateNameValid()) { view.noErrorOnTemplateName(); } else { view.errorOnTemplateName(); hasError = true; } if (isCapabilityValid()) { view.noErrorOnCapability(); } else { view.errorCapability(); hasError = true; } return !hasError; } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testIsValid() { when( view.getTemplateName() ).thenReturn( "templateName", "", "templateName" ); when( view.isRuleCapabilityChecked() ).thenReturn( true, false ); when( view.isProcessCapabilityChecked() ).thenReturn( true, false ); when( view.isPlanningCapabilityChecked() ).thenReturn( false ); assertTrue( presenter.isValid() ); verify( view ).noErrorOnTemplateName(); verify( view ).noErrorOnCapability(); assertFalse( presenter.isValid() ); verify( view ).errorOnTemplateName(); verify( view, times( 2 ) ).noErrorOnCapability(); assertFalse( presenter.isValid() ); verify( view, times( 2 ) ).noErrorOnTemplateName(); verify( view ).errorCapability(); }
|
NewTemplatePresenter implements WizardPage { @Override public void isComplete(final Callback<Boolean> callback) { if (isValid()) { specManagementService.call(new RemoteCallback<Boolean>() { @Override public void callback(final Boolean result) { if (result.equals(Boolean.FALSE)) { view.errorOnTemplateName(view.getInvalidErrorMessage()); callback.callback(false); } else { callback.callback(true); } } }).isNewServerTemplateIdValid(view.getTemplateName()); } else { callback.callback(false); } } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testIsComplete() { final Callback callback = mock( Callback.class ); final String templateName = "templateName"; when( view.getTemplateName() ).thenReturn( templateName ).thenReturn( templateName, templateName, templateName, "" ); when( view.isRuleCapabilityChecked() ).thenReturn( true ); when( view.isProcessCapabilityChecked() ).thenReturn( true ); when( specManagementService.isNewServerTemplateIdValid( templateName ) ).thenReturn( true, false ); presenter.isComplete( callback ); verify( specManagementService ).isNewServerTemplateIdValid( templateName ); verify( callback ).callback( true ); presenter.isComplete( callback ); verify( specManagementService, times( 2 ) ).isNewServerTemplateIdValid( templateName ); verify( callback ).callback( false ); presenter.isComplete( callback ); verify( callback, times( 2 ) ).callback( false ); verify( view ).errorOnTemplateName(); }
|
NewTemplatePresenter implements WizardPage { public void clear() { view.clear(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testClear() { presenter.clear(); verify( view ).clear(); }
|
NewTemplatePresenter implements WizardPage { @Override public String getTitle() { return view.getTitle(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testTitle() { final String title = "title"; when( view.getTitle() ).thenReturn( title ); assertEquals( title, presenter.getTitle() ); verify( view ).getTitle(); }
|
NewTemplatePresenter implements WizardPage { public void addContentChangeHandler(final ContentChangeHandler contentChangeHandler) { checkNotNull("contentChangeHandler", contentChangeHandler); view.addContentChangeHandler(new ContentChangeHandler() { @Override public void onContentChange() { contentChangeHandler.onContentChange(); wizardPageStatusChangeEvent.fire(new WizardPageStatusChangeEvent(NewTemplatePresenter.this)); } }); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testAddContentChangeHandler() { doAnswer( new Answer() { @Override public Object answer( InvocationOnMock invocation ) throws Throwable { final ContentChangeHandler handler = (ContentChangeHandler) invocation.getArguments()[ 0 ]; if ( handler != null ) { handler.onContentChange(); } return null; } } ).when( view ).addContentChangeHandler( any( ContentChangeHandler.class ) ); presenter.addContentChangeHandler( mock( ContentChangeHandler.class ) ); final ArgumentCaptor<WizardPageStatusChangeEvent> eventCaptor = ArgumentCaptor.forClass( WizardPageStatusChangeEvent.class ); verify( wizardPageStatusChangeEvent ).fire( eventCaptor.capture() ); assertEquals( presenter, eventCaptor.getValue().getPage() ); }
|
NewTemplatePresenter implements WizardPage { public boolean isRuleCapabilityChecked() { return view.isRuleCapabilityChecked(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testIsRuleCapabilityChecked() { when( view.isRuleCapabilityChecked() ).thenReturn( true ).thenReturn( false ); assertTrue( presenter.isRuleCapabilityChecked() ); assertFalse( presenter.isRuleCapabilityChecked() ); }
|
NewTemplatePresenter implements WizardPage { public boolean isProcessCapabilityChecked() { return view.isProcessCapabilityChecked(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testIsProcessCapabilityChecked() { when( view.isProcessCapabilityChecked() ).thenReturn( true ).thenReturn( false ); assertTrue( presenter.isProcessCapabilityChecked() ); assertFalse( presenter.isProcessCapabilityChecked() ); }
|
NewTemplatePresenter implements WizardPage { public boolean isPlanningCapabilityChecked() { return view.isPlanningCapabilityChecked(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testIsPlanningCapabilityChecked() { when( view.isPlanningCapabilityChecked() ).thenReturn( true ).thenReturn( false ); assertTrue( presenter.isPlanningCapabilityChecked() ); assertFalse( presenter.isPlanningCapabilityChecked() ); }
|
NewTemplatePresenter implements WizardPage { public boolean hasProcessCapability() { return view.getProcessCapabilityCheck(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testHasProcessCapability() { when( view.getProcessCapabilityCheck() ).thenReturn( true, false ); assertTrue( presenter.hasProcessCapability() ); assertFalse( presenter.hasProcessCapability() ); verify( view, times( 2 ) ).getProcessCapabilityCheck(); }
|
NewTemplatePresenter implements WizardPage { public String getTemplateName() { return view.getTemplateName(); } @Inject NewTemplatePresenter(final View view,
final Caller<SpecManagementService> specManagementService,
final Event<WizardPageStatusChangeEvent> wizardPageStatusChangeEvent); boolean hasProcessCapability(); String getTemplateName(); @PostConstruct void init(); @Override String getTitle(); @Override void isComplete(final Callback<Boolean> callback); void addContentChangeHandler(final ContentChangeHandler contentChangeHandler); @Override void initialise(); @Override void prepareView(); @Override Widget asWidget(); boolean isValid(); boolean isTemplateNameValid(); boolean isCapabilityValid(); void clear(); boolean isRuleCapabilityChecked(); boolean isProcessCapabilityChecked(); boolean isPlanningCapabilityChecked(); View getView(); }
|
@Test public void testTemplateName() { final String templateName = "templateName"; when( view.getTemplateName() ).thenReturn( templateName ); assertEquals( templateName, presenter.getTemplateName() ); verify( view ).getTemplateName(); }
|
ServerManagementBrowserPresenter { @PostConstruct public void init() { this.view.setNavigation( navigationPresenter.getView() ); } @Inject ServerManagementBrowserPresenter( final Logger logger,
final View view,
final ServerNavigationPresenter navigationPresenter,
final ServerTemplatePresenter serverTemplatePresenter,
final ServerEmptyPresenter serverEmptyPresenter,
final ServerContainerEmptyPresenter serverContainerEmptyPresenter,
final ContainerPresenter containerPresenter,
final RemotePresenter remotePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification ); @PostConstruct void init(); @OnOpen void onOpen(); void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ); void onSelected( @Observes final ServerTemplateSelected serverTemplateSelected ); void onSelected( @Observes final ContainerSpecSelected containerSpecSelected ); void onSelected( @Observes final ServerInstanceSelected serverInstanceSelected ); void onContainerUpdate( @Observes final ContainerUpdateEvent containerUpdateEvent ); void setup( final Collection<ServerTemplateKey> serverTemplateKeys,
final String selectServerTemplateId ); void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ); void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); }
|
@Test public void testInit() { presenter.init(); verify( view ).setNavigation( navigationPresenter.getView() ); assertEquals( view, presenter.getView() ); }
|
ServerManagementBrowserPresenter { @OnOpen public void onOpen() { refreshList( new ServerTemplateListRefresh() ); } @Inject ServerManagementBrowserPresenter( final Logger logger,
final View view,
final ServerNavigationPresenter navigationPresenter,
final ServerTemplatePresenter serverTemplatePresenter,
final ServerEmptyPresenter serverEmptyPresenter,
final ServerContainerEmptyPresenter serverContainerEmptyPresenter,
final ContainerPresenter containerPresenter,
final RemotePresenter remotePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification ); @PostConstruct void init(); @OnOpen void onOpen(); void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ); void onSelected( @Observes final ServerTemplateSelected serverTemplateSelected ); void onSelected( @Observes final ContainerSpecSelected containerSpecSelected ); void onSelected( @Observes final ServerInstanceSelected serverInstanceSelected ); void onContainerUpdate( @Observes final ContainerUpdateEvent containerUpdateEvent ); void setup( final Collection<ServerTemplateKey> serverTemplateKeys,
final String selectServerTemplateId ); void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ); void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); }
|
@Test public void testOnOpen() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList( serverTemplateKey ); when( specManagementService.listServerTemplateKeys() ).thenReturn( new ServerTemplateKeyList(serverTemplateKeys) ); presenter.onOpen(); verify( navigationPresenter ).setup( serverTemplateKey, serverTemplateKeys ); final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( templateSelectedCaptor.capture() ); assertEquals( serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey() ); }
|
ServerManagementBrowserPresenter { public void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ) { if ( serverTemplateDeleted != null ) { refreshList( new ServerTemplateListRefresh() ); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerManagementBrowserPresenter( final Logger logger,
final View view,
final ServerNavigationPresenter navigationPresenter,
final ServerTemplatePresenter serverTemplatePresenter,
final ServerEmptyPresenter serverEmptyPresenter,
final ServerContainerEmptyPresenter serverContainerEmptyPresenter,
final ContainerPresenter containerPresenter,
final RemotePresenter remotePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification ); @PostConstruct void init(); @OnOpen void onOpen(); void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ); void onSelected( @Observes final ServerTemplateSelected serverTemplateSelected ); void onSelected( @Observes final ContainerSpecSelected containerSpecSelected ); void onSelected( @Observes final ServerInstanceSelected serverInstanceSelected ); void onContainerUpdate( @Observes final ContainerUpdateEvent containerUpdateEvent ); void setup( final Collection<ServerTemplateKey> serverTemplateKeys,
final String selectServerTemplateId ); void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ); void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); }
|
@Test public void testOnServerDeleted() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList( serverTemplateKey ); when( specManagementService.listServerTemplateKeys() ).thenReturn( new ServerTemplateKeyList(serverTemplateKeys) ); presenter.onServerDeleted( new ServerTemplateDeleted() ); verify( navigationPresenter ).setup( serverTemplateKey, serverTemplateKeys ); final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( templateSelectedCaptor.capture() ); assertEquals( serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey() ); }
|
ServerManagementBrowserPresenter { public void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ) { if ( serverTemplateUpdated != null && serverTemplateUpdated.getServerTemplate() != null ) { final ServerTemplate serverTemplate = serverTemplateUpdated.getServerTemplate(); refreshList(new ServerTemplateListRefresh(serverTemplate.getId())); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerManagementBrowserPresenter( final Logger logger,
final View view,
final ServerNavigationPresenter navigationPresenter,
final ServerTemplatePresenter serverTemplatePresenter,
final ServerEmptyPresenter serverEmptyPresenter,
final ServerContainerEmptyPresenter serverContainerEmptyPresenter,
final ContainerPresenter containerPresenter,
final RemotePresenter remotePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification ); @PostConstruct void init(); @OnOpen void onOpen(); void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ); void onSelected( @Observes final ServerTemplateSelected serverTemplateSelected ); void onSelected( @Observes final ContainerSpecSelected containerSpecSelected ); void onSelected( @Observes final ServerInstanceSelected serverInstanceSelected ); void onContainerUpdate( @Observes final ContainerUpdateEvent containerUpdateEvent ); void setup( final Collection<ServerTemplateKey> serverTemplateKeys,
final String selectServerTemplateId ); void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ); void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); }
|
@Test public void testOnServerTemplateUpdated() { final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "serverInstanceKeyId", "serverName", "serverInstanceId", "url" ); final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateId", "ServerTemplateName" ); serverTemplate.addServerInstance( serverInstanceKey ); when( serverTemplatePresenter.getCurrentServerTemplate() ).thenReturn( serverTemplate ); final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList( serverTemplateKey ); when( specManagementService.listServerTemplateKeys() ).thenReturn( new ServerTemplateKeyList(serverTemplateKeys) ); presenter.onServerTemplateUpdated( new ServerTemplateUpdated( serverTemplate ) ); final ArgumentCaptor<Collection> serverTemplateKeysCaptor = ArgumentCaptor.forClass( Collection.class ); verify( navigationPresenter ).setup( eq( serverTemplateKey ), serverTemplateKeysCaptor.capture() ); final Collection<ServerTemplateKey> serverTemplateKeysValue = serverTemplateKeysCaptor.getValue(); assertEquals( 1, serverTemplateKeysValue.size() ); assertTrue( serverTemplateKeysValue.contains( serverTemplateKey ) ); final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( templateSelectedCaptor.capture() ); assertEquals( serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey() ); }
|
ServerManagementBrowserPresenter { public void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ) { if ( serverInstanceDeleted != null && serverInstanceDeleted.getServerInstanceId() != null && serverTemplatePresenter.getCurrentServerTemplate() != null ) { final String deletedServerInstanceId = serverInstanceDeleted.getServerInstanceId(); for ( final ServerInstanceKey serverInstanceKey : serverTemplatePresenter.getCurrentServerTemplate().getServerInstanceKeys() ) { if ( deletedServerInstanceId.equals( serverInstanceKey.getServerInstanceId() ) ) { refreshList( new ServerTemplateListRefresh( serverTemplatePresenter.getCurrentServerTemplate().getId() ) ); break; } } } else { logger.warn( "Illegal event argument." ); } } @Inject ServerManagementBrowserPresenter( final Logger logger,
final View view,
final ServerNavigationPresenter navigationPresenter,
final ServerTemplatePresenter serverTemplatePresenter,
final ServerEmptyPresenter serverEmptyPresenter,
final ServerContainerEmptyPresenter serverContainerEmptyPresenter,
final ContainerPresenter containerPresenter,
final RemotePresenter remotePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification ); @PostConstruct void init(); @OnOpen void onOpen(); void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ); void onSelected( @Observes final ServerTemplateSelected serverTemplateSelected ); void onSelected( @Observes final ContainerSpecSelected containerSpecSelected ); void onSelected( @Observes final ServerInstanceSelected serverInstanceSelected ); void onContainerUpdate( @Observes final ContainerUpdateEvent containerUpdateEvent ); void setup( final Collection<ServerTemplateKey> serverTemplateKeys,
final String selectServerTemplateId ); void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ); void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); }
|
@Test public void testOnDelete() { final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "serverInstanceKeyId", "serverName", "serverInstanceId", "url" ); final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateId", "ServerTemplateName" ); serverTemplate.addServerInstance( serverInstanceKey ); when( serverTemplatePresenter.getCurrentServerTemplate() ).thenReturn( serverTemplate ); final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList( serverTemplateKey ); when( specManagementService.listServerTemplateKeys() ).thenReturn( new ServerTemplateKeyList(serverTemplateKeys) ); presenter.onDelete( new ServerInstanceDeleted( serverInstanceKey.getServerInstanceId() ) ); verify( navigationPresenter ).setup( serverTemplateKey, serverTemplateKeys ); final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( templateSelectedCaptor.capture() ); assertEquals( serverTemplateKey, templateSelectedCaptor.getValue().getServerTemplateKey() ); }
@Test public void testOnDeleteWithoutCurrentServer() { final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "serverInstanceKeyId", "serverName", "serverInstanceId", "url" ); presenter.onDelete( new ServerInstanceDeleted( serverInstanceKey.getServerInstanceId() ) ); verify( specManagementService, never() ).listServerTemplateKeys(); }
|
ServerManagementBrowserPresenter { public void onContainerUpdate( @Observes final ContainerUpdateEvent containerUpdateEvent ) { if ( containerUpdateEvent != null && containerUpdateEvent.getContainerRuntimeOperation() != null && containerUpdateEvent.getContainerRuntimeState() != null && containerUpdateEvent.getFailedServerInstances().size() > 0 ) { final ClientContainerRuntimeOperation containerRuntimeOperation = ClientContainerRuntimeOperation.convert( containerUpdateEvent.getContainerRuntimeOperation() ); final String message; final NotificationEvent.NotificationType notificationType; switch ( containerUpdateEvent.getContainerRuntimeState() ) { case OFFLINE: message = view.getErrorMessage( containerRuntimeOperation, containerUpdateEvent.getFailedServerInstances().size() ); notificationType = NotificationEvent.NotificationType.ERROR; break; case PARTIAL_ONLINE: message = view.getWarnMessage( containerRuntimeOperation, containerUpdateEvent.getFailedServerInstances().size() ); notificationType = NotificationEvent.NotificationType.WARNING; break; case ONLINE: message = view.getSuccessMessage( containerRuntimeOperation, containerUpdateEvent.getFailedServerInstances().size() ); notificationType = NotificationEvent.NotificationType.SUCCESS; break; default: message = null; notificationType = null; break; } if ( message != null ) { notification.fire( new NotificationEvent( message, notificationType ) ); } } else { logger.warn( "Illegal event argument." ); } } @Inject ServerManagementBrowserPresenter( final Logger logger,
final View view,
final ServerNavigationPresenter navigationPresenter,
final ServerTemplatePresenter serverTemplatePresenter,
final ServerEmptyPresenter serverEmptyPresenter,
final ServerContainerEmptyPresenter serverContainerEmptyPresenter,
final ContainerPresenter containerPresenter,
final RemotePresenter remotePresenter,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification ); @PostConstruct void init(); @OnOpen void onOpen(); void onServerDeleted( @Observes final ServerTemplateDeleted serverTemplateDeleted ); void onSelected( @Observes final ServerTemplateSelected serverTemplateSelected ); void onSelected( @Observes final ContainerSpecSelected containerSpecSelected ); void onSelected( @Observes final ServerInstanceSelected serverInstanceSelected ); void onContainerUpdate( @Observes final ContainerUpdateEvent containerUpdateEvent ); void setup( final Collection<ServerTemplateKey> serverTemplateKeys,
final String selectServerTemplateId ); void onServerTemplateUpdated( @Observes final ServerTemplateUpdated serverTemplateUpdated ); void onDelete( @Observes final ServerInstanceDeleted serverInstanceDeleted ); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); }
|
@Test public void testOnContainerUpdateSuccess() { when( view.getSuccessMessage( ClientContainerRuntimeOperation.START_CONTAINER, 2 ) ).thenReturn( "Success" ); presenter.onContainerUpdate( new ContainerUpdateEvent( mock( ServerTemplateKey.class ), mock( ContainerSpec.class ), new ArrayList<ServerInstanceKey>() {{ add( mock( ServerInstanceKey.class ) ); add( mock( ServerInstanceKey.class ) ); }}, ContainerRuntimeState.ONLINE, ContainerRuntimeOperation.START_CONTAINER ) ); verify( notification ).fire( new NotificationEvent( "Success", NotificationEvent.NotificationType.SUCCESS ) ); }
@Test public void testOnContainerUpdateFailed() { when( view.getErrorMessage( ClientContainerRuntimeOperation.START_CONTAINER, 2 ) ).thenReturn( "Error" ); presenter.onContainerUpdate( new ContainerUpdateEvent( mock( ServerTemplateKey.class ), mock( ContainerSpec.class ), new ArrayList<ServerInstanceKey>() {{ add( mock( ServerInstanceKey.class ) ); add( mock( ServerInstanceKey.class ) ); }}, ContainerRuntimeState.OFFLINE, ContainerRuntimeOperation.START_CONTAINER ) ); verify( notification ).fire( new NotificationEvent( "Error", NotificationEvent.NotificationType.ERROR ) ); }
@Test public void testOnContainerUpdateWarn() { when( view.getWarnMessage( ClientContainerRuntimeOperation.START_CONTAINER, 2 ) ).thenReturn( "Warn" ); presenter.onContainerUpdate( new ContainerUpdateEvent( mock( ServerTemplateKey.class ), mock( ContainerSpec.class ), new ArrayList<ServerInstanceKey>() {{ add( mock( ServerInstanceKey.class ) ); add( mock( ServerInstanceKey.class ) ); }}, ContainerRuntimeState.PARTIAL_ONLINE, ContainerRuntimeOperation.START_CONTAINER ) ); verify( notification ).fire( new NotificationEvent( "Warn", NotificationEvent.NotificationType.WARNING ) ); }
@Test public void testOnContainerEmptyList() { presenter.onContainerUpdate( new ContainerUpdateEvent( mock( ServerTemplateKey.class ), mock( ContainerSpec.class ), Collections.emptyList(), ContainerRuntimeState.PARTIAL_ONLINE, ContainerRuntimeOperation.START_CONTAINER ) ); verify( notification, never() ).fire( any() ); }
@Test public void testOnContainerNull() { presenter.onContainerUpdate( new ContainerUpdateEvent() ); verify( notification, never() ).fire( any() ); }
|
ContainerCardPresenter { public View getView() { return view; } @Inject ContainerCardPresenter( final View view,
final ManagedInstance<Object> presenterProvider,
final Event<ServerInstanceSelected> remoteServerSelectedEvent ); View getView(); void setup( final ServerInstanceKey serverInstanceKey,
final Container container ); void delete(); void updateContent( final ServerInstanceKey serverInstanceKey,
final Container container ); }
|
@Test public void testInit() { assertEquals( view, presenter.getView() ); }
|
ContainerCardPresenter { public void delete() { view.delete(); } @Inject ContainerCardPresenter( final View view,
final ManagedInstance<Object> presenterProvider,
final Event<ServerInstanceSelected> remoteServerSelectedEvent ); View getView(); void setup( final ServerInstanceKey serverInstanceKey,
final Container container ); void delete(); void updateContent( final ServerInstanceKey serverInstanceKey,
final Container container ); }
|
@Test public void testDelete() { presenter.delete(); verify( view ).delete(); }
|
ContainerCardPresenter { public void setup( final ServerInstanceKey serverInstanceKey, final Container container ) { linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); updateContent( serverInstanceKey, container ); final CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } @Inject ContainerCardPresenter( final View view,
final ManagedInstance<Object> presenterProvider,
final Event<ServerInstanceSelected> remoteServerSelectedEvent ); View getView(); void setup( final ServerInstanceKey serverInstanceKey,
final Container container ); void delete(); void updateContent( final ServerInstanceKey serverInstanceKey,
final Container container ); }
|
@Test public void testSetup() { final LinkTitlePresenter linkTitlePresenter = spy( new LinkTitlePresenter( mock( LinkTitlePresenter.View.class ) ) ); when( linkTitlePresenterProvider.get() ).thenReturn( linkTitlePresenter ); final BodyPresenter bodyPresenter = mock( BodyPresenter.class ); when( bodyPresenterProvider.get() ).thenReturn( bodyPresenter ); final FooterPresenter footerPresenter = mock( FooterPresenter.class ); when( footerPresenterProvider.get() ).thenReturn( footerPresenter ); final CardPresenter.View cardPresenterView = mock( CardPresenter.View.class ); final CardPresenter cardPresenter = spy( new CardPresenter( cardPresenterView ) ); when( cardPresenterProvider.get() ).thenReturn( cardPresenter ); final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "templateId", "serverName", "serverInstanceId", "url" ); final Message message = new Message( Severity.INFO, "testMessage" ); final ReleaseId resolvedReleasedId = new ReleaseId( "org.kie", "container", "1.0.0" ); final Container container = new Container( "containerSpecId", "containerName", serverInstanceKey, Collections.singletonList( message ), resolvedReleasedId, null ); presenter.setup( serverInstanceKey, container ); verify( linkTitlePresenter ).setup( eq( serverInstanceKey.getServerName() ), any( Command.class ) ); verify( bodyPresenter ).setup( Arrays.asList( message ) ); verify( footerPresenter ).setup( container.getUrl(), resolvedReleasedId.getVersion() ); verify( cardPresenter ).addTitle( linkTitlePresenter ); verify( cardPresenter ).addBody( bodyPresenter ); verify( cardPresenter ).addFooter( footerPresenter ); verify( view ).setCard( cardPresenterView ); linkTitlePresenter.onSelect(); verify( remoteServerSelectedEvent ).fire( eq( new ServerInstanceSelected( serverInstanceKey ) ) ); }
|
ContainerStatusEmptyPresenter { @PostConstruct public void init() { view.init(this); } @Inject ContainerStatusEmptyPresenter(final View view,
final Event<RefreshRemoteServers> refreshRemoteServersEvent); @PostConstruct void init(); View getView(); void setup(final ContainerSpecKey containerSpecKey); void refresh(); }
|
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); }
|
ContainerStatusEmptyPresenter { public void refresh() { refreshRemoteServersEvent.fire(new RefreshRemoteServers(containerSpecKey)); } @Inject ContainerStatusEmptyPresenter(final View view,
final Event<RefreshRemoteServers> refreshRemoteServersEvent); @PostConstruct void init(); View getView(); void setup(final ContainerSpecKey containerSpecKey); void refresh(); }
|
@Test public void testRefresh() { final ContainerSpecKey containerSpecKey = new ContainerSpecKey( "id", "name", new ServerTemplateKey() ); presenter.setup( containerSpecKey ); presenter.refresh(); final ArgumentCaptor<RefreshRemoteServers> refreshRemoteServersCaptor = ArgumentCaptor.forClass( RefreshRemoteServers.class ); verify( refreshRemoteServersEvent ).fire( refreshRemoteServersCaptor.capture() ); assertEquals( containerSpecKey, refreshRemoteServersCaptor.getValue().getContainerSpecKey() ); }
|
ServerContainerEmptyPresenter { @PostConstruct public void init() { view.init(this); } @Inject ServerContainerEmptyPresenter(final View view,
final Event<AddNewContainer> addNewContainerEvent); @PostConstruct void init(); View getView(); void setTemplate(final ServerTemplate serverTemplate); void addContainer(); }
|
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); }
|
ServerContainerEmptyPresenter { public void setTemplate(final ServerTemplate serverTemplate) { this.serverTemplate = checkNotNull("serverTemplate", serverTemplate); view.setTemplateName(serverTemplate.getName()); } @Inject ServerContainerEmptyPresenter(final View view,
final Event<AddNewContainer> addNewContainerEvent); @PostConstruct void init(); View getView(); void setTemplate(final ServerTemplate serverTemplate); void addContainer(); }
|
@Test public void testTemplate() { final ServerTemplate template = new ServerTemplate( "id", "name" ); presenter.setTemplate( template ); verify( view ).setTemplateName( template.getName() ); }
|
ServerContainerEmptyPresenter { public void addContainer() { addNewContainerEvent.fire(new AddNewContainer(serverTemplate)); } @Inject ServerContainerEmptyPresenter(final View view,
final Event<AddNewContainer> addNewContainerEvent); @PostConstruct void init(); View getView(); void setTemplate(final ServerTemplate serverTemplate); void addContainer(); }
|
@Test public void testAddContainer() { presenter.addContainer(); verify( addNewContainerEvent ).fire( any( AddNewContainer.class ) ); }
|
ContainerRulesConfigPresenter { @PostConstruct public void init() { view.init(this); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); }
|
@Test public void testInit() { presenter.init(); verify(view).init(presenter); assertEquals(view, presenter.getView()); }
|
ContainerRulesConfigPresenter { public void setup(final ContainerSpec containerSpec, final RuleConfig ruleConfig) { this.containerSpec = checkNotNull("containerSpec", containerSpec); setRuleConfig(ruleConfig, containerSpec.getReleasedId().getVersion()); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); }
|
@Test public void testSetup() { when(ruleConfig.getScannerStatus()).thenReturn(KieScannerStatus.STOPPED); when(ruleConfig.getPollInterval()).thenReturn(null); releaseId.setVersion("1.x"); presenter.setup(containerSpec, ruleConfig); verify(view).setContent(eq(""), eq("1.x"), eq(State.ENABLED), eq(State.DISABLED), eq(State.ENABLED), eq(State.ENABLED)); }
|
ContainerRulesConfigPresenter { public void setVersion(final String version) { this.view.setVersion(version); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); }
|
@Test public void testVersion() { final String version = "1.0"; presenter.setVersion(version); verify(view).setVersion(version); }
|
ContainerRulesConfigPresenter { public void upgrade(final String version) { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { if (version != null && !version.isEmpty() && version.compareTo(containerSpec.getReleasedId().getVersion()) == 0) { notification.fire(new NotificationEvent(view.getUpgradeSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); } updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getUpgradeErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).upgradeContainer(containerSpec, new ReleaseId(containerSpec.getReleasedId().getGroupId(), containerSpec.getReleasedId().getArtifactId(), version)); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); }
|
@Test public void testUpgrade() { final String version = "1.0"; presenter.setup(containerSpec, ruleConfig); presenter.upgrade(version); verify(view).disableActions(); final ArgumentCaptor<ReleaseId> releaseIdCaptor = ArgumentCaptor.forClass(ReleaseId.class); verify(ruleCapabilitiesService).upgradeContainer(eq(containerSpec), releaseIdCaptor.capture()); assertEquals(version, releaseIdCaptor.getValue().getVersion()); verify(view).setStartScannerState(State.ENABLED); verify(view).setStopScannerState(State.DISABLED); verify(view).setScanNowState(State.ENABLED); verify(view).setUpgradeState(State.ENABLED); verify(notification).fire(new NotificationEvent(SUCCESS_UPGRADE, NotificationEvent.NotificationType.SUCCESS)); }
|
ContainerRulesConfigPresenter { public void stopScanner() { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STOPPED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStopScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).stopScanner(containerSpec); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); }
|
@Test public void testStopScanner() { presenter.stopScanner(); verify(view).disableActions(); verify(view).setStartScannerState(State.ENABLED); verify(view).setStopScannerState(State.DISABLED); verify(view).setScanNowState(State.ENABLED); verify(view).setUpgradeState(State.ENABLED); }
|
ContainerRulesConfigPresenter { public void scanNow() { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STOPPED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getScanNowErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).scanNow(containerSpec); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); }
|
@Test public void testScanNow() { presenter.scanNow(); verify(view).disableActions(); verify(view).setStartScannerState(State.ENABLED); verify(view).setStopScannerState(State.DISABLED); verify(view).setScanNowState(State.ENABLED); verify(view).setUpgradeState(State.ENABLED); }
|
ContainerRulesConfigPresenter { public void startScanner(final String interval, final String timeUnit) { if (interval.trim().isEmpty()) { view.errorOnInterval(); return; } Long actualInterval = calculateInterval(Long.valueOf(checkNotEmpty("interval", interval)), timeUnit); view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { scannerStatus = KieScannerStatus.STARTED; setScannerStatus(); updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartScannerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).startScanner(containerSpec, actualInterval); } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); }
|
@Test public void testStartScannerEmpty() { presenter.startScanner("", ContainerRulesConfigPresenter.MS); verify(view).errorOnInterval(); }
@Test public void testStartScanner() { presenter.setup(containerSpec, ruleConfig); final String interval = "1"; presenter.startScanner(interval, ContainerRulesConfigPresenter.MS); verify(view).disableActions(); verify(ruleCapabilitiesService).startScanner(eq(containerSpec), eq(Long.valueOf(interval))); verify(view).setStartScannerState(State.DISABLED); verify(view).setStopScannerState(State.ENABLED); verify(view).setScanNowState(State.DISABLED); verify(view).setUpgradeState(State.DISABLED); }
|
ContainerRulesConfigPresenter { public void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated) { if (configUpdated != null && configUpdated.getContainerSpecKey() != null && configUpdated.getContainerSpecKey().equals(containerSpec)) { setup(containerSpec, configUpdated.getRuleConfig()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); }
|
@Test public void testOnConfigUpdate() { final RuleConfigUpdated ruleConfigUpdated = new RuleConfigUpdated(); ruleConfigUpdated.setContainerSpecKey(containerSpec); ruleConfigUpdated.setRuleConfig(ruleConfig); presenter.setup(containerSpec, ruleConfig); presenter.onConfigUpdate(ruleConfigUpdated); verify(view, times(2)).setContent(anyString(), anyString(), any(State.class), any(State.class), any(State.class), any(State.class)); }
|
ContainerRulesConfigPresenter { public void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate) { if (configUpdate != null && configUpdate.getRuleConfig() != null && configUpdate.getReleasedId() != null) { setRuleConfig(configUpdate.getRuleConfig(), configUpdate.getReleasedId().getVersion()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerRulesConfigPresenter(final Logger logger,
final View view,
final Caller<RuleCapabilitiesService> ruleCapabilitiesService,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void setup(final ContainerSpec containerSpec,
final RuleConfig ruleConfig); void setVersion(final String version); void startScanner(final String interval,
final String timeUnit); void stopScanner(); void scanNow(); void upgrade(final String version); void onConfigUpdate(@Observes final RuleConfigUpdated configUpdated); void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate); }
|
@Test public void testOnRuleConfigUpdate() { final RuleConfigUpdated ruleConfigUpdated = new RuleConfigUpdated(); ruleConfigUpdated.setRuleConfig(ruleConfig); ruleConfigUpdated.setReleasedId(releaseId); final Long poolInterval = 1l; when(ruleConfig.getPollInterval()).thenReturn(poolInterval); presenter.onRuleConfigUpdate(ruleConfigUpdated); verify(view).setContent(eq(String.valueOf(poolInterval)), anyString(), any(State.class), any(State.class), any(State.class), any(State.class)); }
|
ContainerProcessConfigPresenter { @PostConstruct public void init() { view.init( this ); view.setProcessConfigView( processConfigPresenter.getView() ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); }
|
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); verify( view ).setProcessConfigView( processConfigPresenterView ); assertEquals( view, presenter.getView() ); }
|
ContainerProcessConfigPresenter { public void disable() { view.disable(); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); }
|
@Test public void testDisable() { presenter.disable(); verify( view ).disable(); }
|
ContainerProcessConfigPresenter { public void cancel() { setupView( processConfigPresenter.getProcessConfig() ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); }
|
@Test public void testCancel() { presenter.cancel(); verify( view ).enableActions(); verify( processConfigPresenter ).setProcessConfig( processConfig ); }
|
ContainerProcessConfigPresenter { public void save() { view.disableActions(); final ProcessConfig newProcessConfig = processConfigPresenter.buildProcessConfig(); specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void containerConfig ) { notification.fire( new NotificationEvent( view.getSaveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); setupView( newProcessConfig ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getSaveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); setupView( processConfigPresenter.getProcessConfig() ); return false; } } ) .updateContainerConfig( processConfigPresenter.getContainerSpecKey().getServerTemplateKey().getId(), processConfigPresenter.getContainerSpecKey().getId(), Capability.PROCESS, newProcessConfig ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); }
|
@Test public void testSave() { final String templateKey = "templateKey"; final String containerKey = "containerKey"; when( serverTemplateKey.getId() ).thenReturn( templateKey ); when( containerSpecKey.getId() ).thenReturn( containerKey ); when( view.getSaveSuccessMessage() ).thenReturn( "SUCCESS" ); presenter.save(); verify( notification ).fire( new NotificationEvent( "SUCCESS", NotificationEvent.NotificationType.SUCCESS ) ); verify( view ).disableActions(); verify( processConfigPresenter ).buildProcessConfig(); final ArgumentCaptor<ProcessConfig> processConfigCaptor = ArgumentCaptor.forClass( ProcessConfig.class ); verify( specManagementService ).updateContainerConfig( eq( templateKey ), eq( containerKey ), eq( Capability.PROCESS ), processConfigCaptor.capture() ); verify( view ).enableActions(); verify( processConfigPresenter ).setProcessConfig( processConfigCaptor.getValue() ); }
@Test public void testSaveError() { final String templateKey = "templateKey"; final String containerKey = "containerKey"; when( serverTemplateKey.getId() ).thenReturn( templateKey ); when( containerSpecKey.getId() ).thenReturn( containerKey ); when( view.getSaveErrorMessage() ).thenReturn( "ERROR" ); doThrow( new RuntimeException() ).when( specManagementService ).updateContainerConfig( anyString(), anyString(), any( Capability.class ), any( ContainerConfig.class ) ); presenter.save(); verify( notification ).fire( new NotificationEvent( "ERROR", NotificationEvent.NotificationType.ERROR ) ); verify( view ).disableActions(); verify( view ).enableActions(); verify( processConfigPresenter ).setProcessConfig( processConfig ); }
|
ContainerProcessConfigPresenter { public void setup( final ContainerSpecKey containerSpecKey, final ProcessConfig processConfig ) { this.processConfigPresenter.setup( containerSpecKey, processConfig ); setupView( processConfig ); } @Inject ContainerProcessConfigPresenter( final View view,
final ProcessConfigPresenter processConfigPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void setup( final ContainerSpecKey containerSpecKey,
final ProcessConfig processConfig ); void disable(); void save(); void cancel(); }
|
@Test public void testSetup() { final ContainerSpecKey containerSpecKey = new ContainerSpecKey( "id", "container-name", new ServerTemplateKey( "template-id", "template-name" ) ); final ProcessConfig processConfig = new ProcessConfig( RuntimeStrategy.PER_REQUEST.toString(), "kbase", "ksession", MergeMode.KEEP_ALL.toString() ); presenter.setup( containerSpecKey, processConfig ); verify( view ).enableActions(); verify( processConfigPresenter ).setup( containerSpecKey, processConfig ); verify( processConfigPresenter ).setProcessConfig( processConfig ); }
|
ContainerPresenter { public void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated) { if (instanceUpdated != null && containerSpec != null && containerSpec.getServerTemplateKey().getId().equals(instanceUpdated.getServerInstance().getServerTemplateId())) { load(containerSpec); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); }
|
@Test public void testOnInstanceUpdatedWhenContainerSpecServerTemplateNotEqualServerInstanceUpdatedServerTemplate() { ServerInstanceUpdated serverInstanceUpdated = mock(ServerInstanceUpdated.class); ServerInstance serverInstance = mock(ServerInstance.class); when(serverInstanceUpdated.getServerInstance()).thenReturn(serverInstance); when(serverInstance.getServerTemplateId()).thenReturn(serverTemplateKey + "1"); presenter.onInstanceUpdated(serverInstanceUpdated); verify(runtimeManagementService, times(0)).getContainersByContainerSpec(any(), any()); }
|
ContainerPresenter { @PostConstruct public void init() { view.init(this); view.setStatus(containerRemoteStatusPresenter.getView()); view.setRulesConfig(containerRulesConfigPresenter.getView()); view.setProcessConfig(containerProcessConfigPresenter.getView()); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); }
|
@Test public void testInit() { presenter.init(); verify(view).init(presenter); assertEquals(view, presenter.getView()); verify(view).setStatus(containerRemoteStatusPresenter.getView()); verify(view).setRulesConfig(containerRulesConfigPresenter.getView()); verify(view).setProcessConfig(containerProcessConfigPresenter.getView()); }
|
ContainerPresenter { public void startContainer() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { updateStatus(KieContainerStatus.STARTED); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStartContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateStatus(KieContainerStatus.STOPPED); return false; } }).startContainer(containerSpec); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); }
|
@Test public void testStartContainer() { presenter.loadContainers(containerSpecData); presenter.startContainer(); verify(view).setContainerStartState(State.ENABLED); verify(view).setContainerStopState(State.DISABLED); verify(view).disableRemoveButton(); verify(view).enableToggleActivationButton(); final String errorMessage = "ERROR"; when(view.getStartContainerErrorMessage()).thenReturn(errorMessage); doThrow(new RuntimeException()).when(specManagementService).startContainer(containerSpecData.getContainerSpec()); presenter.startContainer(); verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR)); verify(view, times(2)).setContainerStartState(State.DISABLED); verify(view, times(2)).setContainerStopState(State.ENABLED); verify(view, times(2)).enableRemoveButton(); }
|
ContainerPresenter { public void stopContainer() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { updateStatus(KieContainerStatus.STOPPED); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getStopContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateStatus(KieContainerStatus.STARTED); return false; } }).stopContainer(containerSpec); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); }
|
@Test public void testStopContainer() { presenter.loadContainers(containerSpecData); presenter.stopContainer(); verify(view, times(2)).setContainerStartState(State.DISABLED); verify(view, times(2)).setContainerStopState(State.ENABLED); verify(view, times(2)).enableRemoveButton(); final String errorMessage = "ERROR"; when(view.getStopContainerErrorMessage()).thenReturn(errorMessage); doThrow(new RuntimeException()).when(specManagementService).stopContainer(containerSpecData.getContainerSpec()); presenter.stopContainer(); verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR)); verify(view).setContainerStartState(State.ENABLED); verify(view).setContainerStopState(State.DISABLED); verify(view).disableRemoveButton(); }
|
ContainerPresenter { public void loadContainers(@Observes final ContainerSpecData content) { if (content != null && content.getContainerSpec() != null && content.getContainers() != null && containerSpec != null && containerSpec.getId() != null && containerSpec.getId().equals(content.getContainerSpec().getId())) { setup(content.getContainerSpec(), content.getContainers()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); }
|
@Test public void testLoadContainersEmpty() { presenter.loadContainers(containerSpecData); verifyLoad(true, 1); }
@Test public void testLoadContainers() { final Container container = new Container("containerSpecId", "containerName", new ServerInstanceKey(), Collections.<Message>emptyList(), null, null); containerSpecData.getContainers().add(container); presenter.loadContainers(containerSpecData); verifyLoad(true, 1); }
@Test public void testLoadContainersNonStoped() { final Container container = new Container("containerSpecId", "containerName", new ServerInstanceKey(), Collections.<Message>emptyList(), null, null); container.setStatus(KieContainerStatus.STARTED); containerSpecData.getContainers().add(container); presenter.loadContainers(containerSpecData); verifyLoad(false, 1); }
|
ContainerPresenter { public void refresh() { load(containerSpec); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); }
|
@Test public void testRefresh() { when(runtimeManagementService.getContainersByContainerSpec( serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData); presenter.loadContainers(containerSpecData); presenter.refresh(); verifyLoad(true, 2); }
|
ContainerPresenter { public void load(@Observes final ContainerSpecSelected containerSpecSelected) { if (containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null) { load(containerSpecSelected.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); }
|
@Test public void testLoad() { when(runtimeManagementService.getContainersByContainerSpec( serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData); presenter.load(new ContainerSpecSelected(containerSpec)); verifyLoad(true, 1); }
@Test public void testLoadWhenRuntimeManagementServiceReturnsInvalidData() { ContainerSpecData badData = new ContainerSpecData(null, null); when(runtimeManagementService.getContainersByContainerSpec(anyObject(), anyObject())).thenReturn(badData); ContainerSpecKey lookupKey = new ContainerSpecKey("dummyId", "dummyName", new ServerTemplateKey("keyId", "keyName")); presenter.load(lookupKey); verify(view, never()).setContainerName(anyString()); }
|
ContainerPresenter { public void onRefresh(@Observes final RefreshRemoteServers refresh) { if (refresh != null && refresh.getContainerSpecKey() != null) { load(refresh.getContainerSpecKey()); } else { logger.warn("Illegal event argument."); } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); }
|
@Test public void testOnRefresh() { when(runtimeManagementService.getContainersByContainerSpec( serverTemplateKey.getId(), containerSpec.getId())).thenReturn(containerSpecData); presenter.onRefresh(new RefreshRemoteServers(containerSpec)); verifyLoad(true, 1); }
|
ContainerPresenter { public void removeContainer() { view.confirmRemove(new Command() { @Override public void execute() { specManagementService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { notification.fire(new NotificationEvent(view.getRemoveContainerSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); serverTemplateSelectedEvent.fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getRemoveContainerErrorMessage(), NotificationEvent.NotificationType.ERROR)); serverTemplateSelectedEvent.fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); return false; } }).deleteContainerSpec(containerSpec.getServerTemplateKey().getId(), containerSpec.getId()); } }); } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); }
|
@Test public void testRemoveContainer() { doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { final Command command = (Command) invocation.getArguments()[0]; if (command != null) { command.execute(); } return null; } }).when(view).confirmRemove(any(Command.class)); final String successMessage = "SUCCESS"; when(view.getRemoveContainerSuccessMessage()).thenReturn(successMessage); presenter.loadContainers(containerSpecData); presenter.removeContainer(); verify(specManagementService).deleteContainerSpec(serverTemplateKey.getId(), containerSpec.getId()); final ArgumentCaptor<NotificationEvent> notificationCaptor = ArgumentCaptor.forClass(NotificationEvent.class); verify(notification).fire(notificationCaptor.capture()); final NotificationEvent event = notificationCaptor.getValue(); assertEquals(NotificationEvent.NotificationType.SUCCESS, event.getType()); assertEquals(successMessage, event.getNotification()); final ArgumentCaptor<ServerTemplateSelected> serverTemplateSelectedCaptor = ArgumentCaptor.forClass(ServerTemplateSelected.class); verify(serverTemplateSelectedEvent).fire(serverTemplateSelectedCaptor.capture()); assertEquals(serverTemplateKey.getId(), serverTemplateSelectedCaptor.getValue().getServerTemplateKey().getId()); final String errorMessage = "ERROR"; when(view.getRemoveContainerErrorMessage()).thenReturn(errorMessage); doThrow(new RuntimeException()).when(specManagementService).deleteContainerSpec(serverTemplateKey.getId(), containerSpec.getId()); presenter.removeContainer(); verify(notification).fire(new NotificationEvent(errorMessage, NotificationEvent.NotificationType.ERROR)); verify(serverTemplateSelectedEvent, times(2)).fire(new ServerTemplateSelected(containerSpec.getServerTemplateKey())); }
|
ContainerPresenter { protected void updateStatus(final KieContainerStatus status) { switch (status) { case CREATING: case STARTED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(false); view.enableToggleActivationButton(); break; case DEACTIVATED: view.disableRemoveButton(); view.setContainerStartState(State.ENABLED); view.setContainerStopState(State.DISABLED); view.updateToggleActivationButton(true); view.enableToggleActivationButton(); break; case STOPPED: view.updateToggleActivationButton(false); case DISPOSING: case FAILED: view.enableRemoveButton(); view.setContainerStartState(State.DISABLED); view.setContainerStopState(State.ENABLED); view.disableToggleActivationButton(); break; } } @Inject ContainerPresenter(final Logger logger,
final View view,
final ContainerRemoteStatusPresenter containerRemoteStatusPresenter,
final ContainerStatusEmptyPresenter containerStatusEmptyPresenter,
final ContainerProcessConfigPresenter containerProcessConfigPresenter,
final ContainerRulesConfigPresenter containerRulesConfigPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementService,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent,
final Event<NotificationEvent> notification); @PostConstruct void init(); View getView(); void onRefresh(@Observes final RefreshRemoteServers refresh); void load(@Observes final ContainerSpecSelected containerSpecSelected); void onInstanceUpdated(@Observes ServerInstanceUpdated instanceUpdated); void loadContainers(@Observes final ContainerSpecData content); void refreshOnContainerUpdateEvent(@Observes final ContainerUpdateEvent updateEvent); void refresh(); void load(final ContainerSpecKey containerSpecKey); void removeContainer(); void stopContainer(); void startContainer(); void toggleActivationContainer(); }
|
@Test public void testUpdateStatusForStopped() { presenter.updateStatus(KieContainerStatus.STOPPED); verify(view).updateToggleActivationButton(false); }
@Test public void testUpdateStatusForStarted() { presenter.updateStatus(KieContainerStatus.STARTED); verify(view).disableRemoveButton(); verify(view).setContainerStartState(State.ENABLED); verify(view).setContainerStopState(State.DISABLED); verify(view).updateToggleActivationButton(false); verify(view).enableToggleActivationButton(); }
@Test public void testUpdateStatusForFailed() { presenter.updateStatus(KieContainerStatus.FAILED); verify(view).enableRemoveButton(); verify(view).setContainerStartState(State.DISABLED); verify(view).setContainerStopState(State.ENABLED); verify(view).disableToggleActivationButton(); }
@Test public void testUpdateStatusForDeactiveated() { presenter.updateStatus(KieContainerStatus.DEACTIVATED); verify(view).disableRemoveButton(); verify(view).setContainerStartState(State.ENABLED); verify(view).setContainerStopState(State.DISABLED); verify(view).updateToggleActivationButton(true); verify(view).enableToggleActivationButton(); }
|
DeleteRelationRowCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<AbstractCanvasHandler, CanvasViolation> newCanvasCommand(final AbstractCanvasHandler handler) { return new AbstractCanvasCommand() { @Override public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler handler) { uiModel.deleteRow(uiRowIndex); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } @Override public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler handler) { uiModel.insertRow(uiRowIndex, oldUiModelRow); updateRowNumbers(); updateParentInformation(); canvasOperation.execute(); return CanvasCommandResultBuilder.SUCCESS; } }; } DeleteRelationRowCommand(final Relation relation,
final GridData uiModel,
final int uiRowIndex,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); }
|
@Test public void testCanvasCommandAllow() { final Command<AbstractCanvasHandler, CanvasViolation> c = command.newCanvasCommand(handler); assertEquals(CanvasCommandResultBuilder.SUCCESS, c.allow(handler)); }
|
ContainerCardPresenter { public org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView() { return view; } @Inject ContainerCardPresenter( final ManagedInstance<Object> presenterProvider,
final org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View view,
final Event<ContainerSpecSelected> containerSpecSelectedEvent ); org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView(); void setup( final Container container ); }
|
@Test public void testInit() { assertEquals( view, presenter.getView() ); }
|
ContainerCardPresenter { public void setup( final Container container ) { final LinkTitlePresenter linkTitlePresenter = presenterProvider.select( LinkTitlePresenter.class ).get(); linkTitlePresenter.setup( container.getContainerName() != null ? container.getContainerName() : container.getContainerSpecId(), new Command() { @Override public void execute() { containerSpecSelectedEvent.fire( new ContainerSpecSelected( buildContainerSpecKey( container ) ) ); } } ); final InfoTitlePresenter infoTitlePresenter = presenterProvider.select( InfoTitlePresenter.class ).get(); infoTitlePresenter.setup( container.getResolvedReleasedId() ); final BodyPresenter bodyPresenter = presenterProvider.select( BodyPresenter.class ).get(); bodyPresenter.setup( container.getMessages() ); final FooterPresenter footerPresenter = presenterProvider.select( FooterPresenter.class ).get(); footerPresenter.setup( container.getUrl(), container.getResolvedReleasedId().getVersion() ); CardPresenter card = presenterProvider.select( CardPresenter.class ).get(); card.addTitle( linkTitlePresenter ); card.addTitle( infoTitlePresenter ); card.addBody( bodyPresenter ); card.addFooter( footerPresenter ); view.setCard( card.getView() ); } @Inject ContainerCardPresenter( final ManagedInstance<Object> presenterProvider,
final org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View view,
final Event<ContainerSpecSelected> containerSpecSelectedEvent ); org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter.View getView(); void setup( final Container container ); }
|
@Test public void testSetup() { final InfoTitlePresenter infoTitlePresenter = mock( InfoTitlePresenter.class ); when( infoTitlePresenterProvider.get() ).thenReturn( infoTitlePresenter ); final LinkTitlePresenter linkTitlePresenter = spy( new LinkTitlePresenter( mock( LinkTitlePresenter.View.class ) ) ); when( linkTitlePresenterProvider.get() ).thenReturn( linkTitlePresenter ); final BodyPresenter bodyPresenter = mock( BodyPresenter.class ); when( bodyPresenterProvider.get() ).thenReturn( bodyPresenter ); final FooterPresenter footerPresenter = mock( FooterPresenter.class ); when( footerPresenterProvider.get() ).thenReturn( footerPresenter ); final CardPresenter.View cardPresenterView = mock( CardPresenter.View.class ); final CardPresenter cardPresenter = spy( new CardPresenter( cardPresenterView ) ); when( cardPresenterProvider.get() ).thenReturn( cardPresenter ); final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "templateId", "serverName", "serverInstanceId", "url" ); final Message message = new Message( Severity.INFO, "testMessage" ); final ReleaseId resolvedReleasedId = new ReleaseId( "org.kie", "container", "1.0.0" ); final Container container = new Container( "containerSpecId", "containerName", serverInstanceKey, Collections.singletonList( message ), resolvedReleasedId, null ); presenter.setup( container ); verify( linkTitlePresenter ).setup( eq( container.getContainerName() ), any( Command.class ) ); verify( infoTitlePresenter ).setup( container.getResolvedReleasedId() ); verify( bodyPresenter ).setup( Arrays.asList( message ) ); verify( footerPresenter ).setup( container.getUrl(), resolvedReleasedId.getVersion() ); verify( cardPresenter ).addTitle( linkTitlePresenter ); verify( cardPresenter ).addTitle( infoTitlePresenter ); verify( cardPresenter ).addBody( bodyPresenter ); verify( cardPresenter ).addFooter( footerPresenter ); verify( view ).setCard( cardPresenterView ); linkTitlePresenter.onSelect(); final ContainerSpecKey containerSpecKey = new ContainerSpecKey( container.getContainerSpecId(), container.getContainerName(), new ServerTemplateKey( container.getServerInstanceKey().getServerTemplateId(), "" ) ); verify( containerSpecSelectedEvent ).fire( eq( new ContainerSpecSelected( containerSpecKey ) ) ); }
@Test public void testSetupWithUnNamedContainer() { final InfoTitlePresenter infoTitlePresenter = mock(InfoTitlePresenter.class); when(infoTitlePresenterProvider.get()).thenReturn(infoTitlePresenter); final LinkTitlePresenter linkTitlePresenter = spy(new LinkTitlePresenter(mock(LinkTitlePresenter.View.class))); when(linkTitlePresenterProvider.get()).thenReturn(linkTitlePresenter); final BodyPresenter bodyPresenter = mock(BodyPresenter.class); when(bodyPresenterProvider.get()).thenReturn(bodyPresenter); final FooterPresenter footerPresenter = mock(FooterPresenter.class); when(footerPresenterProvider.get()).thenReturn(footerPresenter); final CardPresenter.View cardPresenterView = mock(CardPresenter.View.class); final CardPresenter cardPresenter = spy(new CardPresenter(cardPresenterView)); when(cardPresenterProvider.get()).thenReturn(cardPresenter); final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("templateId", "serverName", "serverInstanceId", "url"); final Message message = new Message(Severity.INFO, "testMessage"); final ReleaseId resolvedReleasedId = new ReleaseId("org.kie", "container", "1.0.0"); final Container container = new Container("containerSpecId", null, serverInstanceKey, Collections.singletonList(message), resolvedReleasedId, null); presenter.setup(container); verify(linkTitlePresenter).setup(eq(container.getContainerSpecId()), any(Command.class)); verify(view).setCard(cardPresenterView); linkTitlePresenter.onSelect(); final ContainerSpecKey containerSpecKey = new ContainerSpecKey(container.getContainerSpecId(), container.getContainerSpecId(), new ServerTemplateKey(container.getServerInstanceKey().getServerTemplateId(), "")); verify(containerSpecSelectedEvent).fire(eq(new ContainerSpecSelected(containerSpecKey))); }
|
RemoteEmptyPresenter { public View getView() { return view; } @Inject RemoteEmptyPresenter( final View view ); View getView(); }
|
@Test public void testInit() { assertEquals( view, presenter.getView() ); }
|
RemotePresenter { @PostConstruct public void init() { view.init( this ); } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void onSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void remove(); void refresh(); void load( final ServerInstanceKey serverInstanceKey ); }
|
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); }
|
RemotePresenter { public void remove() { specManagementServiceCaller.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { notification.fire( new NotificationEvent( view.getRemoteInstanceRemoveSuccessMessage(), NotificationEvent.NotificationType.SUCCESS ) ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getRemoteInstanceRemoveErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); return false; } } ).deleteServerInstance( serverInstanceKey ); } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void onSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void remove(); void refresh(); void load( final ServerInstanceKey serverInstanceKey ); }
|
@Test public void testRemove() { final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "templateId", "serverName", "serverInstanceId", "url" ); presenter.onSelect( new ServerInstanceSelected( serverInstanceKey ) ); presenter.remove(); verify( specManagementService ).deleteServerInstance( serverInstanceKey ); verify( notification ).fire( any( NotificationEvent.class ) ); }
|
RemotePresenter { public void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ) { if ( serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null ) { final ServerInstanceKey updatedServerInstanceKey = toKey( serverInstanceUpdated.getServerInstance() ); if ( serverInstanceKey != null && serverInstanceKey.getServerInstanceId().equals( updatedServerInstanceKey.getServerInstanceId() ) ) { serverInstanceKey = updatedServerInstanceKey; loadContent( serverInstanceUpdated.getServerInstance().getContainers() ); } } else { logger.warn( "Illegal event argument." ); } } @Inject RemotePresenter( final Logger logger,
final View view,
final RemoteStatusPresenter remoteStatusPresenter,
final RemoteEmptyPresenter remoteEmptyPresenter,
final Caller<RuntimeManagementService> runtimeManagementService,
final Caller<SpecManagementService> specManagementServiceCaller,
final Event<NotificationEvent> notification ); @PostConstruct void init(); View getView(); void onSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onInstanceUpdate( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void remove(); void refresh(); void load( final ServerInstanceKey serverInstanceKey ); }
|
@Test public void testOnInstanceUpdate() { final ServerInstance serverInstance = new ServerInstance( "templateId", "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList() ); presenter.onSelect( new ServerInstanceSelected( serverInstance ) ); presenter.onInstanceUpdate( new ServerInstanceUpdated( serverInstance ) ); verify( view, times( 2 ) ).clear(); verify( view, times( 2 ) ).setServerName( serverInstance.getServerName() ); verify( view, times( 2 ) ).setServerURL( serverInstance.getUrl() ); verify( view, times( 2 ) ).setEmptyView( remoteEmptyPresenter.getView() ); }
@Test public void testOnInstanceUpdateWithoutSelect() { final ServerInstance serverInstance = new ServerInstance( "templateId", "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList() ); presenter.onInstanceUpdate( new ServerInstanceUpdated( serverInstance ) ); verify( view, never() ).clear(); verify( view, never() ).setServerName( anyString() ); verify( view, never() ).setServerURL( anyString() ); verify( view, never() ).setEmptyView( any(RemoteEmptyView.class) ); }
|
MoveRowsCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { moveRows(index); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) { moveRows(oldIndex); return GraphCommandResultBuilder.SUCCESS; } private void moveRows(final int index) { final java.util.List<List> rowsToMove = rows .stream() .map(r -> uiModel.getRows().indexOf(r)) .map(i -> relation.getRow().get(i)) .collect(Collectors.toList()); final java.util.List<List> rows = relation.getRow(); CommandUtils.moveRows(rows, rowsToMove, index); } }; } MoveRowsCommand(final Relation relation,
final DMNGridData uiModel,
final int index,
final java.util.List<GridRow> rows,
final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); }
|
@Test public void testGraphCommandAllow() { setupCommand(0, uiModel.getRow(0)); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.allow(gce)); }
@Test public void testGraphCommandExecuteMoveUp() { setupCommand(0, uiModel.getRow(1)); assertEquals(GraphCommandResultBuilder.SUCCESS, command.newGraphCommand(handler).execute(gce)); assertRelationDefinition(1, 0); }
@Test public void testGraphCommandExecuteMoveDown() { setupCommand(1, uiModel.getRow(0)); assertEquals(GraphCommandResultBuilder.SUCCESS, command.newGraphCommand(handler).execute(gce)); assertRelationDefinition(1, 0); }
|
ServerNavigationPresenter { @PostConstruct public void init() { view.init(this); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); }
|
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); }
|
ServerNavigationPresenter { public void clear() { view.clean(); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); }
|
@Test public void testClear() { presenter.clear(); verify( view ).clean(); }
|
ServerNavigationPresenter { public void select(final String id) { serverTemplateSelectedEvent.fire(new ServerTemplateSelected(new ServerTemplateKey(id, ""))); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); }
|
@Test public void testSelect() { final String serverId = "serverId"; presenter.select( serverId ); final ArgumentCaptor<ServerTemplateSelected> serverTemplateSelectedCaptor = ArgumentCaptor.forClass( ServerTemplateSelected.class ); verify( serverTemplateSelectedEvent ).fire( serverTemplateSelectedCaptor.capture() ); assertEquals( serverId, serverTemplateSelectedCaptor.getValue().getServerTemplateKey().getId() ); }
|
ServerNavigationPresenter { public void refresh() { serverTemplateListRefreshEvent.fire(new ServerTemplateListRefresh()); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); }
|
@Test public void testRefresh() { presenter.refresh(); verify( serverTemplateListRefreshEvent ).fire( any( ServerTemplateListRefresh.class ) ); }
|
ServerNavigationPresenter { public void newTemplate() { addNewServerTemplateEvent.fire(new AddNewServerTemplate()); } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); }
|
@Test public void testNewTemplate() { presenter.newTemplate(); verify( addNewServerTemplateEvent ).fire( any( AddNewServerTemplate.class ) ); }
|
ServerNavigationPresenter { public void setup(final ServerTemplateKey firstTemplate, final Collection<ServerTemplateKey> serverTemplateKeys) { view.clean(); serverTemplates.clear(); addTemplate(checkNotNull("serverTemplate2BeSelected", firstTemplate)); for (final ServerTemplateKey serverTemplateKey : serverTemplateKeys) { if (!serverTemplateKey.equals(firstTemplate)) { addTemplate(serverTemplateKey); } } } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); }
|
@Test public void testSetup() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); presenter.setup( serverTemplateKey, Collections.singletonList( serverTemplateKey ) ); verify( view ).clean(); verify( view ).addTemplate( serverTemplateKey.getId(), serverTemplateKey.getName() ); }
|
ServerNavigationPresenter { public void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected) { if (serverTemplateSelected != null && serverTemplateSelected.getServerTemplateKey() != null && serverTemplateSelected.getServerTemplateKey().getId() != null) { view.select(serverTemplateSelected.getServerTemplateKey().getId()); } else { logger.warn("Illegal event argument."); } } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); }
|
@Test public void testOnSelect() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); presenter.onSelect( new ServerTemplateSelected( serverTemplateKey ) ); verify( view ).select( serverTemplateKey.getId() ); }
|
ServerNavigationPresenter { public void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated) { if (serverTemplateUpdated != null && serverTemplateUpdated.getServerTemplate() != null) { final ServerTemplate serverTemplate = serverTemplateUpdated.getServerTemplate(); if (!serverTemplates.contains(serverTemplate.getId())) { addTemplate(serverTemplate); } } else { logger.warn("Illegal event argument."); } } @Inject ServerNavigationPresenter(final Logger logger,
final View view,
final Event<AddNewServerTemplate> addNewServerTemplateEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent,
final Event<ServerTemplateSelected> serverTemplateSelectedEvent); @PostConstruct void init(); View getView(); void setup(final ServerTemplateKey firstTemplate,
final Collection<ServerTemplateKey> serverTemplateKeys); void onSelect(@Observes final ServerTemplateSelected serverTemplateSelected); void onServerTemplateUpdated(@Observes final ServerTemplateUpdated serverTemplateUpdated); void select(final String id); void clear(); void refresh(); void newTemplate(); }
|
@Test public void testOnServerTemplateUpdated() { final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateKeyId", "ServerTemplateKeyName" ); presenter.onServerTemplateUpdated( new ServerTemplateUpdated( serverTemplate ) ); verify( view ).addTemplate( serverTemplate.getId(), serverTemplate.getName() ); }
|
CopyPopupPresenter { @PostConstruct public void init() { view.init(this); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); }
|
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); }
|
CopyPopupPresenter { public void hide() { view.hide(); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); }
|
@Test public void testHide() { presenter.hide(); verify( view ).hide(); }
|
FindAllDmnAssetsQuery extends AbstractFindQuery implements NamedQuery { @Override public void validateTerms(final Set<ValueIndexTerm> queryTerms) throws IllegalArgumentException { checkTerms(queryTerms, NAME, requiredTermNames(), repositoryRootIndexTermPredicate(), fileExtensionIndexTermPredicate()); checkTermsSize(2, queryTerms); } @Inject FindAllDmnAssetsQuery(final FileDetailsResponseBuilder responseBuilder); @Override String getName(); @Override Query toQuery(final Set<ValueIndexTerm> terms); @Override Sort getSortOrder(); @Override ResponseBuilder getResponseBuilder(); @Override void validateTerms(final Set<ValueIndexTerm> queryTerms); static String NAME; }
|
@Test public void testValidateTerms() { final Set<ValueIndexTerm> queryTerms = new HashSet<>(); final String[] requiredTermNames = new String[]{}; final Predicate<ValueIndexTerm> fileExtensionIndexTermPredicate = (t) -> true; final Predicate<ValueIndexTerm> repositoryRootIndexTermPredicate = (t) -> true; doReturn(requiredTermNames).when(query).requiredTermNames(); doReturn(fileExtensionIndexTermPredicate).when(query).repositoryRootIndexTermPredicate(); doReturn(repositoryRootIndexTermPredicate).when(query).fileExtensionIndexTermPredicate(); query.validateTerms(queryTerms); verify(query).checkTermsSize(2, queryTerms); verify(query).checkTerms(queryTerms, NAME, requiredTermNames, fileExtensionIndexTermPredicate, repositoryRootIndexTermPredicate); }
|
CopyPopupPresenter { public void copy(final ParameterizedCommand<String> command) { this.command = checkNotNull("command", command); view.clear(); view.display(); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); }
|
@Test public void testCopy() { final String newTemplateName = "NewTemplateName"; when( view.getNewTemplateName() ).thenReturn( newTemplateName ); final ParameterizedCommand command = mock( ParameterizedCommand.class ); presenter.copy( command ); verify( view ).clear(); verify( view ).display(); presenter.save(); verify( command ).execute( newTemplateName ); }
|
CopyPopupPresenter { public void save() { if (view.getNewTemplateName().trim().isEmpty()) { view.errorOnTemplateNameFromGroup(); return; } command.execute(view.getNewTemplateName()); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); }
|
@Test public void testCopyError() { when( view.getNewTemplateName() ).thenReturn( "" ); presenter.save(); verify( view ).errorOnTemplateNameFromGroup(); }
|
CopyPopupPresenter { public void errorDuringProcessing(final String message) { view.errorOnTemplateNameFromGroup(message); } @Inject CopyPopupPresenter(final View view); @PostConstruct void init(); View getView(); void copy(final ParameterizedCommand<String> command); void errorDuringProcessing(final String message); void save(); void hide(); }
|
@Test public void testErrorOnTemplateNameFromGroup() { final String errorMessage = "errorMessage"; presenter.errorDuringProcessing( errorMessage ); verify( view ).errorOnTemplateNameFromGroup( errorMessage ); }
|
ServerTemplatePresenter { @PostConstruct public void init() { view.init( this ); } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); }
|
@Test public void testInit() { presenter.init(); verify( view ).init( presenter ); assertEquals( view, presenter.getView() ); }
|
ServerTemplatePresenter { public void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ) { if ( containerSpecSelected != null && containerSpecSelected.getContainerSpecKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey() != null && containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId() != null && containerSpecSelected.getContainerSpecKey().getId() != null ) { view.selectContainer( containerSpecSelected.getContainerSpecKey().getServerTemplateKey().getId(), containerSpecSelected.getContainerSpecKey().getId() ); } else { logger.warn( "Illegal event argument." ); } } @Inject ServerTemplatePresenter( final Logger logger,
final View view,
final CopyPopupPresenter copyPresenter,
final Caller<SpecManagementService> specManagementService,
final Event<NotificationEvent> notification,
final Event<AddNewContainer> addNewContainerEvent,
final Event<ContainerSpecSelected> containerSpecSelectedEvent,
final Event<ServerInstanceSelected> serverInstanceSelectedEvent,
final Event<ServerTemplateListRefresh> serverTemplateListRefreshEvent ); @PostConstruct void init(); View getView(); ServerTemplate getCurrentServerTemplate(); void setup( final ServerTemplate serverTemplate,
final ContainerSpec firstContainerSpec ); void onContainerSelect( @Observes final ContainerSpecSelected containerSpecSelected ); void onServerInstanceSelect( @Observes final ServerInstanceSelected serverInstanceSelected ); void onServerInstanceUpdated( @Observes final ServerInstanceUpdated serverInstanceUpdated ); void onServerInstanceDeleted( @Observes final ServerInstanceDeleted serverInstanceDeleted ); void addNewContainer(); void copyTemplate(); void removeTemplate(); }
|
@Test public void testOnContainerSelect() { final ServerTemplateKey serverTemplateKey = new ServerTemplateKey( "ServerTemplateKeyId", "ServerTemplateKeyName" ); final ContainerSpecKey containerSpecKey = new ContainerSpecKey( "containerId", "containerName", serverTemplateKey ); presenter.onContainerSelect( new ContainerSpecSelected( containerSpecKey ) ); verify( view ).selectContainer( serverTemplateKey.getId(), containerSpecKey.getId() ); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.