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());
}
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.");
}
}
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();
}
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);
}
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));
}
Aggregations