@Test public void shouldUpdateSystemScope() { Scope openId = new Scope(); openId.setId("1"); openId.setSystem(false); openId.setKey("openid"); Scope phone = new Scope(); phone.setId("2"); phone.setSystem(true); phone.setKey("phone"); phone.setDiscovery(false); Scope email = new Scope(); email.setId("3"); email.setSystem(true); email.setKey("email"); email.setDiscovery(true); when(scopeService.findByDomainAndKey(eq(DOMAIN_ID), anyString())).thenReturn(Maybe.empty()); when(scopeService.findByDomainAndKey(DOMAIN_ID, "openid")).thenReturn(Maybe.just(openId)); when(scopeService.findByDomainAndKey(DOMAIN_ID, "phone")).thenReturn(Maybe.just(phone)); when(scopeService.findByDomainAndKey(DOMAIN_ID, "email")).thenReturn(Maybe.just(email)); when(scopeService.create(anyString(),any(NewSystemScope.class))).thenReturn(Single.just(new Scope())); when(scopeService.update(anyString(), anyString(), any(UpdateSystemScope.class))).thenReturn(Single.just(new Scope())); assertTrue(openIDScopeUpgrader.upgrade()); verify(scopeService, times(io.gravitee.am.common.oidc.Scope.values().length-3)).create(anyString(), any(NewSystemScope.class)); verify(scopeService, times(2)).update(anyString(), anyString(), any(UpdateSystemScope.class)); }
private boolean shouldUpdateSystemScope(Optional<Scope> optScope, io.gravitee.am.common.oidc.Scope systemScope) { return !optScope.get().isSystem() || optScope.get().isDiscovery() != systemScope.isDiscovery(); }
OpenIDScopeUpgrader implements Upgrader, Ordered { private boolean shouldUpdateSystemScope(Optional<Scope> optScope, io.gravitee.am.common.oidc.Scope systemScope) { return !optScope.get().isSystem() || optScope.get().isDiscovery() != systemScope.isDiscovery(); } }
OpenIDScopeUpgrader implements Upgrader, Ordered { private boolean shouldUpdateSystemScope(Optional<Scope> optScope, io.gravitee.am.common.oidc.Scope systemScope) { return !optScope.get().isSystem() || optScope.get().isDiscovery() != systemScope.isDiscovery(); }  }
OpenIDScopeUpgrader implements Upgrader, Ordered { private boolean shouldUpdateSystemScope(Optional<Scope> optScope, io.gravitee.am.common.oidc.Scope systemScope) { return !optScope.get().isSystem() || optScope.get().isDiscovery() != systemScope.isDiscovery(); }  @Override boolean upgrade(); @Override int getOrder(); }
OpenIDScopeUpgrader implements Upgrader, Ordered { private boolean shouldUpdateSystemScope(Optional<Scope> optScope, io.gravitee.am.common.oidc.Scope systemScope) { return !optScope.get().isSystem() || optScope.get().isDiscovery() != systemScope.isDiscovery(); }  @Override boolean upgrade(); @Override int getOrder();  }