Search in sources :

Example 6 with PreferenceScope

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));
}
Also used : PreferenceScope(org.uberfire.preferences.shared.PreferenceScope) Test(org.junit.Test)

Example 7 with PreferenceScope

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());
}
Also used : PreferenceScopeResolutionStrategyInfo(org.uberfire.preferences.shared.impl.PreferenceScopeResolutionStrategyInfo) PreferenceScope(org.uberfire.preferences.shared.PreferenceScope) Test(org.junit.Test)

Example 8 with PreferenceScope

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());
}
Also used : PreferenceScopeResolutionStrategyInfo(org.uberfire.preferences.shared.impl.PreferenceScopeResolutionStrategyInfo) PreferenceScope(org.uberfire.preferences.shared.PreferenceScope) Test(org.junit.Test)

Example 9 with PreferenceScope

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());
}
Also used : PreferenceScope(org.uberfire.preferences.shared.PreferenceScope) Test(org.junit.Test)

Aggregations

PreferenceScope (org.uberfire.preferences.shared.PreferenceScope)9 Test (org.junit.Test)6 PreferenceScopeResolutionStrategyInfo (org.uberfire.preferences.shared.impl.PreferenceScopeResolutionStrategyInfo)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 PreferenceScopeResolutionStrategy (org.uberfire.preferences.shared.PreferenceScopeResolutionStrategy)1 PreferenceScopeImpl (org.uberfire.preferences.shared.impl.PreferenceScopeImpl)1 InvalidPreferenceScopeException (org.uberfire.preferences.shared.impl.exception.InvalidPreferenceScopeException)1