DefaultApplicationSlaManagementService implements ApplicationSlaManagementService { @Override public Optional<ApplicationSLA> findApplicationSLA(String applicationName) { try { return Optional.ofNullable(storage.findByName(applicationName).toBlocking().firstOrDefault(null)); } catch (Exception e) { return Optional.empty(); } } @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);  }
@Test public void testFindApplicationByName() { ApplicationSLA myApp = ApplicationSlaSample.CriticalSmall.build(); when(storage.findByName(myApp.getAppName())).thenReturn(Observable.just(myApp)); Optional<ApplicationSLA> existing = slaManagementService.findApplicationSLA(myApp.getAppName()); assertThat(existing).hasValueSatisfying(v -> assertThat(v.getAppName()).isEqualTo(myApp.getAppName())); Optional<ApplicationSLA> absent = slaManagementService.findApplicationSLA("absent"); assertThat(absent).isEmpty(); }