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();
}
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);
}
}
};
}
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();
}
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));
}
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());
}
Aggregations