### Question:
ServerTemplatePresenter { public void removeTemplate() { view.confirmRemove( new Command() { @Override public void execute() { specManagementService.call( new RemoteCallback<Void>() { @Override public void callback( final Void aVoid ) { serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh() ); } }, new ErrorCallback<Object>() { @Override public boolean error( final Object o, final Throwable throwable ) { notification.fire( new NotificationEvent( view.getRemoveTemplateErrorMessage(), NotificationEvent.NotificationType.ERROR ) ); serverTemplateListRefreshEvent.fire( new ServerTemplateListRefresh() ); return false; } } ).deleteServerTemplate( serverTemplate.getId() ); } } ); } @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();  }### Answer:
@Test public void testRemoveTemplate() { when( view.getRemoveTemplateErrorMessage() ).thenReturn( "ERROR" ); doAnswer( new Answer<Void>() { @Override public Void answer( final InvocationOnMock invocation ) throws Throwable { Command command = (Command) invocation.getArguments()[ 0 ]; if ( command != null ) { command.execute(); } return null; } } ).when( view ).confirmRemove( any( Command.class ) ); final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateKeyId", "ServerTemplateKeyName" ); presenter.setup( serverTemplate, null ); presenter.removeTemplate(); verify( specManagementService ).deleteServerTemplate( serverTemplate.getId() ); verify( serverTemplateListRefreshEvent ).fire( any( ServerTemplateListRefresh.class ) ); doThrow( new RuntimeException() ).when( specManagementService ).deleteServerTemplate( serverTemplate.getId() ); presenter.removeTemplate(); verify( specManagementService, times( 2 ) ).deleteServerTemplate( serverTemplate.getId() ); verify( serverTemplateListRefreshEvent, times( 2 ) ).fire( any( ServerTemplateListRefresh.class ) ); verify( notification ).fire( new NotificationEvent( "ERROR", NotificationEvent.NotificationType.ERROR ) ); }