ResourceManager { public List<? extends Resource> getTotalResources(String accountId) throws NotFoundException, ServerException { return getResourceDetails(accountId).getTotalResources(); } @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 public void testGetsAccountTotalResources() throws Exception { final List<Resource> res = ImmutableList.of( new ResourceImpl("RAM", 2048, "mb"), new ResourceImpl("timeout", 15, "minutes")); doReturn(res).when(providedResources).getResources(); List<? extends Resource> actual = resourceManager.getTotalResources(ACCOUNT_ID); assertEquals(actual.size(), res.size()); assertTrue(actual.containsAll(res)); }
@Test(expectedExceptions = NotFoundException.class) public void testThrowsNotFoundExceptionWhenResourceForGivenAccountNotFound() throws Exception { doThrow(NotFoundException.class).when(resourcesProvider).getResources(ACCOUNT_ID); resourceManager.getTotalResources(ACCOUNT_ID); }
@Test(expectedExceptions = ServerException.class) public void doThrowServerExceptionWhenErrorOccursWhileFetchingResources() throws Exception { doThrow(ServerException.class).when(resourcesProvider).getResources(ACCOUNT_ID); resourceManager.getTotalResources(ACCOUNT_ID); }