Search in sources :

Example 1 with ProfilePreferences

use of org.kie.workbench.common.profile.api.preferences.ProfilePreferences in project kie-wb-common by kiegroup.

the class HomePresenterTest method setup.

@Before
public void setup() {
    doReturn(mock(ShortcutPresenter.class)).when(shortcutPresenters).get();
    executeParametrizedCommandWith(0, new ProfilePreferences(Profile.FULL)).when(profilePreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class));
    modelProvider = new HomeModelProvider() {

        @Override
        public void initialize(Runnable done) {
            done.run();
        }

        @Override
        public HomeModel get(ProfilePreferences profilePreferences) {
            final HomeModel homeModel = new HomeModel("welcome", "description", "backgroundImageUrl");
            homeModel.addShortcut(ModelUtils.makeShortcut("iconCss1", "heading1", "subHeading1", mock(Command.class)));
            homeModel.addShortcut(ModelUtils.makeShortcut("iconCss2", "heading2", "subHeading2", mock(Command.class), "resourceId2", ResourceType.UNKNOWN, ResourceAction.READ));
            homeModel.addShortcut(ModelUtils.makeShortcut("iconCss3", "heading3", "subHeading3", mock(Command.class), "perspectiveId"));
            return homeModel;
        }
    };
    presenter = new HomePresenter(view, translationService, modelProvider, shortcutPresenters, profilePreferences);
}
Also used : HomeModelProvider(org.kie.workbench.common.screens.home.model.HomeModelProvider) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) HomeModel(org.kie.workbench.common.screens.home.model.HomeModel) ShortcutPresenter(org.kie.workbench.common.screens.home.client.widgets.shortcut.ShortcutPresenter) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) ProfilePreferences(org.kie.workbench.common.profile.api.preferences.ProfilePreferences) Before(org.junit.Before)

Example 2 with ProfilePreferences

use of org.kie.workbench.common.profile.api.preferences.ProfilePreferences in project kie-wb-common by kiegroup.

the class AddAssetScreenTest method setUp.

@Before
public void setUp() {
    this.addAssetScreen = spy(new AddAssetScreen(this.view, this.ts, this.resourceHandlerManager, this.categoriesManagerCache, this.newAssetHandlerCardWidgets, this.libraryConstants, this.categoryUtils, this.libraryPlaces, this.profilePreferences));
    doNothing().when(addAssetScreen).update();
    executeParametrizedCommandWith(0, new ProfilePreferences(Profile.FULL)).when(profilePreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class));
}
Also used : ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) ProfilePreferences(org.kie.workbench.common.profile.api.preferences.ProfilePreferences) Before(org.junit.Before)

Example 3 with ProfilePreferences

use of org.kie.workbench.common.profile.api.preferences.ProfilePreferences in project kie-wb-common by kiegroup.

the class AddAssetScreenTest method testOnOpenProfileFilter.

@Test
public void testOnOpenProfileFilter() {
    NewResourceHandler rhFull = mockResourceHandler(Profile.FULL);
    NewResourceHandler rhDroolsPlanner = mockResourceHandler(Profile.PLANNER_AND_RULES);
    NewResourceHandler rhAll = mockResourceHandler(Profile.values());
    addAssetScreen.initialize();
    doReturn(Arrays.asList(rhFull, rhDroolsPlanner, rhAll)).when(resourceHandlerManager).getNewResourceHandlers();
    addAssetScreen.onOpen();
    assertEquals(2, addAssetScreen.newResourceHandlers.size());
    assertTrue(addAssetScreen.newResourceHandlers.contains(rhFull));
    assertTrue(addAssetScreen.newResourceHandlers.contains(rhAll));
    assertTrue(!addAssetScreen.newResourceHandlers.contains(rhDroolsPlanner));
    executeParametrizedCommandWith(0, new ProfilePreferences(Profile.PLANNER_AND_RULES)).when(profilePreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class));
    addAssetScreen.onOpen();
    assertEquals(2, addAssetScreen.newResourceHandlers.size());
    assertTrue(!addAssetScreen.newResourceHandlers.contains(rhFull));
    assertTrue(addAssetScreen.newResourceHandlers.contains(rhAll));
    assertTrue(addAssetScreen.newResourceHandlers.contains(rhDroolsPlanner));
}
Also used : NewResourceHandler(org.kie.workbench.common.widgets.client.handlers.NewResourceHandler) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) ProfilePreferences(org.kie.workbench.common.profile.api.preferences.ProfilePreferences) Test(org.junit.Test)

Example 4 with ProfilePreferences

use of org.kie.workbench.common.profile.api.preferences.ProfilePreferences in project kie-wb-common by kiegroup.

the class AddAssetScreenTest method testProfileFilter.

@Test
public void testProfileFilter() {
    NewResourceHandler rhFull = mockResourceHandler(Profile.FULL);
    NewResourceHandler rhDroolsPlanner = mockResourceHandler(Profile.PLANNER_AND_RULES);
    NewResourceHandler rhAll = mockResourceHandler(Profile.values());
    addAssetScreen.initialize();
    doReturn(Arrays.asList(rhFull, rhDroolsPlanner, rhAll)).when(resourceHandlerManager).getNewResourceHandlers();
    List<NewResourceHandler> filteredResourceHandlers = this.addAssetScreen.filterNewResourceHandlers(new ProfilePreferences(Profile.FULL));
    assertEquals(2, filteredResourceHandlers.size());
    filteredResourceHandlers = this.addAssetScreen.filterNewResourceHandlers(new ProfilePreferences(Profile.PLANNER_AND_RULES));
    assertEquals(2, filteredResourceHandlers.size());
    doReturn(Arrays.asList(rhFull, rhDroolsPlanner)).when(resourceHandlerManager).getNewResourceHandlers();
    filteredResourceHandlers = this.addAssetScreen.filterNewResourceHandlers(new ProfilePreferences(Profile.PLANNER_AND_RULES));
    assertEquals(1, filteredResourceHandlers.size());
    assertEquals(Profile.PLANNER_AND_RULES, filteredResourceHandlers.get(0).getProfiles().get(0));
    filteredResourceHandlers = this.addAssetScreen.filterNewResourceHandlers(new ProfilePreferences(Profile.FULL));
    assertEquals(1, filteredResourceHandlers.size());
    assertEquals(Profile.FULL, filteredResourceHandlers.get(0).getProfiles().get(0));
}
Also used : NewResourceHandler(org.kie.workbench.common.widgets.client.handlers.NewResourceHandler) ProfilePreferences(org.kie.workbench.common.profile.api.preferences.ProfilePreferences) Test(org.junit.Test)

Example 5 with ProfilePreferences

use of org.kie.workbench.common.profile.api.preferences.ProfilePreferences in project kie-wb-common by kiegroup.

the class DefaultWorkbenchFeaturesMenusHelperTest method setup.

@Before
public void setup() {
    mockConstants();
    mockDefaultPerspective();
    mockRoles();
    mockGroups();
    mockIocManager();
    executeParametrizedCommandWith(0, new ProfilePreferences(Profile.FULL)).when(profilePreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class));
}
Also used : ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) ProfilePreferences(org.kie.workbench.common.profile.api.preferences.ProfilePreferences) Before(org.junit.Before)

Aggregations

ProfilePreferences (org.kie.workbench.common.profile.api.preferences.ProfilePreferences)5 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)4 Before (org.junit.Before)3 Test (org.junit.Test)2 NewResourceHandler (org.kie.workbench.common.widgets.client.handlers.NewResourceHandler)2 ShortcutPresenter (org.kie.workbench.common.screens.home.client.widgets.shortcut.ShortcutPresenter)1 HomeModel (org.kie.workbench.common.screens.home.model.HomeModel)1 HomeModelProvider (org.kie.workbench.common.screens.home.model.HomeModelProvider)1 Command (org.uberfire.mvp.Command)1