@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() ); }
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." ); } }
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." ); } } }
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 ); }
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(); }
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();  }