@Test public void getContainersByServerInstance_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.getContainersByServerInstance(templateId, "dummy_container_spec_id"); }
@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);  }