Search in sources :

Example 21 with ServerInstanceKey

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

the class ServerTemplateVFSStorageTest method testStoreLoadAndUpdateServerTemplate.

@Test
public void testStoreLoadAndUpdateServerTemplate() {
    templateStorage.store(serverTemplate);
    ServerTemplate fromStorage = templateStorage.load(serverTemplate.getId());
    assertNotNull(fromStorage);
    assertEquals(serverTemplate.getId(), fromStorage.getId());
    assertEquals(serverTemplate.getName(), fromStorage.getName());
    // let's add new container
    ContainerSpec newContainerSpec = new ContainerSpec();
    newContainerSpec.setId("test container 2");
    newContainerSpec.setServerTemplateKey(new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName()));
    newContainerSpec.setReleasedId(new ReleaseId("org.kie", "kie-server-kjar", "3.0"));
    newContainerSpec.setStatus(KieContainerStatus.STARTED);
    fromStorage.addContainerSpec(newContainerSpec);
    // now let's add server instance
    fromStorage.addServerInstance(ModelFactory.newServerInstanceKey(serverTemplate.getId(), "http://localhost:8080/server"));
    templateStorage.update(fromStorage);
    ServerTemplate template = templateStorage.load(serverTemplate.getId());
    assertNotNull(template);
    assertEquals(serverTemplate.getId(), template.getId());
    assertEquals(serverTemplate.getName(), template.getName());
    Collection<ServerInstanceKey> instances = template.getServerInstanceKeys();
    assertNotNull(instances);
    assertEquals(1, instances.size());
    ServerInstanceKey serverInstanceKey = instances.iterator().next();
    assertNotNull(serverInstanceKey);
    assertEquals(serverTemplate.getId(), serverInstanceKey.getServerTemplateId());
    assertEquals(serverTemplate.getId() + "@localhost:8080", serverInstanceKey.getServerName());
    assertEquals(serverTemplate.getId() + "@localhost:8080", serverInstanceKey.getServerInstanceId());
    assertEquals("http://localhost:8080/server", serverInstanceKey.getUrl());
    Collection<ContainerSpec> containerSpecs = template.getContainersSpec();
    assertNotNull(containerSpecs);
    assertEquals(2, containerSpecs.size());
    Iterator<ContainerSpec> iterator = containerSpecs.iterator();
    // first container spec...
    ContainerSpec spec = iterator.next();
    assertNotNull(spec);
    assertEquals(containerSpec.getId(), spec.getId());
    assertEquals(containerSpec.getReleasedId(), spec.getReleasedId());
    assertEquals(containerSpec.getServerTemplateKey().getId(), spec.getServerTemplateKey().getId());
    assertEquals(containerSpec.getServerTemplateKey().getName(), spec.getServerTemplateKey().getName());
    assertEquals(containerSpec.getConfigs().size(), spec.getConfigs().size());
    assertTrue(spec.getConfigs().containsKey(Capability.RULE));
    assertTrue(spec.getConfigs().containsKey(Capability.PROCESS));
    RuleConfig ruleConfig = (RuleConfig) spec.getConfigs().get(Capability.RULE);
    assertNotNull(ruleConfig);
    assertEquals(this.ruleConfig.getPollInterval(), ruleConfig.getPollInterval());
    assertEquals(this.ruleConfig.getScannerStatus(), ruleConfig.getScannerStatus());
    ProcessConfig processConfig = (ProcessConfig) spec.getConfigs().get(Capability.PROCESS);
    assertNotNull(processConfig);
    assertEquals(this.processConfig.getKBase(), processConfig.getKBase());
    assertEquals(this.processConfig.getKSession(), processConfig.getKSession());
    assertEquals(this.processConfig.getMergeMode(), processConfig.getMergeMode());
    assertEquals(this.processConfig.getRuntimeStrategy(), processConfig.getRuntimeStrategy());
    // second container spec
    spec = iterator.next();
    assertNotNull(spec);
    assertEquals(newContainerSpec.getId(), spec.getId());
    assertEquals(newContainerSpec.getReleasedId(), spec.getReleasedId());
    assertEquals(newContainerSpec.getServerTemplateKey().getId(), spec.getServerTemplateKey().getId());
    assertEquals(newContainerSpec.getServerTemplateKey().getName(), spec.getServerTemplateKey().getName());
    assertEquals(newContainerSpec.getConfigs().size(), spec.getConfigs().size());
}
Also used : ServerTemplateKey(org.kie.server.controller.api.model.spec.ServerTemplateKey) ProcessConfig(org.kie.server.controller.api.model.spec.ProcessConfig) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) ContainerSpec(org.kie.server.controller.api.model.spec.ContainerSpec) ReleaseId(org.kie.server.api.model.ReleaseId) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) RuleConfig(org.kie.server.controller.api.model.spec.RuleConfig) Test(org.junit.Test)

Example 22 with ServerInstanceKey

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

the class RemotePresenter method onInstanceUpdate.

public void onInstanceUpdate(@Observes final ServerInstanceUpdated serverInstanceUpdated) {
    if (serverInstanceUpdated != null && serverInstanceUpdated.getServerInstance() != null) {
        final ServerInstanceKey updatedServerInstanceKey = toKey(serverInstanceUpdated.getServerInstance());
        if (serverInstanceKey != null && serverInstanceKey.getServerInstanceId().equals(updatedServerInstanceKey.getServerInstanceId())) {
            serverInstanceKey = updatedServerInstanceKey;
            loadContent(serverInstanceUpdated.getServerInstance().getContainers());
        }
    } else {
        logger.warn("Illegal event argument.");
    }
}
Also used : ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey)

Example 23 with ServerInstanceKey

use of org.kie.server.controller.api.model.runtime.ServerInstanceKey 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 24 with ServerInstanceKey

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

the class ServerManagementBrowserPresenterTest method testOnSelectedServerInstance.

@Test
public void testOnSelectedServerInstance() {
    final RemotePresenter.View remoteView = mock(RemotePresenter.View.class);
    when(remotePresenter.getView()).thenReturn(remoteView);
    presenter.onSelected(new ServerInstanceSelected(new ServerInstanceKey()));
    verify(view).setContent(remoteView);
}
Also used : RemotePresenter(org.kie.workbench.common.screens.server.management.client.remote.RemotePresenter) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ServerInstanceSelected(org.kie.workbench.common.screens.server.management.client.events.ServerInstanceSelected) Test(org.junit.Test)

Example 25 with ServerInstanceKey

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

the class ServerManagementBrowserPresenterTest method testOnContainerUpdateFailed.

@Test
public void testOnContainerUpdateFailed() {
    when(view.getErrorMessage(ClientContainerRuntimeOperation.START_CONTAINER, 2)).thenReturn("Error");
    presenter.onContainerUpdate(new ContainerUpdateEvent(mock(ServerTemplateKey.class), mock(ContainerSpec.class), new ArrayList<ServerInstanceKey>() {

        {
            add(mock(ServerInstanceKey.class));
            add(mock(ServerInstanceKey.class));
        }
    }, ContainerRuntimeState.OFFLINE, ContainerRuntimeOperation.START_CONTAINER));
    verify(notification).fire(new NotificationEvent("Error", NotificationEvent.NotificationType.ERROR));
}
Also used : ArrayList(java.util.ArrayList) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) ServerInstanceKey(org.kie.server.controller.api.model.runtime.ServerInstanceKey) ContainerUpdateEvent(org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent) Test(org.junit.Test)

Aggregations

ServerInstanceKey (org.kie.server.controller.api.model.runtime.ServerInstanceKey)32 Test (org.junit.Test)28 Container (org.kie.server.controller.api.model.runtime.Container)12 ContainerSpec (org.kie.server.controller.api.model.spec.ContainerSpec)11 ServerTemplate (org.kie.server.controller.api.model.spec.ServerTemplate)11 ReleaseId (org.kie.server.api.model.ReleaseId)7 ServerInstanceSelected (org.kie.workbench.common.screens.server.management.client.events.ServerInstanceSelected)7 ArrayList (java.util.ArrayList)5 ServerTemplateKey (org.kie.server.controller.api.model.spec.ServerTemplateKey)5 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)5 ServerTemplateMigration (org.kie.workbench.common.screens.server.management.backend.storage.migration.ServerTemplateMigration)4 ContainerUpdateEvent (org.kie.workbench.common.screens.server.management.model.ContainerUpdateEvent)4 Path (org.uberfire.java.nio.file.Path)4 Message (org.kie.server.api.model.Message)3 ServerInstanceDeleted (org.kie.server.controller.api.model.events.ServerInstanceDeleted)3 ProcessConfig (org.kie.server.controller.api.model.spec.ProcessConfig)3 RuleConfig (org.kie.server.controller.api.model.spec.RuleConfig)3 ContainerSpecSelected (org.kie.workbench.common.screens.server.management.client.events.ContainerSpecSelected)3 Command (org.uberfire.mvp.Command)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2