@Test
public void testAddPersistsApplicationSlaAndUpdatesCapacityRequirements() throws Exception {

    ApplicationSLA myApp = ApplicationSlaSample.CriticalSmall.build();
    when(storage.findAll()).thenReturn(Observable.just(myApp));
    when(storage.create(myApp)).thenReturn(Observable.empty());
    ObservableRecorder<Void> cpmRecorder = ObservableRecorder.newRecorder(Observable.empty());
    when(capacityMonitoringService.refresh()).thenReturn(cpmRecorder.getObservable());
    // First add new application SLA, which will queue capacity change update
    slaManagementService.addApplicationSLA(myApp).toBlocking().firstOrDefault(null);
    // Check that capacityAllocationService is triggered correctly
    testScheduler.triggerActions();
    verify(capacityMonitoringService, times(1)).refresh();
    assertThat(cpmRecorder.numberOfFinishedSubscriptions()).isEqualTo(1);
}