Search in sources :

Example 1 with SessionInfoMock

use of org.uberfire.mocks.SessionInfoMock in project kie-wb-common by kiegroup.

the class WorkbenchPreferenceScopeResolutionStrategyTest method setup.

@Before
public void setup() {
    final SessionInfoMock sessionInfo = new SessionInfoMock("admin");
    final UsernameProvider usernameProvider = mock(UsernameProvider.class);
    doReturn(sessionInfo.getIdentity().getIdentifier()).when(usernameProvider).get();
    scopeTypes = new WorkbenchPreferenceScopeTypes(usernameProvider);
    scopesFactory = new PreferenceScopeFactoryImpl(scopeTypes);
    defaultPreferenceScopeResolutionStrategy = new WorkbenchPreferenceScopeResolutionStrategy(scopesFactory, null, null);
}
Also used : SessionInfoMock(org.uberfire.mocks.SessionInfoMock) PreferenceScopeFactoryImpl(org.uberfire.preferences.shared.impl.PreferenceScopeFactoryImpl) UsernameProvider(org.uberfire.preferences.shared.UsernameProvider) Before(org.junit.Before)

Example 2 with SessionInfoMock

use of org.uberfire.mocks.SessionInfoMock in project kie-wb-common by kiegroup.

the class WorkbenchPreferenceScopeTypesTest method setup.

@Before
public void setup() {
    final SessionInfo sessionInfo = new SessionInfoMock();
    final UsernameProvider usernameProvider = mock(UsernameProvider.class);
    doReturn(sessionInfo.getIdentity().getIdentifier()).when(usernameProvider).get();
    scopeTypes = new WorkbenchPreferenceScopeTypes(usernameProvider);
}
Also used : SessionInfoMock(org.uberfire.mocks.SessionInfoMock) SessionInfo(org.uberfire.rpc.SessionInfo) UsernameProvider(org.uberfire.preferences.shared.UsernameProvider) Before(org.junit.Before)

Example 3 with SessionInfoMock

use of org.uberfire.mocks.SessionInfoMock in project kie-wb-common by kiegroup.

the class ContributorsManagementPresenterTest method setup.

@Before
public void setup() {
    organizationalUnitServiceCaller = new CallerMock<>(organizationalUnitService);
    libraryServiceCaller = new CallerMock<>(libraryService);
    sessionInfo = new SessionInfoMock();
    List<SocialUser> allUsers = new ArrayList<>();
    allUsers.add(userA);
    allUsers.add(userB);
    allUsers.add(userC);
    doReturn(allUsers).when(libraryService).getAllUsers();
    doReturn(contributorsManagementListItemPresenter).when(contributorsManagementListItemPresenters).get();
    presenter = new ContributorsManagementPresenter(view, organizationalUnitServiceCaller, libraryServiceCaller, contributorsManagementListItemPresenters, sessionInfo);
}
Also used : SessionInfoMock(org.uberfire.mocks.SessionInfoMock) SocialUser(org.ext.uberfire.social.activities.model.SocialUser) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 4 with SessionInfoMock

use of org.uberfire.mocks.SessionInfoMock in project kie-wb-common by kiegroup.

the class LibraryServiceImplTest method setup.

@Before
public void setup() {
    ous = Arrays.asList(ou1, ou2);
    when(ouService.getOrganizationalUnits()).thenReturn(ous);
    when(ou1.getIdentifier()).thenReturn("ou1");
    when(ou2.getIdentifier()).thenReturn("ou2");
    when(repo1.getAlias()).thenReturn("repo_created_by_user");
    final List<Branch> repo1Branches = Arrays.asList(makeBranch("repo1-branch1", repo1.getAlias()), makeBranch("repo1-branch2", repo1.getAlias()));
    when(repo1.getBranches()).thenReturn(repo1Branches);
    when(repo1.getBranch(anyString())).then(inv -> repo1Branches.stream().filter(b -> b.getName().equals(inv.getArgument(0, String.class))).findFirst());
    when(repo2Default.getAlias()).thenReturn("ou2-repo-alias");
    final List<Branch> repo2Branches = Collections.singletonList(makeBranch("repo2-branch1", repo2Default.getAlias()));
    when(repo2Default.getBranches()).thenReturn(repo2Branches);
    when(ou2.getRepositories()).thenReturn(Arrays.asList(repo1, repo2Default));
    when(indexOracle.isIndexed(any())).thenReturn(true);
    modulesMock = new HashSet<>();
    modulesMock.add(mock(Module.class));
    modulesMock.add(mock(Module.class));
    modulesMock.add(mock(Module.class));
    when(preferences.getOrganizationalUnitPreferences()).thenReturn(spy(new LibraryOrganizationalUnitPreferences()));
    when(preferences.getProjectPreferences()).thenReturn(spy(new LibraryProjectPreferences()));
    sessionInfo = new SessionInfoMock();
    libraryService = spy(new LibraryServiceImpl(ouService, refactoringQueryService, preferences, authorizationManager, sessionInfo, explorerServiceHelper, projectService, moduleService, examplesService, ioService, userManagerService, indexOracle, spaceConfigStorageRegistry, clusterService, archetypeService));
}
Also used : LibraryOrganizationalUnitPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryOrganizationalUnitPreferences) SessionInfoMock(org.uberfire.mocks.SessionInfoMock) Branch(org.guvnor.structure.repositories.Branch) Module(org.guvnor.common.services.project.model.Module) LibraryProjectPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryProjectPreferences) Before(org.junit.Before)

Example 5 with SessionInfoMock

use of org.uberfire.mocks.SessionInfoMock in project kie-wb-common by kiegroup.

the class SpacesScreenServiceImplTest method before.

@Before
public void before() {
    sessionInfo = new SessionInfoMock();
    spacesScreenService = spy(new SpacesScreenServiceImpl(organizationalUnitService, sessionInfo));
}
Also used : SessionInfoMock(org.uberfire.mocks.SessionInfoMock) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)9 SessionInfoMock (org.uberfire.mocks.SessionInfoMock)9 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)3 UsernameProvider (org.uberfire.preferences.shared.UsernameProvider)3 ArrayList (java.util.ArrayList)2 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)2 PreferenceScopeFactoryImpl (org.uberfire.preferences.shared.impl.PreferenceScopeFactoryImpl)2 SyncPromises (org.uberfire.promise.SyncPromises)2 Space (org.uberfire.spaces.Space)2 SocialUser (org.ext.uberfire.social.activities.model.SocialUser)1 Module (org.guvnor.common.services.project.model.Module)1 Branch (org.guvnor.structure.repositories.Branch)1 Repository (org.guvnor.structure.repositories.Repository)1 LibraryInfo (org.kie.workbench.common.screens.library.api.LibraryInfo)1 LibraryOrganizationalUnitPreferences (org.kie.workbench.common.screens.library.api.preferences.LibraryOrganizationalUnitPreferences)1 LibraryProjectPreferences (org.kie.workbench.common.screens.library.api.preferences.LibraryProjectPreferences)1 SessionInfo (org.uberfire.rpc.SessionInfo)1