@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 ); }
serverTemplate.addContainerSpec( containerSpec ); final ContainerSpec containerSpec1 = new ContainerSpec( "containerId1", "containerName1", serverTemplate, new ReleaseId( "org.kie", "container2", "1.0.0" ), KieContainerStatus.CREATING, null ); serverTemplate.addContainerSpec( containerSpec1 );
@Before public void prepare() { returnedContainers.clear(); serverTemplate = new ServerTemplate(); serverTemplate.setName("test server"); serverTemplate.setId(UUID.randomUUID().toString()); containerSpec = new ContainerSpec(); containerSpec.setId("test container"); containerSpec.setServerTemplateKey(new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName())); containerSpec.setReleasedId(new ReleaseId("org.kie", "kie-server-kjar", "1.0")); containerSpec.setStatus(KieContainerStatus.STOPPED); containerSpec.setConfigs(new HashMap<Capability, ContainerConfig>()); serverTemplate.addContainerSpec(containerSpec); this.kieServerInstanceManager = new AsyncKieServerInstanceManager(notificationService, containerUpdateEvent, executor) { @Override protected List<Container> callRemoteKieServerOperation(ServerTemplate serverTemplate, ContainerSpec containerSpec, RemoteKieServerOperation operation) { return returnedContainers; } }; this.kieServerInstanceManager.setExecutor(executor); }
@Override public synchronized void saveContainerSpec(String serverTemplateId, ContainerSpec containerSpec) { ServerTemplate serverTemplate = templateStorage.load(serverTemplateId); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + serverTemplateId); } if (serverTemplate.hasContainerSpec(containerSpec.getId())) { throw new KieServerControllerException("Server template with id " + serverTemplateId + " associated already with container " + containerSpec.getId()); } // make sure correct server template is set containerSpec.setServerTemplateKey(new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName())); serverTemplate.addContainerSpec(containerSpec); templateStorage.update(serverTemplate); notificationService.notify(new ServerTemplateUpdated(serverTemplate)); if (containerSpec.getStatus().equals(KieContainerStatus.STARTED)) { List<Container> containers = kieServerInstanceManager.startContainer(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); } }
serverTemplate1.addServerInstance(serverInstance1); serverTemplate1.addContainerSpec(containerSpec); serverTemplateId2); serverTemplate2.addServerInstance(serverInstance2); serverTemplate2.addContainerSpec(containerSpec);
serverTemplate1.addServerInstance(serverInstance1); serverTemplate1.addContainerSpec(containerSpec); serverTemplateId2); serverTemplate2.addServerInstance(serverInstance2); serverTemplate2.addContainerSpec(containerSpec);
final ServerTemplate serverTemplate = new ServerTemplate(serverTemplateId, serverTemplateId); serverTemplate.addContainerSpec(containerSpec);
final ServerTemplate serverTemplate = new ServerTemplate(serverTemplateId, serverTemplateId); serverTemplate.addContainerSpec(containerSpec);
@Override public synchronized void updateContainerSpec(final String serverTemplateId, final String containerId, final ContainerSpec containerSpec) { ServerTemplate serverTemplate = templateStorage.load(serverTemplateId); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + serverTemplateId); } if (!containerSpec.getId().equals(containerId)) { throw new KieServerControllerException("Cannot update container " + containerSpec.getId() + " on container " + containerId); } if (!serverTemplate.hasContainerSpec(containerSpec.getId())) { throw new KieServerControllerIllegalArgumentException("Server template with id " + serverTemplateId + " has no container with id " + containerSpec.getId()); } if (!serverTemplate.hasMatchingId(containerSpec.getServerTemplateKey())) { throw new KieServerControllerException("Cannot change container template key during update."); } // make sure correct server template is set containerSpec.setServerTemplateKey(new ServerTemplateKey(serverTemplate.getId(), serverTemplate.getName())); ContainerSpec currentVersion = serverTemplate.getContainerSpec(containerSpec.getId()); serverTemplate.deleteContainerSpec(currentVersion.getId()); serverTemplate.addContainerSpec(containerSpec); templateStorage.update(serverTemplate); notificationService.notify(new ServerTemplateUpdated(serverTemplate)); // in case container was started before it was update or update comes with status started update container in running servers if (currentVersion.getStatus().equals(KieContainerStatus.STARTED) || containerSpec.getStatus().equals(KieContainerStatus.STARTED)) { List<Container> containers = kieServerInstanceManager.upgradeAndStartContainer(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); } }
containerSpec.setConfigs(configs); serverTemplate.addContainerSpec(containerSpec);
template.addContainerSpec(containerSpec);
newContainerSpec.setStatus(KieContainerStatus.STARTED); fromStorage.addContainerSpec(newContainerSpec);