Search in sources :

Example 6 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 complete.

@Override
public void complete() {
    final Map<Capability, ContainerConfig> mapConfig = new HashMap<Capability, ContainerConfig>();
    if (getPages().size() == 2) {
        mapConfig.put(Capability.PROCESS, processConfigPagePresenter.buildProcessConfig());
    }
    mapConfig.put(Capability.RULE, new RuleConfig(null, KieScannerStatus.STOPPED));
    final ContainerSpec newContainer = newContainerFormPresenter.buildContainerSpec(newContainerFormPresenter.getServerTemplate().getId(), mapConfig);
    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()));
        }
    }, new ErrorCallback<Object>() {

        @Override
        public boolean error(final Object o, final Throwable throwable) {
            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 : Capability(org.kie.server.controller.api.model.spec.Capability) HashMap(java.util.HashMap) ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) 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) ContainerConfig(org.kie.server.controller.api.model.spec.ContainerConfig) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig)

Example 7 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 testOnSelectedServerTemplate.

@Test
public void testOnSelectedServerTemplate() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    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);
    final ServerContainerEmptyPresenter.View serverEmptyView = mock(ServerContainerEmptyPresenter.View.class);
    when(serverContainerEmptyPresenter.getView()).thenReturn(serverEmptyView);
    presenter.onSelected(new ServerTemplateSelected(serverTemplateKey));
    verify(view).setServerTemplate(serverView);
    verify(specManagementService).getServerTemplate(serverTemplateKey.getId());
    verify(serverContainerEmptyPresenter).setTemplate(serverTemplate);
    verify(view).setContent(serverEmptyView);
    verify(serverTemplatePresenter).setup(serverTemplate, null);
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ServerTemplatePresenter(org.kie.workbench.common.screens.server.management.client.navigation.template.ServerTemplatePresenter) ServerContainerEmptyPresenter(org.kie.workbench.common.screens.server.management.client.container.empty.ServerContainerEmptyPresenter) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) Test(org.junit.Test)

Example 8 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 testOnServerTemplateUpdated.

@Test
public void testOnServerTemplateUpdated() {
    final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
    presenter.onServerTemplateUpdated(new ServerTemplateUpdated(serverTemplate));
    final ArgumentCaptor<Collection> serverTemplateKeysCaptor = ArgumentCaptor.forClass(Collection.class);
    verify(navigationPresenter).setup(eq(serverTemplate), serverTemplateKeysCaptor.capture());
    final Collection<ServerTemplateKey> serverTemplateKeys = serverTemplateKeysCaptor.getValue();
    assertEquals(1, serverTemplateKeys.size());
    assertTrue(serverTemplateKeys.contains(serverTemplate));
    final ArgumentCaptor<ServerTemplateSelected> templateSelectedCaptor = ArgumentCaptor.forClass(ServerTemplateSelected.class);
    verify(serverTemplateSelectedEvent).fire(templateSelectedCaptor.capture());
    assertEquals(serverTemplate, templateSelectedCaptor.getValue().getServerTemplateKey());
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) Collection(java.util.Collection) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) ServerTemplateUpdated(org.kie.server.controller.api.model.events.ServerTemplateUpdated) Test(org.junit.Test)

Example 9 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 testOnOpen.

@Test
public void testOnOpen() {
    final ServerTemplateKey serverTemplateKey = new ServerTemplateKey("ServerTemplateKeyId", "ServerTemplateKeyName");
    final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList(serverTemplateKey);
    when(specManagementService.listServerTemplateKeys()).thenReturn(new ServerTemplateKeyList(serverTemplateKeys));
    presenter.onOpen();
    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) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) ServerTemplateKeyList(org.kie.server.controller.api.model.spec.ServerTemplateKeyList) Test(org.junit.Test)

Example 10 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 testOnServerDeleted.

@Test
public void testOnServerDeleted() {
    final ServerTemplateKey serverTemplateKey = new ServerTemplateKey("ServerTemplateKeyId", "ServerTemplateKeyName");
    final List<ServerTemplateKey> serverTemplateKeys = Collections.singletonList(serverTemplateKey);
    when(specManagementService.listServerTemplateKeys()).thenReturn(new ServerTemplateKeyList(serverTemplateKeys));
    presenter.onServerDeleted(new ServerTemplateDeleted());
    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) ServerTemplateDeleted(org.kie.server.controller.api.model.events.ServerTemplateDeleted) ServerTemplateSelected(org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected) ServerTemplateKeyList(org.kie.server.controller.api.model.spec.ServerTemplateKeyList) Test(org.junit.Test)

Aggregations

ServerTemplateSelected (org.kie.workbench.common.screens.server.management.client.events.ServerTemplateSelected)11 Test (org.junit.Test)9 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)8 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)5 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)3 ServerTemplateKeyList (org.kie.server.controller.api.model.spec.ServerTemplateKeyList)3 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)3 ServerTemplatePresenter (org.kie.workbench.common.screens.server.management.client.navigation.template.ServerTemplatePresenter)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)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 Capability (org.kie.server.controller.api.model.spec.Capability)1 ContainerConfig (org.kie.server.controller.api.model.spec.ContainerConfig)1 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)1 ServerContainerEmptyPresenter (org.kie.workbench.common.screens.server.management.client.container.empty.ServerContainerEmptyPresenter)1