@Test public void testStopScanner() { List<Container> fakeResult = new ArrayList<Container>(); fakeResult.add(container); when(kieServerInstanceManager.stopScanner(any(ServerTemplate.class), any(ContainerSpec.class))).thenReturn(fakeResult); ruleCapabilitiesService.stopScanner(containerSpec); verify(kieServerInstanceManager, times(1)).stopScanner(any(ServerTemplate.class), any(ContainerSpec.class)); ServerTemplate updated = specManagementService.getServerTemplate(serverTemplate.getId()); Collection<ContainerSpec> containerSpecs = updated.getContainersSpec(); assertNotNull(containerSpecs); assertEquals(1, containerSpecs.size()); ContainerSpec updatedContainer = containerSpecs.iterator().next(); assertNotNull(updatedContainer); ContainerConfig ruleConfig = updatedContainer.getConfigs().get(Capability.RULE); assertNotNull(ruleConfig); assertTrue(ruleConfig instanceof RuleConfig); RuleConfig ruleCg = (RuleConfig) ruleConfig; assertEquals(KieScannerStatus.STOPPED, ruleCg.getScannerStatus()); assertNull(ruleCg.getPollInterval()); }
@Override public void stopScanner(final ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId()); } ContainerConfig containerConfig = containerSpec.getConfigs().get(Capability.RULE); if (containerConfig == null) { containerConfig = new RuleConfig(); containerSpec.getConfigs().put(Capability.RULE, containerConfig); } if(((RuleConfig) containerConfig).getScannerStatus() == KieScannerStatus.STOPPED){ return; } ((RuleConfig) containerConfig).setPollInterval(null); ((RuleConfig) containerConfig).setScannerStatus(KieScannerStatus.STOPPED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.stopScanner(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }
RuleCapabilitiesServiceImpl implements RuleCapabilitiesService { @Override public void stopScanner(final ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId()); } ContainerConfig containerConfig = containerSpec.getConfigs().get(Capability.RULE); if (containerConfig == null) { containerConfig = new RuleConfig(); containerSpec.getConfigs().put(Capability.RULE, containerConfig); } if(((RuleConfig) containerConfig).getScannerStatus() == KieScannerStatus.STOPPED){ return; } ((RuleConfig) containerConfig).setPollInterval(null); ((RuleConfig) containerConfig).setScannerStatus(KieScannerStatus.STOPPED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.stopScanner(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); } }
RuleCapabilitiesServiceImpl implements RuleCapabilitiesService { @Override public void stopScanner(final ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId()); } ContainerConfig containerConfig = containerSpec.getConfigs().get(Capability.RULE); if (containerConfig == null) { containerConfig = new RuleConfig(); containerSpec.getConfigs().put(Capability.RULE, containerConfig); } if(((RuleConfig) containerConfig).getScannerStatus() == KieScannerStatus.STOPPED){ return; } ((RuleConfig) containerConfig).setPollInterval(null); ((RuleConfig) containerConfig).setScannerStatus(KieScannerStatus.STOPPED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.stopScanner(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }  }
RuleCapabilitiesServiceImpl implements RuleCapabilitiesService { @Override public void stopScanner(final ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId()); } ContainerConfig containerConfig = containerSpec.getConfigs().get(Capability.RULE); if (containerConfig == null) { containerConfig = new RuleConfig(); containerSpec.getConfigs().put(Capability.RULE, containerConfig); } if(((RuleConfig) containerConfig).getScannerStatus() == KieScannerStatus.STOPPED){ return; } ((RuleConfig) containerConfig).setPollInterval(null); ((RuleConfig) containerConfig).setScannerStatus(KieScannerStatus.STOPPED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.stopScanner(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }  @Override void scanNow(final ContainerSpecKey containerSpecKey); @Override void startScanner(final ContainerSpecKey containerSpecKey,
                             final Long interval); @Override void stopScanner(final ContainerSpecKey containerSpecKey); @Override void upgradeContainer(final ContainerSpecKey containerSpecKey,
                                 ReleaseId releaseId); KieServerTemplateStorage getTemplateStorage(); void setTemplateStorage(KieServerTemplateStorage templateStorage); KieServerInstanceManager getKieServerInstanceManager(); void setKieServerInstanceManager(KieServerInstanceManager kieServerInstanceManager); NotificationService getNotificationService(); void setNotificationService(NotificationService notificationService); }
RuleCapabilitiesServiceImpl implements RuleCapabilitiesService { @Override public void stopScanner(final ContainerSpecKey containerSpecKey) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId()); } ContainerConfig containerConfig = containerSpec.getConfigs().get(Capability.RULE); if (containerConfig == null) { containerConfig = new RuleConfig(); containerSpec.getConfigs().put(Capability.RULE, containerConfig); } if(((RuleConfig) containerConfig).getScannerStatus() == KieScannerStatus.STOPPED){ return; } ((RuleConfig) containerConfig).setPollInterval(null); ((RuleConfig) containerConfig).setScannerStatus(KieScannerStatus.STOPPED); templateStorage.update(serverTemplate); List<Container> containers = kieServerInstanceManager.stopScanner(serverTemplate, containerSpec); notificationService.notify(serverTemplate, containerSpec, containers); }  @Override void scanNow(final ContainerSpecKey containerSpecKey); @Override void startScanner(final ContainerSpecKey containerSpecKey,
                             final Long interval); @Override void stopScanner(final ContainerSpecKey containerSpecKey); @Override void upgradeContainer(final ContainerSpecKey containerSpecKey,
                                 ReleaseId releaseId); KieServerTemplateStorage getTemplateStorage(); void setTemplateStorage(KieServerTemplateStorage templateStorage); KieServerInstanceManager getKieServerInstanceManager(); void setKieServerInstanceManager(KieServerInstanceManager kieServerInstanceManager); NotificationService getNotificationService(); void setNotificationService(NotificationService notificationService);  }