Search in sources :

Example 1 with ServerTemplateSelected

use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected 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 ServerTemplateSelected

use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected in project kie-wb-common by kiegroup.

the class ServerManagementBrowserPresenterTest method testOnSelectedNonEmptyServerTemplate.

@Test
public void testOnSelectedNonEmptyServerTemplate() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    final ContainerSpec toBeSelected = mock(ContainerSpec.class);
    serverTemplate.addContainerSpec(toBeSelected);
    when(toBeSelected.getId()).thenReturn("other-id");
    final ContainerSpec forcedToBeSelected = mock(ContainerSpec.class);
    when(forcedToBeSelected.getId()).thenReturn("container-id");
    serverTemplate.addContainerSpec(forcedToBeSelected);
    final ServerTemplateKey serverTemplateKey = new ServerTemplateKey("ServerTemplateKeyId", "ServerTemplateKeyName");
    when(specManagementService.getServerTemplate(serverTemplateKey.getId())).thenReturn(serverTemplate);
    final ServerTemplatePresenter.View serverView = mock(ServerTemplatePresenter.View.class);
    when(serverTemplatePresenter.getView()).thenReturn(serverView);
    presenter.onSelected(new ServerTemplateSelected(serverTemplateKey));
    verify(view).setServerTemplate(serverView);
    verify(specManagementService).getServerTemplate(serverTemplateKey.getId());
    verify(serverTemplatePresenter).setup(serverTemplate, toBeSelected);
    presenter.onSelected(new ServerTemplateSelected(serverTemplateKey, "container-id"));
    verify(serverTemplatePresenter).setup(serverTemplate, forcedToBeSelected);
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ServerTemplatePresenter(org.kie.workbench.common.screens.server.management.client.navigation.template.ServerTemplatePresenter) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) Test(org.junit.Test)

Example 3 with ServerTemplateSelected

use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected in project kie-wb-common by kiegroup.

the class ContainerPresenterTest method testRemoveContainer.

@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()));
}
Also used : Answer(org.mockito.stubbing.Answer) Command(org.uberfire.mvp.Command) InvocationOnMock(org.mockito.invocation.InvocationOnMock) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) Test(org.junit.Test)

Example 4 with ServerTemplateSelected

use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected in project kie-wb-common by kiegroup.

the class NewContainerWizard method saveContainerSpec.

protected void saveContainerSpec(final ContainerSpec newContainer) {
    newContainerFormPresenter.showBusyIndicator(newContainer.getReleasedId().toString());
    specManagementService.call(new RemoteCallback<Void>() {

        @Override
        public void callback(final Void o) {
            notification.fire(new NotificationEvent(newContainerFormPresenter.getView().getNewContainerWizardSaveSuccess(), NotificationEvent.NotificationType.SUCCESS));
            clear();
            NewContainerWizard.super.complete();
            serverTemplateSelectedEvent.fire(new ServerTemplateSelected(serverTemplate, newContainer.getId()));
            newContainerFormPresenter.hideBusyIndicator();
        }
    }, new ErrorCallback<Object>() {

        @Override
        public boolean error(final Object o, final Throwable throwable) {
            newContainerFormPresenter.hideBusyIndicator();
            notification.fire(new NotificationEvent(newContainerFormPresenter.getView().getNewContainerWizardSaveError(), NotificationEvent.NotificationType.ERROR));
            NewContainerWizard.this.pageSelected(0);
            NewContainerWizard.this.start();
            return false;
        }
    }).saveContainerSpec(newContainerFormPresenter.getServerTemplate().getId(), newContainer);
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 5 with ServerTemplateSelected

use of org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected in project kie-wb-common by kiegroup.

the class ServerNavigationPresenterTest method testOnSelect.

@Test
public void testOnSelect() {
    final ServerTemplateKey serverTemplateKey = new ServerTemplateKey("ServerTemplateKeyId", "ServerTemplateKeyName");
    presenter.onSelect(new ServerTemplateSelected(serverTemplateKey));
    verify(view).select(serverTemplateKey.getId());
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) Test(org.junit.Test)

Aggregations

ServerTemplateSelected (org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected)12 Test (org.junit.Test)10 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)8 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)6 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)4 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)3 ServerTemplateKeyList (org.kie.server.controller.api.model.spec.ServerTemplateKeyList)3 GAV (org.guvnor.common.services.project.model.GAV)2 JarListPageRow (org.guvnor.m2repo.model.JarListPageRow)2 ReleaseId (org.kie.server.api.model.ReleaseId)2 ServerTemplatePresenter (org.kie.workbench.common.screens.server.management.client.navigation.template.ServerTemplatePresenter)2 Command (org.uberfire.mvp.Command)2 PageResponse (org.uberfire.paging.PageResponse)2 Collection (java.util.Collection)1 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)1 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 ServerInstanceDeleted (org.kie.server.controller.api.model.events.ServerInstanceDeleted)1 ServerTemplateDeleted (org.kie.server.controller.api.model.events.ServerTemplateDeleted)1 ServerTemplateUpdated (org.kie.server.controller.api.model.events.ServerTemplateUpdated)1 ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)1