@Test public void getContainersByServerInstance_returnsListOfContainers_whenInstanceWithIdExists() { final String templateId = "templateId"; final String templateName = "templateName"; final String serverInstanceId = "serverInstanceId"; ServerInstanceKey serverInstanceKey = new ServerInstanceKey(templateId, templateName, serverInstanceId, "dummyUrl"); ServerTemplate serverTemplate = new ServerTemplate( templateId, templateName, Collections.emptyList(), Collections.emptyMap(), Collections.emptyList(), Collections.singletonList(serverInstanceKey) ); final List<Container> containersInServerInstance = Arrays.asList(new Container(), new Container()); KieServerTemplateStorage templateStorageMock = createMockStorageWithOneTemplate(serverTemplate); KieServerInstanceManager instanceMangerMock = mock(KieServerInstanceManager.class); when(instanceMangerMock.getContainers(eq(serverInstanceKey))) .thenReturn(containersInServerInstance); runtimeManagementService.setTemplateStorage(templateStorageMock); runtimeManagementService.setKieServerInstanceManager(instanceMangerMock); specManagementService.setTemplateStorage(templateStorageMock); specManagementService.setKieServerInstanceManager(instanceMangerMock); Collection<Container> containers = runtimeManagementServiceCDI.getContainersByServerInstance(templateId, serverInstanceId); assertThat(containers) .as("Should return list of containers from server instance id") .hasSameSizeAs(containersInServerInstance); }
@Override public Collection<Container> getContainersByServerInstance(final String serverTemplateId, final String serverInstanceId) { final ServerTemplate serverTemplate = specManagementService.getServerTemplate(serverTemplateId); if (serverTemplate == null) { throw new RuntimeException("Server template with id " + serverTemplateId + " not found"); } return serverTemplate.getServerInstanceKeys().stream() .filter(serverInstanceKey -> serverInstanceKey.getServerInstanceId().equalsIgnoreCase(serverInstanceId)) .findFirst() .map(serverInstanceKey -> Arrays.asList(service.getContainers(serverInstanceKey).getContainers())) .orElse(Collections.emptyList()); }
RuntimeManagementServiceCDI implements RuntimeManagementService { @Override public Collection<Container> getContainersByServerInstance(final String serverTemplateId, final String serverInstanceId) { final ServerTemplate serverTemplate = specManagementService.getServerTemplate(serverTemplateId); if (serverTemplate == null) { throw new RuntimeException("Server template with id " + serverTemplateId + " not found"); } return serverTemplate.getServerInstanceKeys().stream() .filter(serverInstanceKey -> serverInstanceKey.getServerInstanceId().equalsIgnoreCase(serverInstanceId)) .findFirst() .map(serverInstanceKey -> Arrays.asList(service.getContainers(serverInstanceKey).getContainers())) .orElse(Collections.emptyList()); } }
RuntimeManagementServiceCDI implements RuntimeManagementService { @Override public Collection<Container> getContainersByServerInstance(final String serverTemplateId, final String serverInstanceId) { final ServerTemplate serverTemplate = specManagementService.getServerTemplate(serverTemplateId); if (serverTemplate == null) { throw new RuntimeException("Server template with id " + serverTemplateId + " not found"); } return serverTemplate.getServerInstanceKeys().stream() .filter(serverInstanceKey -> serverInstanceKey.getServerInstanceId().equalsIgnoreCase(serverInstanceId)) .findFirst() .map(serverInstanceKey -> Arrays.asList(service.getContainers(serverInstanceKey).getContainers())) .orElse(Collections.emptyList()); }  }
RuntimeManagementServiceCDI implements RuntimeManagementService { @Override public Collection<Container> getContainersByServerInstance(final String serverTemplateId, final String serverInstanceId) { final ServerTemplate serverTemplate = specManagementService.getServerTemplate(serverTemplateId); if (serverTemplate == null) { throw new RuntimeException("Server template with id " + serverTemplateId + " not found"); } return serverTemplate.getServerInstanceKeys().stream() .filter(serverInstanceKey -> serverInstanceKey.getServerInstanceId().equalsIgnoreCase(serverInstanceId)) .findFirst() .map(serverInstanceKey -> Arrays.asList(service.getContainers(serverInstanceKey).getContainers())) .orElse(Collections.emptyList()); }  @Override Collection<Container> getContainersByServerInstance(final String serverTemplateId,
                                                               final String serverInstanceId); @Override ContainerSpecData getContainersByContainerSpec(final String serverTemplateId,
                                                          final String containerSpecId); }
RuntimeManagementServiceCDI implements RuntimeManagementService { @Override public Collection<Container> getContainersByServerInstance(final String serverTemplateId, final String serverInstanceId) { final ServerTemplate serverTemplate = specManagementService.getServerTemplate(serverTemplateId); if (serverTemplate == null) { throw new RuntimeException("Server template with id " + serverTemplateId + " not found"); } return serverTemplate.getServerInstanceKeys().stream() .filter(serverInstanceKey -> serverInstanceKey.getServerInstanceId().equalsIgnoreCase(serverInstanceId)) .findFirst() .map(serverInstanceKey -> Arrays.asList(service.getContainers(serverInstanceKey).getContainers())) .orElse(Collections.emptyList()); }  @Override Collection<Container> getContainersByServerInstance(final String serverTemplateId,
                                                               final String serverInstanceId); @Override ContainerSpecData getContainersByContainerSpec(final String serverTemplateId,
                                                          final String containerSpecId);  }