ResourceManager { public ResourcesDetails getResourceDetails(String accountId) throws NotFoundException, ServerException { final List<ProvidedResources> resources = new ArrayList<>(); for (ResourcesProvider resourcesProvider : resourcesProviders) { resources.addAll(resourcesProvider.getResources(accountId)); } final List<Resource> allResources = resources .stream() .flatMap(providedResources -> providedResources.getResources().stream()) .collect(Collectors.toList()); return new ResourcesDetailsImpl( accountId, resources, new ArrayList<>(resourceAggregator.aggregateByType(allResources).values())); } @Inject  ResourceManager(
      ResourceAggregator resourceAggregator,
      Set<ResourcesProvider> resourcesProviders,
      Set<ResourceUsageTracker> usageTrackers,
      AccountManager accountManager,
      Map<String, AvailableResourcesProvider> accountTypeToAvailableResourcesProvider,
      DefaultAvailableResourcesProvider defaultAvailableResourcesProvider); List<? extends Resource> getTotalResources(String accountId); List<? extends Resource> getAvailableResources(String accountId); List<? extends Resource> getUsedResources(String accountId); void checkResourcesAvailability(String accountId, List<? extends Resource> resources); ResourcesDetails getResourceDetails(String accountId);  }
@Test( expectedExceptions = NotFoundException.class, expectedExceptionsMessageRegExp = "Account with specified id was not found") public void testThrowsNotFoundExceptionWhenAccountWithGivenIdWasNotFound() throws Exception { when(resourcesProvider.getResources(eq(ACCOUNT_ID))) .thenThrow(new NotFoundException("Account with specified id was not found")); resourceManager.getResourceDetails(ACCOUNT_ID); }