Search in sources :

Example 11 with CallerMock

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

the class DatabaseSchemaExplorerTest method setup.

@Before
public void setup() {
    schemaExplorer = new DatabaseSchemaExplorer(view, new CallerMock<>(metadataService), translationService);
    // emulate the @PostConstruct invocation
    schemaExplorer.init();
    schemas.add(new SchemaMetadata("schema1"));
    schemas.add(new SchemaMetadata("schema2"));
}
Also used : SchemaMetadata(org.kie.workbench.common.screens.datasource.management.metadata.SchemaMetadata) CallerMock(org.uberfire.mocks.CallerMock) Before(org.junit.Before)

Example 12 with CallerMock

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

the class DatabaseObjectExplorerTest method setup.

@Before
public void setup() {
    objectExplorer = new DatabaseObjectExplorer(view, new CallerMock<>(metadataService), translationService);
    // emulate the @PostConstruct invocation.
    objectExplorer.init();
    schemas.add(new SchemaMetadata(SCHEMA_NAME));
    schemas.add(new SchemaMetadata("schema2"));
    schemas.add(new SchemaMetadata("schema3"));
    dbObjects.add(new TableMetadata(CATALOG_NAME, SCHEMA_NAME, "table1", DatabaseMetadata.TableType.TABLE.name()));
    dbObjects.add(new TableMetadata(CATALOG_NAME, SCHEMA_NAME, "table2", DatabaseMetadata.TableType.TABLE.name()));
}
Also used : TableMetadata(org.kie.workbench.common.screens.datasource.management.metadata.TableMetadata) SchemaMetadata(org.kie.workbench.common.screens.datasource.management.metadata.SchemaMetadata) CallerMock(org.uberfire.mocks.CallerMock) Before(org.junit.Before)

Example 13 with CallerMock

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

the class PopulatedLibraryScreenTest method setup.

@Before
public void setup() {
    libraryServiceCaller = new CallerMock<>(libraryService);
    libraryScreen = spy(new PopulatedLibraryScreen(view, libraryPlaces, libraryServiceCaller, projectController, projectContext, tileWidgets, addProjectButtonPresenter, projectCountUpdateEvent));
    doReturn(true).when(projectController).canCreateProjects(any());
    project1 = mockProject(PROJECT_1);
    project2 = mockProject(PROJECT_2);
    project3 = mockProject(PROJECT_3);
    final List<WorkspaceProject> projects = new ArrayList<>();
    projects.add(project1);
    projects.add(project2);
    projects.add(project3);
    when(projectContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
    when(projectContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    when(projectContext.getActiveModule()).thenReturn(Optional.empty());
    when(projectContext.getActiveRepositoryRoot()).thenReturn(Optional.empty());
    when(projectContext.getActivePackage()).thenReturn(Optional.empty());
    final LibraryInfo libraryInfo = new LibraryInfo(projects);
    doReturn(libraryInfo).when(libraryService).getLibraryInfo(organizationalUnit);
    doReturn(mock(TileWidget.View.class)).when(tileWidget).getView();
    when(tileWidgets.get()).thenAnswer((Answer<TileWidget<WorkspaceProject>>) invocationOnMock -> {
        TileWidget tile = mock(TileWidget.class);
        doReturn(mock(TileWidget.View.class)).when(tile).getView();
        doAnswer((Answer<Void>) invocationOnMock1 -> {
            when(tile.getContent()).thenReturn(invocationOnMock1.getArgument(0, WorkspaceProject.class));
            return null;
        }).when(tile).setContent(any());
        return tile;
    });
    doReturn(mock(AddProjectButtonPresenter.View.class)).when(addProjectButtonPresenter).getView();
    libraryScreen.setup();
}
Also used : TileWidget(org.kie.workbench.common.screens.library.client.widgets.common.TileWidget) CallerMock(org.uberfire.mocks.CallerMock) Space(org.uberfire.spaces.Space) Mock(org.mockito.Mock) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) RunWith(org.junit.runner.RunWith) ProjectAssetListUpdated(org.kie.workbench.common.screens.library.api.ProjectAssetListUpdated) Mockito.spy(org.mockito.Mockito.spy) ArrayList(java.util.ArrayList) LibraryPlaces(org.kie.workbench.common.screens.library.client.util.LibraryPlaces) Answer(org.mockito.stubbing.Answer) ArgumentCaptor(org.mockito.ArgumentCaptor) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Module(org.guvnor.common.services.project.model.Module) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Mockito.doReturn(org.mockito.Mockito.doReturn) Before(org.junit.Before) Event(javax.enterprise.event.Event) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) NewProjectEvent(org.guvnor.common.services.project.events.NewProjectEvent) Repository(org.guvnor.structure.repositories.Repository) Answers(org.mockito.Answers) LibraryInfo(org.kie.workbench.common.screens.library.api.LibraryInfo) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) LibraryService(org.kie.workbench.common.screens.library.api.LibraryService) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) Mockito.verify(org.mockito.Mockito.verify) RepositoryRemovedEvent(org.guvnor.structure.repositories.RepositoryRemovedEvent) List(java.util.List) Mockito.never(org.mockito.Mockito.never) Caller(org.jboss.errai.common.client.api.Caller) ProjectController(org.guvnor.common.services.project.client.security.ProjectController) AddProjectButtonPresenter(org.kie.workbench.common.screens.library.client.widgets.library.AddProjectButtonPresenter) Optional(java.util.Optional) Mockito.anyInt(org.mockito.Mockito.anyInt) Assert(org.junit.Assert) Mockito.any(org.mockito.Mockito.any) ProjectCountUpdate(org.kie.workbench.common.screens.library.api.ProjectCountUpdate) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.eq(org.mockito.Mockito.eq) Mockito.mock(org.mockito.Mockito.mock) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) LibraryInfo(org.kie.workbench.common.screens.library.api.LibraryInfo) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) TileWidget(org.kie.workbench.common.screens.library.client.widgets.common.TileWidget) Before(org.junit.Before)

Example 14 with CallerMock

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

the class ProjectClientDiagramValidatorTest method setUp.

@Before
public void setUp() {
    this.graphTestHandler = new TestingGraphMockHandler();
    treeWalkTraverseProcessor = new TreeWalkTraverseProcessorImpl();
    backendViolation = new ElementViolationImpl.Builder().setUuid(uuid).build();
    Collection<DiagramElementViolation<RuleViolation>> violations = Collections.singletonList(backendViolation);
    when(diagram.getName()).thenReturn("Test diagram");
    when(diagram.getMetadata()).thenReturn(metadata);
    when(validationService.validate(diagram)).thenReturn(violations);
    when(validators.spliterator()).thenReturn(Spliterators.emptySpliterator());
    when(graphTestHandler.getRuleManager().evaluate(any(), any())).thenReturn(mock(RuleViolations.class));
    clientDiagramValidator = new ProjectClientDiagramValidator(graphTestHandler.getDefinitionManager(), graphTestHandler.getRuleManager(), treeWalkTraverseProcessor, modelValidator, new CallerMock<>(validationService), validators);
}
Also used : ElementViolationImpl(org.kie.workbench.common.stunner.core.validation.impl.ElementViolationImpl) DiagramElementViolation(org.kie.workbench.common.stunner.core.validation.DiagramElementViolation) RuleViolations(org.kie.workbench.common.stunner.core.rule.RuleViolations) TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) TreeWalkTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl) CallerMock(org.uberfire.mocks.CallerMock) Before(org.junit.Before)

Example 15 with CallerMock

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

the class CaseDefinitionNewResourceHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    when(translationService.getDefinitionDescription(CaseDefinitionNewResourceHandler.CASE_DEFINITION)).thenReturn(DESCRIPTION);
    when(projectContext.getActiveWorkspaceProject()).thenReturn(Optional.of(workspaceProject));
    when(workspaceProject.getRootPath()).thenReturn(rootPath);
    caseHelper = new CaseHelper(new CallerMock<>(bpmnDiagramService), projectContext);
    tested = new CaseDefinitionNewResourceHandler(definitionManager, projectDiagramService, indicatorView, projectDiagramResourceType, translationService, caseHelper);
}
Also used : CaseHelper(org.kie.workbench.common.stunner.bpmn.project.client.handlers.util.CaseHelper) 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