DefaultAvailableCapacityService implements AvailableCapacityService { @Override public Optional<ResourceDimension> totalCapacityOf(Tier tier) { return Optional.ofNullable(availableCapacity.get(tier)); } @Inject  DefaultAvailableCapacityService(CapacityManagementConfiguration configuration,
                                           ServerInfoResolver serverInfoResolver,
                                           AgentManagementService agentManagementService,
                                           Registry registry); @VisibleForTesting  DefaultAvailableCapacityService(CapacityManagementConfiguration configuration,
                                    ServerInfoResolver serverInfoResolver,
                                    AgentManagementService agentManagementService,
                                    Registry registry,
                                    Scheduler scheduler); @Activator void enterActiveMode(); @PreDestroy void shutdown(); @Override Optional<ResourceDimension> totalCapacityOf(Tier tier);  }
@Test public void testCapacityComputationCorrectness() { testScheduler.triggerActions(); Optional<ResourceDimension> capacity = availableCapacityService.totalCapacityOf(Tier.Critical); assertThat(capacity).isPresent(); ResourceDimension criticalExpected = dimensionOf(AwsInstanceType.M4_XLarge, CRITICAL_INSTANCE_COUNT); assertThat(capacity).contains(criticalExpected); }