Search in sources :

Example 1 with ServerInstanceDeleted

use of org.kie.server.controller.api.model.events.ServerInstanceDeleted in project kie-wb-common by kiegroup.

the class ServerManagementBrowserPresenterTest method testOnDelete.

@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());
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ServerInstanceDeleted(org.kie.server.controller.api.model.events.ServerInstanceDeleted) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ServerTemplateKeyList(org.kie.server.controller.api.model.spec.ServerTemplateKeyList) Test(org.junit.Test)

Example 2 with ServerInstanceDeleted

use of org.kie.server.controller.api.model.events.ServerInstanceDeleted in project kie-wb-common by kiegroup.

the class ContainerRemoteStatusPresenterTest method testOnDelete.

@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();
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) ContainerCardPresenter(org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter) Container(org.kie.server.controller.api.model.runtime.Container) ServerInstanceDeleted(org.kie.server.controller.api.model.events.ServerInstanceDeleted) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) Test(org.junit.Test)

Example 3 with ServerInstanceDeleted

use of org.kie.server.controller.api.model.events.ServerInstanceDeleted in project kie-wb-common by kiegroup.

the class ServerManagementBrowserPresenterTest method testOnDeleteWithoutCurrentServer.

@Test
public void testOnDeleteWithoutCurrentServer() {
    final ServerInstanceKey serverInstanceKey = new ServerInstanceKey("serverInstanceKeyId", "serverName", "serverInstanceId", "url");
    presenter.onDelete(new ServerInstanceDeleted(serverInstanceKey.getServerInstanceId()));
    verify(specManagementService, never()).listServerTemplateKeys();
}
Also used : ServerInstanceDeleted(org.kie.server.controller.api.model.events.ServerInstanceDeleted) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) Test(org.junit.Test)

Example 4 with ServerInstanceDeleted

use of org.kie.server.controller.api.model.events.ServerInstanceDeleted in project kie-wb-common by kiegroup.

the class ServerTemplatePresenterTest method testOnServerInstanceUpdated.

@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));
}
Also used : ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ServerInstanceDeleted(org.kie.server.controller.api.model.events.ServerInstanceDeleted) ServerInstanceUpdated(org.kie.server.controller.api.model.events.ServerInstanceUpdated) ServerInstance(org.kie.server.controller.api.model.runtime.ServerInstance) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 ServerInstanceDeleted (org.kie.server.controller.api.model.events.ServerInstanceDeleted)4 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)3 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)2 IsWidget (com.google.gwt.user.client.ui.IsWidget)1 ServerInstanceUpdated (org.kie.server.controller.api.model.events.ServerInstanceUpdated)1 Container (org.kie.server.controller.api.model.runtime.Container)1 ServerInstance (org.kie.server.controller.api.model.runtime.ServerInstance)1 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)1 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)1 ServerTemplateKeyList (org.kie.server.controller.api.model.spec.ServerTemplateKeyList)1 ContainerCardPresenter (org.kie.workbench.common.screens.server.management.client.container.status.card.ContainerCardPresenter)1 ServerTemplateSelected (org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected)1 Command (org.uberfire.mvp.Command)1 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)1