use of org.uberfire.preferences.shared.PreferenceScope in project kie-wb-common by kiegroup.
the class DefaultAdminPageHelperTest method preferencesShouldBeSavedOnGlobalScopeWhenUserHasPermissionAndEnabledTest.
@Test
public void preferencesShouldBeSavedOnGlobalScopeWhenUserHasPermissionAndEnabledTest() {
final PreferenceScope globalScope = mock(PreferenceScope.class);
doReturn(globalScope).when(scopeFactory).createScope(GuvnorPreferenceScopes.GLOBAL);
doReturn(true).when(authorizationManager).authorize(eq(WorkbenchFeatures.EDIT_GLOBAL_PREFERENCES), any());
defaultAdminPageHelper.setup(true, true, true);
verify(adminPage, times(3)).addPreference(anyString(), anyString(), anyString(), anyString(), anyString(), any(PreferenceScope.class), eq(AdminPageOptions.WITH_BREADCRUMBS));
verify(adminPage, times(3)).addPreference(anyString(), anyString(), anyString(), anyString(), anyString(), eq(globalScope), eq(AdminPageOptions.WITH_BREADCRUMBS));
}
use of org.uberfire.preferences.shared.PreferenceScope in project kie-wb-common by kiegroup.
the class WorkbenchPreferenceScopeResolutionStrategiesImplTest method getInfoTest.
@Test
public void getInfoTest() {
final PreferenceScopeResolutionStrategyInfo scopeInfo = scopeResolutionStrategies.getUserInfoFor(null, null);
final List<PreferenceScope> order = scopeInfo.order();
assertEquals(2, order.size());
final PreferenceScope firstScope = order.get(0);
assertEquals("user", firstScope.type());
assertEquals("admin", firstScope.key());
final PreferenceScope secondScope = order.get(1);
assertEquals("global", secondScope.type());
assertEquals("global", secondScope.key());
final PreferenceScope defaultScope = scopeInfo.defaultScope();
assertEquals("user", defaultScope.type());
assertEquals("admin", defaultScope.key());
}
use of org.uberfire.preferences.shared.PreferenceScope in project kie-wb-common by kiegroup.
the class WorkbenchPreferenceScopeResolutionStrategiesImplTest method getInfoWithScopeTest.
@Test
public void getInfoWithScopeTest() {
final PreferenceScopeResolutionStrategyInfo scopeInfo = scopeResolutionStrategies.getUserInfoFor(WorkbenchPreferenceScopes.PROJECT, "my-project");
final List<PreferenceScope> order = scopeInfo.order();
assertEquals(3, order.size());
final PreferenceScope firstScope = order.get(0);
assertEquals("user", firstScope.type());
assertEquals("admin", firstScope.key());
assertEquals("project", firstScope.childScope().type());
assertEquals("my-project", firstScope.childScope().key());
final PreferenceScope secondScope = order.get(1);
assertEquals("user", secondScope.type());
assertEquals("admin", secondScope.key());
final PreferenceScope threeScope = order.get(2);
assertEquals("global", threeScope.type());
assertEquals("global", threeScope.key());
final PreferenceScope defaultScope = scopeInfo.defaultScope();
assertEquals("user", defaultScope.type());
assertEquals("admin", defaultScope.key());
assertEquals("project", defaultScope.childScope().type());
assertEquals("my-project", defaultScope.childScope().key());
}
use of org.uberfire.preferences.shared.PreferenceScope in project kie-wb-common by kiegroup.
the class WorkbenchPreferenceScopeResolutionStrategyTest method orderWithProjectScopeTest.
@Test
public void orderWithProjectScopeTest() {
PreferenceScope userScope = scopesFactory.createScope(WorkbenchPreferenceScopes.USER);
PreferenceScope projectScope = scopesFactory.createScope(WorkbenchPreferenceScopes.PROJECT, "my-project");
PreferenceScope userProjectScope = scopesFactory.createScope(userScope, projectScope);
defaultPreferenceScopeResolutionStrategy = new WorkbenchPreferenceScopeResolutionStrategy(scopesFactory, userProjectScope);
final List<PreferenceScope> order = defaultPreferenceScopeResolutionStrategy.getInfo().order();
assertEquals(3, order.size());
final PreferenceScope firstScope = order.get(0);
assertEquals("user", firstScope.type());
assertEquals("admin", firstScope.key());
assertEquals("project", firstScope.childScope().type());
assertEquals("my-project", firstScope.childScope().key());
final PreferenceScope secondScope = order.get(1);
assertEquals("user", secondScope.type());
assertEquals("admin", secondScope.key());
final PreferenceScope threeScope = order.get(2);
assertEquals("global", threeScope.type());
assertEquals("global", threeScope.key());
final PreferenceScope defaultScope = defaultPreferenceScopeResolutionStrategy.getInfo().defaultScope();
assertEquals("user", defaultScope.type());
assertEquals("admin", defaultScope.key());
assertEquals("project", defaultScope.childScope().type());
assertEquals("my-project", defaultScope.childScope().key());
}
Aggregations