Search in sources :

Example 1 with CallerMock

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

the class WorkItemDefinitionClientRegistryTest method init.

@Before
@SuppressWarnings("unchecked")
public void init() {
    when(sessionManager.getCurrentSession()).thenReturn(session);
    when(session.getSessionUUID()).thenReturn(SESSION_ID);
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getRoot()).thenReturn(root);
    when(service.search(eq(root))).thenReturn(Collections.singleton(DEF));
    when(registry.items()).thenReturn(Collections.singleton(DEF));
    when(registry.get(eq(WID_ID))).thenReturn(DEF);
    CallerMock<WorkItemDefinitionService> serviceCaller = new CallerMock<>(service);
    WorkItemDefinitionMetadataRegistry metadataRegistry = new WorkItemDefinitionMetadataRegistry();
    this.tested = new WorkItemDefinitionClientRegistry(sessionManager, serviceCaller, () -> registry, registryInstanceDestroyer, metadataRegistry);
    this.tested.init();
}
Also used : WorkItemDefinitionService(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionService) WorkItemDefinitionMetadataRegistry(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionMetadataRegistry) CallerMock(org.uberfire.mocks.CallerMock) Before(org.junit.Before)

Example 2 with CallerMock

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

the class DataModelerScreenPresenterTestBase method setUp.

@Before
public void setUp() throws Exception {
    promises = new SyncPromises();
    when(alertsButtonMenuItemBuilder.build()).thenReturn(alertsButtonMenuItem);
    testObject1 = DataModelerEditorsTestHelper.createTestObject1();
    testModel = DataModelerEditorsTestHelper.createTestModel(testObject1);
    testErrors = createTestErrors();
    testPackages = createTestPackages();
    testAnnotationDefs = createTestAnnotations();
    testTypeDefs = createTestPropertyTypes();
    presenter = new DataModelerScreenPresenter(view, sessionInfo) {

        {
            docks = DataModelerScreenPresenterTestBase.this.docks;
            kieView = mock(KieEditorWrapperView.class);
            this.versionRecordManager = DataModelerScreenPresenterTestBase.this.versionRecordManager;
            this.authorizationManager = DataModelerScreenPresenterTestBase.this.authorizationManager;
            overviewWidget = mock(OverviewWidgetPresenter.class);
            savePopUpPresenter = DataModelerScreenPresenterTestBase.this.savePopUpPresenter;
            renamePopUpPresenter = DataModelerScreenPresenterTestBase.this.renamePopUpPresenter;
            copyPopUpPresenter = DataModelerScreenPresenterTestBase.this.copyPopUpPresenter;
            javaSourceEditor = DataModelerScreenPresenterTestBase.this.javaSourceEditor;
            dataModelerEvent = DataModelerScreenPresenterTestBase.this.dataModelerEvent;
            unpublishMessagesEvent = DataModelerScreenPresenterTestBase.this.unpublishMessagesEvent;
            publishBatchMessagesEvent = DataModelerScreenPresenterTestBase.this.publishBatchMessagesEvent;
            lockRequired = DataModelerScreenPresenterTestBase.this.lockRequired;
            dataModelerFocusEvent = DataModelerScreenPresenterTestBase.this.dataModelerFocusEvent;
            notification = DataModelerScreenPresenterTestBase.this.notificationEvent;
            modelerService = new CallerMock<>(DataModelerScreenPresenterTestBase.this.modelerService);
            validationPopup = DataModelerScreenPresenterTestBase.this.validationPopup;
            validationService = new CallerMock<>(DataModelerScreenPresenterTestBase.this.validationService);
            validatorService = DataModelerScreenPresenterTestBase.this.validatorService;
            javaFileNameValidator = DataModelerScreenPresenterTestBase.this.javaFileNameValidator;
            resourceType = DataModelerScreenPresenterTestBase.this.resourceType;
            dataModelerWBContext = DataModelerScreenPresenterTestBase.this.dataModelerWBContext;
            fileMenuBuilder = DataModelerScreenPresenterTestBase.this.fileMenuBuilder;
            workbenchContext = DataModelerScreenPresenterTestBase.this.workbenchContext;
            projectController = DataModelerScreenPresenterTestBase.this.projectController;
            deletePopUpPresenter = DataModelerScreenPresenterTestBase.this.deletePopUpPresenter;
            showAssetUsagesDisplayer = DataModelerScreenPresenterTestBase.this.showAssetUsages;
            alertsButtonMenuItemBuilder = DataModelerScreenPresenterTestBase.this.alertsButtonMenuItemBuilder;
            promises = DataModelerScreenPresenterTestBase.this.promises;
            uiStarted = true;
            when(workbenchContext.getActiveOrganizationalUnit()).thenReturn(Optional.empty());
            when(workbenchContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
            when(workbenchContext.getActiveModule()).thenReturn(Optional.empty());
            when(workbenchContext.getActiveRepositoryRoot()).thenReturn(Optional.empty());
            when(workbenchContext.getActivePackage()).thenReturn(Optional.empty());
        }

        @Override
        public void addDownloadMenuItem(final FileMenuBuilder fileMenuBuilder) {
        // Do nothing.
        }

        @Override
        protected void selectEditorTab() {
            // emulates the ui action produced by the tabs events.
            onEditTabSelected();
        }

        @Override
        protected void selectOverviewTab() {
            // emulates the ui action produced by the tabs events.
            onOverviewSelected();
        }

        @Override
        public void setSelectedTab(int index) {
            // emulates the ui action produced by the tabs events.
            switch(index) {
                case 0:
                    onEditTabSelected();
                    break;
                case 1:
                    onOverviewSelected();
                    break;
                case 2:
                    onSourceTabSelected();
                    break;
                default:
                    throw new RuntimeException("Tab index out of bounds: " + index);
            }
        }
    };
}
Also used : BasicFileMenuBuilder(org.uberfire.ext.editor.commons.client.menu.BasicFileMenuBuilder) FileMenuBuilder(org.kie.workbench.common.widgets.client.menu.FileMenuBuilder) SyncPromises(org.uberfire.promise.SyncPromises) CallerMock(org.uberfire.mocks.CallerMock) Before(org.junit.Before)

Example 3 with CallerMock

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

the class NewWorkspaceProjectWizardTest method setUp.

@Before
public void setUp() throws Exception {
    preferences = new HashMap<>();
    ApplicationPreferences.setUp(preferences);
    pomDefaultOptions = new KiePOMDefaultOptions();
    PlaceManager placeManager = mock(PlaceManager.class);
    wizard = new NewWorkspaceProjectWizardExtended(new CallerMock<>(projectService), placeManager, notificationEventEvent, pomWizardPage, busyIndicatorView, conflictingRepositoriesPopup, moduleContext, view, pomDefaultOptions);
    when(moduleContext.getActiveOrganizationalUnit()).thenReturn(Optional.empty());
    when(moduleContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    when(moduleContext.getActiveModule()).thenReturn(Optional.empty());
    when(moduleContext.getActiveRepositoryRoot()).thenReturn(Optional.empty());
    when(moduleContext.getActivePackage()).thenReturn(Optional.empty());
    wizard.setupPages();
}
Also used : PlaceManager(org.uberfire.client.mvp.PlaceManager) KiePOMDefaultOptions(org.kie.workbench.common.screens.projecteditor.client.util.KiePOMDefaultOptions) CallerMock(org.uberfire.mocks.CallerMock) Before(org.junit.Before)

Example 4 with CallerMock

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

the class KSessionSelectorTest method setUp.

@Before
public void setUp() throws Exception {
    kieModule = spy(new KieModule());
    when(kieModule.getKModuleXMLPath()).thenReturn(kmodulePath);
    kModule = new KModuleModel();
    kModule.getKBases().put("kbase1", getKBase("kbase1", "ksession1"));
    kModule.getKBases().put("kbase2", getKBase("kbase2", "ksession2", "ksession3"));
    kModule.getKBases().put("kbase3", getKBase("kbase3"));
    view = mock(KSessionSelectorView.class);
    when(kieModuleService.resolveModule(path)).thenReturn(kieModule);
    when(kModuleService.load(kmodulePath)).thenReturn(kModule);
    selector = new KSessionSelector(view, new CallerMock<>(kieModuleService), new CallerMock<>(kModuleService));
}
Also used : KieModule(org.kie.workbench.common.services.shared.project.KieModule) CallerMock(org.uberfire.mocks.CallerMock) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Before(org.junit.Before)

Example 5 with CallerMock

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

the class LibraryToolbarPresenterTest method setup.

@Before
public void setup() {
    presenter = new LibraryToolbarPresenter(projectContext, new CallerMock<>(projectService), libraryPlaces, view, placeManager);
    selectedOrganizationalUnit = mock(OrganizationalUnit.class);
    final Branch masterBranch = new Branch("master", mock(Path.class));
    selectedRepository = mock(Repository.class);
    selectedRepositoryBranches = new ArrayList<>();
    selectedRepositoryBranches.add(masterBranch);
    when(selectedRepository.getDefaultBranch()).thenReturn(Optional.of(masterBranch));
    when(selectedRepository.getBranches()).thenReturn(selectedRepositoryBranches);
    doReturn("repository1").when(selectedRepository).getAlias();
    callback = mock(Command.class);
    doReturn(Optional.of(selectedOrganizationalUnit)).when(projectContext).getActiveOrganizationalUnit();
    doReturn(Optional.of(new WorkspaceProject(selectedOrganizationalUnit, selectedRepository, masterBranch, mock(Module.class)))).when(projectContext).getActiveWorkspaceProject();
    when(projectContext.getActiveModule()).thenReturn(Optional.empty());
    when(projectContext.getActiveRepositoryRoot()).thenReturn(Optional.empty());
    when(projectContext.getActivePackage()).thenReturn(Optional.empty());
}
Also used : Path(org.uberfire.backend.vfs.Path) Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Command(org.uberfire.mvp.Command) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Module(org.guvnor.common.services.project.model.Module) CallerMock(org.uberfire.mocks.CallerMock) Before(org.junit.Before)

Aggregations

CallerMock (org.uberfire.mocks.CallerMock)16 Before (org.junit.Before)14 KieModule (org.kie.workbench.common.services.shared.project.KieModule)3 Command (org.uberfire.mvp.Command)3 Module (org.guvnor.common.services.project.model.Module)2 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)2 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)2 Repository (org.guvnor.structure.repositories.Repository)2 Test (org.junit.Test)2 SchemaMetadata (org.kie.workbench.common.screens.datasource.management.metadata.SchemaMetadata)2 Path (org.uberfire.backend.vfs.Path)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Event (javax.enterprise.event.Event)1 ProvisioningClientValidationService (org.guvnor.ala.ui.client.validation.ProvisioningClientValidationService)1 OpenShiftClientValidationService (org.guvnor.ala.ui.openshift.client.validation.OpenShiftClientValidationService)1 BuildResults (org.guvnor.common.services.project.builder.model.BuildResults)1 WorkspaceProjectContext (org.guvnor.common.services.project.client.context.WorkspaceProjectContext)1 ProjectController (org.guvnor.common.services.project.client.security.ProjectController)1