@Test public void testRemovePersistsApplicationSlaAndUpdatesCapacityRequirements() throws Exception { ApplicationSLA myApp = ApplicationSlaSample.CriticalSmall.build(); when(storage.findAll()).thenReturn(Observable.just(myApp)); when(storage.remove(myApp.getAppName())).thenReturn(Observable.empty()); ObservableRecorder<Void> cpmRecorder = ObservableRecorder.newRecorder(Observable.empty()); when(capacityMonitoringService.refresh()).thenReturn(cpmRecorder.getObservable()); slaManagementService.removeApplicationSLA(myApp.getAppName()).toBlocking().firstOrDefault(null); testScheduler.triggerActions(); verify(capacityMonitoringService, times(1)).refresh(); assertThat(cpmRecorder.numberOfFinishedSubscriptions()).isEqualTo(1); }
@Override public Observable<Void> removeApplicationSLA(String applicationName) { if (applicationName.equals(DEFAULT_APPLICATION)) { return Observable.error(new IllegalArgumentException(DEFAULT_APPLICATION + " cannot be removed")); } return storage.remove(applicationName).doOnCompleted(() -> capacityMonitoringService.refresh().subscribe()); }
DefaultApplicationSlaManagementService implements ApplicationSlaManagementService { @Override public Observable<Void> removeApplicationSLA(String applicationName) { if (applicationName.equals(DEFAULT_APPLICATION)) { return Observable.error(new IllegalArgumentException(DEFAULT_APPLICATION + " cannot be removed")); } return storage.remove(applicationName).doOnCompleted(() -> capacityMonitoringService.refresh().subscribe()); } }
DefaultApplicationSlaManagementService implements ApplicationSlaManagementService { @Override public Observable<Void> removeApplicationSLA(String applicationName) { if (applicationName.equals(DEFAULT_APPLICATION)) { return Observable.error(new IllegalArgumentException(DEFAULT_APPLICATION + " cannot be removed")); } return storage.remove(applicationName).doOnCompleted(() -> capacityMonitoringService.refresh().subscribe()); } @Inject  DefaultApplicationSlaManagementService(CapacityMonitoringService capacityMonitoringService,
                                                  ApplicationSlaStore storage,
                                                  ManagementSubsystemInitializer initializer); }
DefaultApplicationSlaManagementService implements ApplicationSlaManagementService { @Override public Observable<Void> removeApplicationSLA(String applicationName) { if (applicationName.equals(DEFAULT_APPLICATION)) { return Observable.error(new IllegalArgumentException(DEFAULT_APPLICATION + " cannot be removed")); } return storage.remove(applicationName).doOnCompleted(() -> capacityMonitoringService.refresh().subscribe()); } @Inject  DefaultApplicationSlaManagementService(CapacityMonitoringService capacityMonitoringService,
                                                  ApplicationSlaStore storage,
                                                  ManagementSubsystemInitializer initializer); @Override Collection<ApplicationSLA> getApplicationSLAs(); @Override Collection<ApplicationSLA> getApplicationSLAsForScheduler(String schedulerName); @Override Optional<ApplicationSLA> findApplicationSLA(String applicationName); @Override ApplicationSLA getApplicationSLA(String applicationName); @Override Observable<Void> addApplicationSLA(ApplicationSLA applicationSLA); @Override Observable<Void> removeApplicationSLA(String applicationName); }
DefaultApplicationSlaManagementService implements ApplicationSlaManagementService { @Override public Observable<Void> removeApplicationSLA(String applicationName) { if (applicationName.equals(DEFAULT_APPLICATION)) { return Observable.error(new IllegalArgumentException(DEFAULT_APPLICATION + " cannot be removed")); } return storage.remove(applicationName).doOnCompleted(() -> capacityMonitoringService.refresh().subscribe()); } @Inject  DefaultApplicationSlaManagementService(CapacityMonitoringService capacityMonitoringService,
                                                  ApplicationSlaStore storage,
                                                  ManagementSubsystemInitializer initializer); @Override Collection<ApplicationSLA> getApplicationSLAs(); @Override Collection<ApplicationSLA> getApplicationSLAsForScheduler(String schedulerName); @Override Optional<ApplicationSLA> findApplicationSLA(String applicationName); @Override ApplicationSLA getApplicationSLA(String applicationName); @Override Observable<Void> addApplicationSLA(ApplicationSLA applicationSLA); @Override Observable<Void> removeApplicationSLA(String applicationName);  }