@Test public void testStartContainer() { createServerTemplateWithContainer(); List<Container> fakeResult = new ArrayList<Container>(); fakeResult.add(container); when(kieServerInstanceManager.startContainer(any(ServerTemplate.class), any(ContainerSpec.class))).thenReturn(fakeResult); specManagementService.startContainer(containerSpec); verify(kieServerInstanceManager, times(1)).startContainer(any(ServerTemplate.class), any(ContainerSpec.class)); ServerTemplate updated = specManagementService.getServerTemplate(serverTemplate.getId()); assertNotNull(updated); ContainerSpec updatedContainer = updated.getContainerSpec(containerSpec.getId()); assertNotNull(updatedContainer); assertEquals(KieContainerStatus.STARTED, updatedContainer.getStatus()); }
@Override public synchronized void startContainer(ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId() + " within server template with id " + serverTemplate.getId()); } containerSpec.setStatus(KieContainerStatus.STARTED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.startContainer(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }
SpecManagementServiceImpl implements SpecManagementService { @Override public synchronized void startContainer(ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId() + " within server template with id " + serverTemplate.getId()); } containerSpec.setStatus(KieContainerStatus.STARTED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.startContainer(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); } }
SpecManagementServiceImpl implements SpecManagementService { @Override public synchronized void startContainer(ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId() + " within server template with id " + serverTemplate.getId()); } containerSpec.setStatus(KieContainerStatus.STARTED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.startContainer(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }  }
SpecManagementServiceImpl implements SpecManagementService { @Override public synchronized void startContainer(ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId() + " within server template with id " + serverTemplate.getId()); } containerSpec.setStatus(KieContainerStatus.STARTED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.startContainer(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }  @Override synchronized void saveContainerSpec(String serverTemplateId,
                                               ContainerSpec containerSpec); @Override synchronized void updateContainerSpec(String serverTemplateId, ContainerSpec containerSpec); @Override synchronized void updateContainerSpec(final String serverTemplateId, final String containerId, final ContainerSpec containerSpec); @Override synchronized void updateContainerSpec(String serverTemplateId, String containerId, ContainerSpec containerSpec, Boolean resetBeforeUpdate); @Override synchronized void saveServerTemplate(ServerTemplate serverTemplate); @Override ServerTemplate getServerTemplate(String serverTemplateId); @Override ServerTemplateKeyList listServerTemplateKeys(); @Override ServerTemplateList listServerTemplates(); @Override ContainerSpecList listContainerSpec(String serverTemplateId); @Override ContainerSpec getContainerInfo(String serverTemplateId,
                                          String containerId); @Override synchronized void deleteContainerSpec(String serverTemplateId,
                                                 String containerSpecId); @Override synchronized void deleteServerTemplate(String serverTemplateId); @Override synchronized void copyServerTemplate(String serverTemplateId,
                                                String newServerTemplateId,
                                                String newServerTemplateName); @Override synchronized void updateContainerConfig(final String serverTemplateId,
                                                   final String containerSpecId,
                                                   final Capability capability,
                                                   final ContainerConfig containerConfig); @Override synchronized void updateServerTemplateConfig(String serverTemplateId,
                                                        Capability capability,
                                                        ServerConfig serverTemplateConfig); @Override synchronized void startContainer(ContainerSpecKey containerSpecKey); @Override synchronized void stopContainer(ContainerSpecKey containerSpecKey); @Override synchronized void activateContainer(ContainerSpecKey containerSpecKey); @Override synchronized void deactivateContainer(ContainerSpecKey containerSpecKey); @Override void deleteServerInstance(final ServerInstanceKey serverInstanceKey); KieServerTemplateStorage getTemplateStorage(); void setTemplateStorage(KieServerTemplateStorage templateStorage); NotificationService getNotificationService(); void setNotificationService(NotificationService notificationService); KieServerInstanceManager getKieServerInstanceManager(); void setKieServerInstanceManager(KieServerInstanceManager kieServerInstanceManager); }
SpecManagementServiceImpl implements SpecManagementService { @Override public synchronized void startContainer(ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId() + " within server template with id " + serverTemplate.getId()); } containerSpec.setStatus(KieContainerStatus.STARTED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.startContainer(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }  @Override synchronized void saveContainerSpec(String serverTemplateId,
                                               ContainerSpec containerSpec); @Override synchronized void updateContainerSpec(String serverTemplateId, ContainerSpec containerSpec); @Override synchronized void updateContainerSpec(final String serverTemplateId, final String containerId, final ContainerSpec containerSpec); @Override synchronized void updateContainerSpec(String serverTemplateId, String containerId, ContainerSpec containerSpec, Boolean resetBeforeUpdate); @Override synchronized void saveServerTemplate(ServerTemplate serverTemplate); @Override ServerTemplate getServerTemplate(String serverTemplateId); @Override ServerTemplateKeyList listServerTemplateKeys(); @Override ServerTemplateList listServerTemplates(); @Override ContainerSpecList listContainerSpec(String serverTemplateId); @Override ContainerSpec getContainerInfo(String serverTemplateId,
                                          String containerId); @Override synchronized void deleteContainerSpec(String serverTemplateId,
                                                 String containerSpecId); @Override synchronized void deleteServerTemplate(String serverTemplateId); @Override synchronized void copyServerTemplate(String serverTemplateId,
                                                String newServerTemplateId,
                                                String newServerTemplateName); @Override synchronized void updateContainerConfig(final String serverTemplateId,
                                                   final String containerSpecId,
                                                   final Capability capability,
                                                   final ContainerConfig containerConfig); @Override synchronized void updateServerTemplateConfig(String serverTemplateId,
                                                        Capability capability,
                                                        ServerConfig serverTemplateConfig); @Override synchronized void startContainer(ContainerSpecKey containerSpecKey); @Override synchronized void stopContainer(ContainerSpecKey containerSpecKey); @Override synchronized void activateContainer(ContainerSpecKey containerSpecKey); @Override synchronized void deactivateContainer(ContainerSpecKey containerSpecKey); @Override void deleteServerInstance(final ServerInstanceKey serverInstanceKey); KieServerTemplateStorage getTemplateStorage(); void setTemplateStorage(KieServerTemplateStorage templateStorage); NotificationService getNotificationService(); void setNotificationService(NotificationService notificationService); KieServerInstanceManager getKieServerInstanceManager(); void setKieServerInstanceManager(KieServerInstanceManager kieServerInstanceManager);  }