@Test public void testDefaultApplicationSlaIsCreatedIfNotDefined() throws Exception { when(applicationStore.findByName(DEFAULT_APPLICATION)).thenReturn( Observable.error(new NotFoundException(ApplicationSLA.class, "missing")) ); when(applicationStore.create(any())).thenReturn(Observable.empty()); new ManagementSubsystemInitializer(configuration, applicationStore).enterActiveMode(); verify(applicationStore, times(1)).findByName(DEFAULT_APPLICATION); verify(applicationStore, times(1)).create(any()); }
@Activator public Observable<Void> enterActiveMode() { logger.info("Entering active mode"); try { ApplicationSLA defaultSLA = applicationSlaStore.findByName(ApplicationSlaManagementService.DEFAULT_APPLICATION).toBlocking().first(); logger.info("Default application SLA configured as: {}", defaultSLA); } catch (NotFoundException e) { ApplicationSLA defaultSLA = buildDefaultApplicationSLA(configuration); applicationSlaStore.create(defaultSLA).toBlocking().firstOrDefault(null); logger.info("Default application SLA not defined; creating it according to the provided configuration: {}", defaultSLA); } return Observable.empty(); }
ManagementSubsystemInitializer { @Activator public Observable<Void> enterActiveMode() { logger.info("Entering active mode"); try { ApplicationSLA defaultSLA = applicationSlaStore.findByName(ApplicationSlaManagementService.DEFAULT_APPLICATION).toBlocking().first(); logger.info("Default application SLA configured as: {}", defaultSLA); } catch (NotFoundException e) { ApplicationSLA defaultSLA = buildDefaultApplicationSLA(configuration); applicationSlaStore.create(defaultSLA).toBlocking().firstOrDefault(null); logger.info("Default application SLA not defined; creating it according to the provided configuration: {}", defaultSLA); } return Observable.empty(); } }
ManagementSubsystemInitializer { @Activator public Observable<Void> enterActiveMode() { logger.info("Entering active mode"); try { ApplicationSLA defaultSLA = applicationSlaStore.findByName(ApplicationSlaManagementService.DEFAULT_APPLICATION).toBlocking().first(); logger.info("Default application SLA configured as: {}", defaultSLA); } catch (NotFoundException e) { ApplicationSLA defaultSLA = buildDefaultApplicationSLA(configuration); applicationSlaStore.create(defaultSLA).toBlocking().firstOrDefault(null); logger.info("Default application SLA not defined; creating it according to the provided configuration: {}", defaultSLA); } return Observable.empty(); } @Inject  ManagementSubsystemInitializer(CapacityManagementConfiguration configuration,
                                          ApplicationSlaStore applicationSlaStore); }
ManagementSubsystemInitializer { @Activator public Observable<Void> enterActiveMode() { logger.info("Entering active mode"); try { ApplicationSLA defaultSLA = applicationSlaStore.findByName(ApplicationSlaManagementService.DEFAULT_APPLICATION).toBlocking().first(); logger.info("Default application SLA configured as: {}", defaultSLA); } catch (NotFoundException e) { ApplicationSLA defaultSLA = buildDefaultApplicationSLA(configuration); applicationSlaStore.create(defaultSLA).toBlocking().firstOrDefault(null); logger.info("Default application SLA not defined; creating it according to the provided configuration: {}", defaultSLA); } return Observable.empty(); } @Inject  ManagementSubsystemInitializer(CapacityManagementConfiguration configuration,
                                          ApplicationSlaStore applicationSlaStore); @Activator Observable<Void> enterActiveMode(); }
ManagementSubsystemInitializer { @Activator public Observable<Void> enterActiveMode() { logger.info("Entering active mode"); try { ApplicationSLA defaultSLA = applicationSlaStore.findByName(ApplicationSlaManagementService.DEFAULT_APPLICATION).toBlocking().first(); logger.info("Default application SLA configured as: {}", defaultSLA); } catch (NotFoundException e) { ApplicationSLA defaultSLA = buildDefaultApplicationSLA(configuration); applicationSlaStore.create(defaultSLA).toBlocking().firstOrDefault(null); logger.info("Default application SLA not defined; creating it according to the provided configuration: {}", defaultSLA); } return Observable.empty(); } @Inject  ManagementSubsystemInitializer(CapacityManagementConfiguration configuration,
                                          ApplicationSlaStore applicationSlaStore); @Activator Observable<Void> enterActiveMode();  }