@Test public void testUpdateContainerConfigWhenContainerConfigIsNotAProcessConfigNeitherARuleConfig() { final SpecManagementServiceImpl specManagementService = spy((SpecManagementServiceImpl) this.specManagementService); final Capability capability = Capability.PROCESS; final ContainerConfig containerConfig = mock(ContainerConfig.class); final ServerTemplate serverTemplate = mock(ServerTemplate.class); final ContainerSpec containerSpec = mock(ContainerSpec.class); final List<?> expectedContainers = new ArrayList<>(); final List<Container> actualContainers = specManagementService.updateContainerConfig(capability, containerConfig, serverTemplate, containerSpec); assertEquals(expectedContainers, actualContainers); }
@Override public synchronized void updateContainerConfig(final String serverTemplateId, final String containerSpecId, final Capability capability, final ContainerConfig containerConfig) { final ServerTemplate serverTemplate = templateStorage.load(serverTemplateId); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + serverTemplateId); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecId + " within server template with id " + serverTemplateId); } final List<Container> affectedContainers = updateContainerConfig(capability, containerConfig, serverTemplate, containerSpec); if (affectedContainers.isEmpty()) { logInfo("Update of container configuration resulted in no changes to containers running on kie-servers"); } affectedContainers.forEach(ac -> { logDebug("Container {} on server {} was affected by a change in the scanner", ac.getContainerSpecId(), ac.getServerInstanceKey()); }); containerSpec.getConfigs().put(capability, containerConfig); templateStorage.update(serverTemplate); notificationService.notify(new ServerTemplateUpdated(serverTemplate)); }
SpecManagementServiceImpl implements SpecManagementService { @Override public synchronized void updateContainerConfig(final String serverTemplateId, final String containerSpecId, final Capability capability, final ContainerConfig containerConfig) { final ServerTemplate serverTemplate = templateStorage.load(serverTemplateId); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + serverTemplateId); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecId + " within server template with id " + serverTemplateId); } final List<Container> affectedContainers = updateContainerConfig(capability, containerConfig, serverTemplate, containerSpec); if (affectedContainers.isEmpty()) { logInfo("Update of container configuration resulted in no changes to containers running on kie-servers"); } affectedContainers.forEach(ac -> { logDebug("Container {} on server {} was affected by a change in the scanner", ac.getContainerSpecId(), ac.getServerInstanceKey()); }); containerSpec.getConfigs().put(capability, containerConfig); templateStorage.update(serverTemplate); notificationService.notify(new ServerTemplateUpdated(serverTemplate)); } }
SpecManagementServiceImpl implements SpecManagementService { @Override public synchronized void updateContainerConfig(final String serverTemplateId, final String containerSpecId, final Capability capability, final ContainerConfig containerConfig) { final ServerTemplate serverTemplate = templateStorage.load(serverTemplateId); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + serverTemplateId); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecId + " within server template with id " + serverTemplateId); } final List<Container> affectedContainers = updateContainerConfig(capability, containerConfig, serverTemplate, containerSpec); if (affectedContainers.isEmpty()) { logInfo("Update of container configuration resulted in no changes to containers running on kie-servers"); } affectedContainers.forEach(ac -> { logDebug("Container {} on server {} was affected by a change in the scanner", ac.getContainerSpecId(), ac.getServerInstanceKey()); }); containerSpec.getConfigs().put(capability, containerConfig); templateStorage.update(serverTemplate); notificationService.notify(new ServerTemplateUpdated(serverTemplate)); }  }
SpecManagementServiceImpl implements SpecManagementService { @Override public synchronized void updateContainerConfig(final String serverTemplateId, final String containerSpecId, final Capability capability, final ContainerConfig containerConfig) { final ServerTemplate serverTemplate = templateStorage.load(serverTemplateId); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + serverTemplateId); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecId + " within server template with id " + serverTemplateId); } final List<Container> affectedContainers = updateContainerConfig(capability, containerConfig, serverTemplate, containerSpec); if (affectedContainers.isEmpty()) { logInfo("Update of container configuration resulted in no changes to containers running on kie-servers"); } affectedContainers.forEach(ac -> { logDebug("Container {} on server {} was affected by a change in the scanner", ac.getContainerSpecId(), ac.getServerInstanceKey()); }); containerSpec.getConfigs().put(capability, containerConfig); templateStorage.update(serverTemplate); notificationService.notify(new ServerTemplateUpdated(serverTemplate)); }  @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 updateContainerConfig(final String serverTemplateId, final String containerSpecId, final Capability capability, final ContainerConfig containerConfig) { final ServerTemplate serverTemplate = templateStorage.load(serverTemplateId); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + serverTemplateId); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecId + " within server template with id " + serverTemplateId); } final List<Container> affectedContainers = updateContainerConfig(capability, containerConfig, serverTemplate, containerSpec); if (affectedContainers.isEmpty()) { logInfo("Update of container configuration resulted in no changes to containers running on kie-servers"); } affectedContainers.forEach(ac -> { logDebug("Container {} on server {} was affected by a change in the scanner", ac.getContainerSpecId(), ac.getServerInstanceKey()); }); containerSpec.getConfigs().put(capability, containerConfig); templateStorage.update(serverTemplate); notificationService.notify(new ServerTemplateUpdated(serverTemplate)); }  @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);  }