@Test public void shouldNotCreateScopes_domainHasScopes() { final Scope domainScope = new Scope(); domainScope.setId("domain-scope-key"); domainScope.setKey("domain-scope-key"); final String domainId = "domain-id"; final String domainName = "domain-name"; final Domain domain = new Domain(); domain.setId(domainId); domain.setName(domainName); when(domainService.findAll()).thenReturn(Single.just(Collections.singleton(domain))); when(scopeService.findByDomain(domain.getId())).thenReturn(Single.just(Collections.singleton(domainScope))); scopeUpgrader.upgrade(); verify(domainService, times(1)).findAll(); verify(scopeService, times(1)).findByDomain(domain.getId()); verify(clientService, never()).findByDomain(domain.getId()); verify(roleService, never()).findByDomain(domain.getId()); verify(scopeService, never()).create(any(String.class), any(NewScope.class)); }
@Override public boolean upgrade() { logger.info("Applying scope upgrade"); domainService.findAll() .flatMapObservable(domains -> Observable.fromIterable(domains)) .flatMapSingle(domain -> upgradeDomain(domain)) .subscribe(); return true; }
ScopeUpgrader implements Upgrader, Ordered { @Override public boolean upgrade() { logger.info("Applying scope upgrade"); domainService.findAll() .flatMapObservable(domains -> Observable.fromIterable(domains)) .flatMapSingle(domain -> upgradeDomain(domain)) .subscribe(); return true; } }
ScopeUpgrader implements Upgrader, Ordered { @Override public boolean upgrade() { logger.info("Applying scope upgrade"); domainService.findAll() .flatMapObservable(domains -> Observable.fromIterable(domains)) .flatMapSingle(domain -> upgradeDomain(domain)) .subscribe(); return true; }  }
ScopeUpgrader implements Upgrader, Ordered { @Override public boolean upgrade() { logger.info("Applying scope upgrade"); domainService.findAll() .flatMapObservable(domains -> Observable.fromIterable(domains)) .flatMapSingle(domain -> upgradeDomain(domain)) .subscribe(); return true; }  @Override boolean upgrade(); @Override int getOrder(); }
ScopeUpgrader implements Upgrader, Ordered { @Override public boolean upgrade() { logger.info("Applying scope upgrade"); domainService.findAll() .flatMapObservable(domains -> Observable.fromIterable(domains)) .flatMapSingle(domain -> upgradeDomain(domain)) .subscribe(); return true; }  @Override boolean upgrade(); @Override int getOrder();  }