@Test public void testServerInstanceDeleted() { handler.accept(new ServerInstanceDeleted("serverId")); verify(eventHandler).onServerInstanceDeleted(any()); verifyNoMoreInteractions(eventHandler); }
@Test public void testOnDeleteWithoutCurrentServer() { final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "serverInstanceKeyId", "serverName", "serverInstanceId", "url" ); presenter.onDelete( new ServerInstanceDeleted( serverInstanceKey.getServerInstanceId() ) ); verify( specManagementService, never() ).listServerTemplateKeys(); }
protected void notifyOnDisconnect(ServerInstanceKey serverInstanceKey, ServerTemplate serverTemplate) { notificationService.notify(new ServerInstanceDeleted(serverInstanceKey.getServerInstanceId())); notificationService.notify(new ServerTemplateUpdated(serverTemplate)); notificationService.notify(new ServerInstanceDisconnected(serverInstanceKey.getServerInstanceId())); }
@Test public void testOnDelete() { final ContainerCardPresenter cardPresenter = mock( ContainerCardPresenter.class ); when( cardPresenter.getView() ).thenReturn( mock( ContainerCardPresenter.View.class ) ); when( presenterProvider.get() ).thenReturn( cardPresenter ); final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "templateId", "serverName", "serverInstanceId", "url" ); final Container container = new Container( "containerSpecId", "containerName", serverInstanceKey, Collections.<Message>emptyList(), null, null ); container.setStatus( KieContainerStatus.STARTED ); presenter.setup( new ContainerSpec(), Collections.singletonList( container ) ); verify( view ).clear(); verify( cardPresenter ).setup( container.getServerInstanceKey(), container ); verify( view ).addCard( any( IsWidget.class ) ); presenter.onDelete( new ServerInstanceDeleted( serverInstanceKey.getServerInstanceId() ) ); verify( cardPresenter ).delete(); presenter.onDelete( new ServerInstanceDeleted( "randomKey" ) ); verify( cardPresenter ).delete(); }
@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 testServerInstanceDeleted() throws Exception { final ServerInstanceDeleted event = new ServerInstanceDeleted("serverId"); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
@Override public void deleteServerInstance(final ServerInstanceKey serverInstanceKey) { checkNotNull("serverInstanceKey", serverInstanceKey); if (getKieServerInstanceManager().isAlive(serverInstanceKey)) { throw new RuntimeException("Can't delete live instance."); } else { final String serverInstanceId = serverInstanceKey.getServerInstanceId(); final ServerTemplate serverTemplate = getServerTemplate(serverInstanceKey.getServerTemplateId()); if (serverTemplate != null) { serverTemplate.deleteServerInstance(serverInstanceId); getTemplateStorage().update(serverTemplate); getNotificationService().notify(new ServerInstanceDeleted(serverInstanceId)); } } }
@Test public void testOnServerInstanceUpdated() { final ServerTemplate serverTemplate = new ServerTemplate( "ServerTemplateId", "ServerTemplateName" ); presenter.setup( serverTemplate, null ); assertEquals( serverTemplate, presenter.getCurrentServerTemplate() ); final ServerInstance serverInstance = new ServerInstance( serverTemplate.getId(), "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList() ); presenter.onServerInstanceUpdated( new ServerInstanceUpdated( serverInstance ) ); presenter.onServerInstanceUpdated( new ServerInstanceUpdated( serverInstance ) ); verify( view ).addServerInstance( eq( serverInstance.getServerTemplateId() ), eq( serverInstance.getServerInstanceId() ), eq( serverInstance.getServerName() ), any( Command.class ) ); presenter.onServerInstanceDeleted( new ServerInstanceDeleted( serverInstance.getServerInstanceId() ) ); presenter.onServerInstanceUpdated( new ServerInstanceUpdated( serverInstance ) ); verify( view, times( 2 ) ).addServerInstance( eq( serverInstance.getServerTemplateId() ), eq( serverInstance.getServerInstanceId() ), eq( serverInstance.getServerName() ), any( Command.class ) ); }
@Parameterized.Parameters(name = "{index}: {0}") public static Collection<Object[]> data() { Collection<Object[]> parameterData = new ArrayList<Object[]>(Arrays.asList(new Object[][]{ {new ServerInstanceConnected(new ServerInstance())}, {new ServerInstanceDisconnected("serverId")}, {new ServerInstanceDeleted("serverId")}, {new ServerInstanceUpdated(new ServerInstance())}, {new ServerTemplateUpdated(new ServerTemplate())}, {new ServerTemplateDeleted("serverTemplateId")}, {new ContainerSpecUpdated(new ServerTemplate(), new ContainerSpec(), new ArrayList<>())} } )); return parameterData; }