@Test public void shouldLoadApplications() throws Exception { Resource applicationResource = mock(Resource.class); given(applicationResource.getInputStream()).willReturn(mock(InputStream.class)); given(applicationDiscovery.discoverApplications()).willReturn(Collections.singletonList(applicationResource)); ApplicationContent applicationContent = new ApplicationContent(); given(applicationReader.read(applicationResource.getInputStream())).willReturn(applicationContent); List<ApplicationContent> applicationContents = applicationService.loadApplications(); assertThat(applicationContents).containsExactly(applicationContent); }
public List<ApplicationContent> loadApplications() { List<ApplicationContent> applications = new ArrayList<>(); List<Resource> applicationResources = applicationDiscovery.discoverApplications(); try { for (Resource applicationResource : applicationResources) { try (InputStream inputStream = applicationResource.getInputStream()) { applications.add(applicationReader.read(inputStream)); } } } catch (IOException e) { throw new AppliationLoadException("Unable to load application resource", e); } return applications; }
ApplicationService { public List<ApplicationContent> loadApplications() { List<ApplicationContent> applications = new ArrayList<>(); List<Resource> applicationResources = applicationDiscovery.discoverApplications(); try { for (Resource applicationResource : applicationResources) { try (InputStream inputStream = applicationResource.getInputStream()) { applications.add(applicationReader.read(inputStream)); } } } catch (IOException e) { throw new AppliationLoadException("Unable to load application resource", e); } return applications; } }
ApplicationService { public List<ApplicationContent> loadApplications() { List<ApplicationContent> applications = new ArrayList<>(); List<Resource> applicationResources = applicationDiscovery.discoverApplications(); try { for (Resource applicationResource : applicationResources) { try (InputStream inputStream = applicationResource.getInputStream()) { applications.add(applicationReader.read(inputStream)); } } } catch (IOException e) { throw new AppliationLoadException("Unable to load application resource", e); } return applications; } ApplicationService(ApplicationDiscovery applicationDiscovery,
                              ApplicationReader applicationReader); }
ApplicationService { public List<ApplicationContent> loadApplications() { List<ApplicationContent> applications = new ArrayList<>(); List<Resource> applicationResources = applicationDiscovery.discoverApplications(); try { for (Resource applicationResource : applicationResources) { try (InputStream inputStream = applicationResource.getInputStream()) { applications.add(applicationReader.read(inputStream)); } } } catch (IOException e) { throw new AppliationLoadException("Unable to load application resource", e); } return applications; } ApplicationService(ApplicationDiscovery applicationDiscovery,
                              ApplicationReader applicationReader); List<ApplicationContent> loadApplications(); }
ApplicationService { public List<ApplicationContent> loadApplications() { List<ApplicationContent> applications = new ArrayList<>(); List<Resource> applicationResources = applicationDiscovery.discoverApplications(); try { for (Resource applicationResource : applicationResources) { try (InputStream inputStream = applicationResource.getInputStream()) { applications.add(applicationReader.read(inputStream)); } } } catch (IOException e) { throw new AppliationLoadException("Unable to load application resource", e); } return applications; } ApplicationService(ApplicationDiscovery applicationDiscovery,
                              ApplicationReader applicationReader); List<ApplicationContent> loadApplications();  }