@Test public void getContainersByContainerSpec_throwsRuntimeException_whenServerTemplateNotFound() { final String templateId = "this_template_does_NOT_exist"; expectedException.expect(RuntimeException.class); expectedException.expectMessage(containsString("No server template found for id " + templateId)); runtimeManagementServiceCDI.getContainersByContainerSpec(templateId, "dummy_container_spec_id"); }
@Override public ContainerSpecData getContainersByContainerSpec(final String serverTemplateId, final String containerSpecId) { final ServerTemplate serverTemplate = specManagementService.getServerTemplate(serverTemplateId); if (serverTemplate == null) { throw new RuntimeException("Server template with id " + serverTemplateId + " not found"); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId); if (containerSpec == null) { throw new RuntimeException("Container with id " + containerSpecId + " not found"); } final ContainerList containerList = service.getContainers(serverTemplate, containerSpec); final List<Container> containers = Arrays.asList(containerList.getContainers()); return new ContainerSpecData(containerSpec, containers); }
RuntimeManagementServiceCDI implements RuntimeManagementService { @Override public ContainerSpecData getContainersByContainerSpec(final String serverTemplateId, final String containerSpecId) { final ServerTemplate serverTemplate = specManagementService.getServerTemplate(serverTemplateId); if (serverTemplate == null) { throw new RuntimeException("Server template with id " + serverTemplateId + " not found"); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId); if (containerSpec == null) { throw new RuntimeException("Container with id " + containerSpecId + " not found"); } final ContainerList containerList = service.getContainers(serverTemplate, containerSpec); final List<Container> containers = Arrays.asList(containerList.getContainers()); return new ContainerSpecData(containerSpec, containers); } }
RuntimeManagementServiceCDI implements RuntimeManagementService { @Override public ContainerSpecData getContainersByContainerSpec(final String serverTemplateId, final String containerSpecId) { final ServerTemplate serverTemplate = specManagementService.getServerTemplate(serverTemplateId); if (serverTemplate == null) { throw new RuntimeException("Server template with id " + serverTemplateId + " not found"); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId); if (containerSpec == null) { throw new RuntimeException("Container with id " + containerSpecId + " not found"); } final ContainerList containerList = service.getContainers(serverTemplate, containerSpec); final List<Container> containers = Arrays.asList(containerList.getContainers()); return new ContainerSpecData(containerSpec, containers); }  }
RuntimeManagementServiceCDI implements RuntimeManagementService { @Override public ContainerSpecData getContainersByContainerSpec(final String serverTemplateId, final String containerSpecId) { final ServerTemplate serverTemplate = specManagementService.getServerTemplate(serverTemplateId); if (serverTemplate == null) { throw new RuntimeException("Server template with id " + serverTemplateId + " not found"); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId); if (containerSpec == null) { throw new RuntimeException("Container with id " + containerSpecId + " not found"); } final ContainerList containerList = service.getContainers(serverTemplate, containerSpec); final List<Container> containers = Arrays.asList(containerList.getContainers()); return new ContainerSpecData(containerSpec, containers); }  @Override Collection<Container> getContainersByServerInstance(final String serverTemplateId,
                                                               final String serverInstanceId); @Override ContainerSpecData getContainersByContainerSpec(final String serverTemplateId,
                                                          final String containerSpecId); }
RuntimeManagementServiceCDI implements RuntimeManagementService { @Override public ContainerSpecData getContainersByContainerSpec(final String serverTemplateId, final String containerSpecId) { final ServerTemplate serverTemplate = specManagementService.getServerTemplate(serverTemplateId); if (serverTemplate == null) { throw new RuntimeException("Server template with id " + serverTemplateId + " not found"); } final ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecId); if (containerSpec == null) { throw new RuntimeException("Container with id " + containerSpecId + " not found"); } final ContainerList containerList = service.getContainers(serverTemplate, containerSpec); final List<Container> containers = Arrays.asList(containerList.getContainers()); return new ContainerSpecData(containerSpec, containers); }  @Override Collection<Container> getContainersByServerInstance(final String serverTemplateId,
                                                               final String serverInstanceId); @Override ContainerSpecData getContainersByContainerSpec(final String serverTemplateId,
                                                          final String containerSpecId);  }