Search in sources :

Example 86 with Mock

use of org.mockito.Mock in project kie-wb-common by kiegroup.

the class DecisionServiceParametersListWidgetTest method testGetCurrentItems.

@Test
public void testGetCurrentItems() {
    final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
    final DecisionService decisionService = mock(DecisionService.class);
    final String id1 = "id1";
    final String id2 = "id2";
    final String id3 = "id3";
    final List<DMNElementReference> list = createListOfDMNElementReferenceWithIds(id1, id2, id3);
    final List<InputData> unsortedInputs = Arrays.asList(createInputDataWithId(id2), createInputDataWithId(id3), createInputDataWithId(id1));
    doReturn(value).when(widget).getValue();
    when(value.getDecisionService()).thenReturn(decisionService);
    when(decisionService.getInputData()).thenReturn(list);
    final List<InputData> sorted = widget.getCurrentItems(unsortedInputs);
    assertThat(sorted).extracting(inputData -> inputData.getId().getValue()).containsExactly(id1, id2, id3);
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) DecisionServiceParameters_Outputs(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_Outputs) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) ClientTranslationService(org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService) Mockito.doReturn(org.mockito.Mockito.doReturn) DecisionServiceParameters_EncapsulatedDecisions(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_EncapsulatedDecisions) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Mockito.doNothing(org.mockito.Mockito.doNothing) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) List(java.util.List) Stream(java.util.stream.Stream) DMNDiagramsSession(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramsSession) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Node(org.kie.workbench.common.stunner.core.graph.Node) Mockito.mock(org.mockito.Mockito.mock) GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) DecisionServiceParameters_Inputs(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_Inputs) Mockito.spy(org.mockito.Mockito.spy) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ArrayList(java.util.ArrayList) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Elemental2DomUtil(org.jboss.errai.common.client.dom.elemental2.Elemental2DomUtil) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) Before(org.junit.Before) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Mockito.verify(org.mockito.Mockito.verify) ParameterGroup(org.kie.workbench.common.dmn.client.widgets.decisionservice.parameters.parametergroup.ParameterGroup) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Mockito.never(org.mockito.Mockito.never) HTMLDivElement(elemental2.dom.HTMLDivElement) DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Assert.assertEquals(org.junit.Assert.assertEquals) DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Example 87 with Mock

use of org.mockito.Mock in project kie-wb-common by kiegroup.

the class DecisionServiceParametersListWidgetTest method testGetNewItems.

@Test
public void testGetNewItems() {
    final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
    final DecisionService decisionService = mock(DecisionService.class);
    final String id1 = "id1";
    final String id2 = "id2";
    final String id3 = "id3";
    final String newItem1 = "aaa";
    final String newItem2 = "bbb";
    final String newItem3 = "ccc";
    final String newItem4 = "ddd";
    final List<DMNElementReference> list = createListOfDMNElementReferenceWithIds(id1, id2, id3);
    final List<InputData> currentItems = Arrays.asList(createInputDataWithId(id2), createInputDataWithId(id3), createInputDataWithId(id1));
    final List<InputData> inputs = Arrays.asList(createInputDataWithId(newItem3), createInputDataWithId(newItem2), createInputDataWithId(newItem4), createInputDataWithId(newItem1));
    doReturn(value).when(widget).getValue();
    when(value.getDecisionService()).thenReturn(decisionService);
    when(decisionService.getInputData()).thenReturn(list);
    final List<InputData> result = widget.getNewItems(inputs, currentItems);
    assertThat(result).extracting(inputData -> inputData.getId().getValue()).containsExactly(newItem1, newItem2, newItem3, newItem4);
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) DecisionServiceParameters_Outputs(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_Outputs) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) ClientTranslationService(org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService) Mockito.doReturn(org.mockito.Mockito.doReturn) DecisionServiceParameters_EncapsulatedDecisions(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_EncapsulatedDecisions) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Mockito.doNothing(org.mockito.Mockito.doNothing) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) List(java.util.List) Stream(java.util.stream.Stream) DMNDiagramsSession(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramsSession) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Node(org.kie.workbench.common.stunner.core.graph.Node) Mockito.mock(org.mockito.Mockito.mock) GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) DecisionServiceParameters_Inputs(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_Inputs) Mockito.spy(org.mockito.Mockito.spy) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ArrayList(java.util.ArrayList) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Elemental2DomUtil(org.jboss.errai.common.client.dom.elemental2.Elemental2DomUtil) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) Before(org.junit.Before) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Mockito.verify(org.mockito.Mockito.verify) ParameterGroup(org.kie.workbench.common.dmn.client.widgets.decisionservice.parameters.parametergroup.ParameterGroup) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Mockito.never(org.mockito.Mockito.never) HTMLDivElement(elemental2.dom.HTMLDivElement) DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Assert.assertEquals(org.junit.Assert.assertEquals) DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Example 88 with Mock

use of org.mockito.Mock in project kie-wb-common by kiegroup.

the class BaseExpressionGridGeneralTest method testUpdateWidthOfPeers.

/*
     * Test that parent column width is updated to sum of nested columns
     * The update is forced from nested column at position indexOfColumnToUpdate
     * The default width of parent column is 100
     */
private void testUpdateWidthOfPeers(final int indexOfColumnToUpdate, final double... widthsOfNestedColumns) {
    // parent column
    final BaseExpressionGrid parentGrid = mock(BaseExpressionGrid.class);
    final GridData parentGridData = mock(GridData.class);
    when(parentGrid.getModel()).thenReturn(parentGridData);
    when(parentGrid.getExpression()).thenReturn(Optional::empty);
    final DMNGridColumn parentColumn = mockColumn(100, parentGrid);
    when(parentCell.getGridWidget()).thenReturn(parentGrid);
    when(parentGridData.getColumns()).thenReturn(Collections.singletonList(parentColumn));
    when(parentGridData.getColumnCount()).thenReturn(widthsOfNestedColumns.length);
    when(gridLayer.getGridWidgets()).thenReturn(Collections.singleton(parentGrid));
    // nested columns
    final List<DMNGridColumn> columns = Arrays.stream(widthsOfNestedColumns).mapToObj(width -> mockColumn(width, grid)).collect(Collectors.toList());
    grid.getModel().appendRow(new BaseGridRow());
    columns.stream().forEach(column -> grid.getModel().appendColumn(column));
    // force the peers width update
    columns.get(indexOfColumnToUpdate).updateWidthOfPeers();
    // assert parent width is equal to sum of nested columns widths
    final double padding = BaseExpressionGrid.DEFAULT_PADDING * 2;
    Assertions.assertThat(parentColumn.getWidth()).isEqualTo(Arrays.stream(widthsOfNestedColumns).sum() + padding);
}
Also used : DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn) TextAreaSingletonDOMElementFactory(org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextAreaSingletonDOMElementFactory) Arrays(java.util.Arrays) UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) HasCellEditorControls(org.kie.workbench.common.dmn.client.widgets.grid.controls.HasCellEditorControls) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) BaseGridColumn(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DMNGridCell(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridCell) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) Group(com.ait.lienzo.client.core.shape.Group) UUID(org.kie.workbench.common.stunner.core.util.UUID) SetTypeRefCommand(org.kie.workbench.common.dmn.client.commands.general.SetTypeRefCommand) GridLayerRedrawManager(org.uberfire.ext.wires.core.grids.client.widget.layer.impl.GridLayerRedrawManager) SetHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHeaderValueCommand) GridFactoryCommandUtils(org.kie.workbench.common.dmn.client.editors.expressions.types.GridFactoryCommandUtils) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Assertions(org.assertj.core.api.Assertions) SelectionExtension(org.uberfire.ext.wires.core.grids.client.widget.grid.selections.SelectionExtension) Mockito.doReturn(org.mockito.Mockito.doReturn) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) SetCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand) DeleteHeaderValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteHeaderValueCommand) EditableHeaderGridWidgetEditCellMouseEventHandler(org.kie.workbench.common.dmn.client.widgets.grid.handlers.EditableHeaderGridWidgetEditCellMouseEventHandler) Index(org.kie.workbench.common.stunner.core.graph.processing.index.Index) NOPDomainObject(org.kie.workbench.common.dmn.api.definition.NOPDomainObject) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) Mockito.doNothing(org.mockito.Mockito.doNothing) Collectors(java.util.stream.Collectors) DeleteCellValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteCellValueCommand) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) HasName(org.kie.workbench.common.dmn.api.definition.HasName) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) List(java.util.List) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) Point2D(com.ait.lienzo.client.core.types.Point2D) TextBoxSingletonDOMElementFactory(org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextBoxSingletonDOMElementFactory) Assert.assertFalse(org.junit.Assert.assertFalse) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) Optional(java.util.Optional) DeleteHasValueCommand(org.kie.workbench.common.dmn.client.commands.general.DeleteHasValueCommand) Node(org.kie.workbench.common.stunner.core.graph.Node) Mockito.mock(org.mockito.Mockito.mock) IntStream(java.util.stream.IntStream) SetHasValueCommand(org.kie.workbench.common.dmn.client.commands.general.SetHasValueCommand) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) CanvasCommandResultBuilder(org.kie.workbench.common.stunner.core.client.command.CanvasCommandResultBuilder) Captor(org.mockito.Captor) ExpressionEditorChanged(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorChanged) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) ArgumentCaptor(org.mockito.ArgumentCaptor) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) ReadOnlyProvider(org.kie.workbench.common.stunner.core.client.ReadOnlyProvider) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) NodeMouseEventHandler(org.uberfire.ext.wires.core.grids.client.widget.grid.NodeMouseEventHandler) Element(org.kie.workbench.common.stunner.core.graph.Element) SetComponentWidthCommand(org.kie.workbench.common.dmn.client.commands.factory.canvas.SetComponentWidthCommand) Command(org.kie.workbench.common.stunner.core.command.Command) GridColumnRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.columns.GridColumnRenderer) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) ListBoxSingletonDOMElementFactory(org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.ListBoxSingletonDOMElementFactory) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) EditableHeaderMetaData(org.kie.workbench.common.dmn.client.widgets.grid.columns.EditableHeaderMetaData) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Mockito.verify(org.mockito.Mockito.verify) Graph(org.kie.workbench.common.stunner.core.graph.Graph) DefaultGridWidgetCellSelectorMouseEventHandler(org.uberfire.ext.wires.core.grids.client.widget.grid.impl.DefaultGridWidgetCellSelectorMouseEventHandler) Mockito.never(org.mockito.Mockito.never) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) GridCellValueTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple) Collections(java.util.Collections) Mockito.reset(org.mockito.Mockito.reset) Assert.assertEquals(org.junit.Assert.assertEquals) Optional(java.util.Optional) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData)

Example 89 with Mock

use of org.mockito.Mock in project kie-wb-common by kiegroup.

the class DecisionServiceParametersListWidgetTest method testGetSortedInputs.

@Test
public void testGetSortedInputs() {
    final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
    final DecisionService decisionService = mock(DecisionService.class);
    final String id1 = "id1";
    final String id2 = "id2";
    final String id3 = "id3";
    final String newId1 = "newId1";
    final String newId2 = "newId2";
    final List<DMNElementReference> list = createListOfDMNElementReferenceWithIds(id1, id2, id3);
    final List<InputData> unsortedInputs = Arrays.asList(createInputDataWithId(id2), createInputDataWithId(id3), createInputDataWithId(newId2), createInputDataWithId(id1), createInputDataWithId(newId1));
    doReturn(value).when(widget).getValue();
    when(value.getDecisionService()).thenReturn(decisionService);
    when(decisionService.getInputData()).thenReturn(list);
    final List<InputData> sorted = widget.getSortedInputs(unsortedInputs);
    assertThat(sorted).extracting(inputData -> inputData.getId().getValue()).containsExactly(id1, id2, id3, newId1, newId2);
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) DecisionServiceParameters_Outputs(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_Outputs) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) ClientTranslationService(org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService) Mockito.doReturn(org.mockito.Mockito.doReturn) DecisionServiceParameters_EncapsulatedDecisions(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_EncapsulatedDecisions) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Mockito.doNothing(org.mockito.Mockito.doNothing) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) List(java.util.List) Stream(java.util.stream.Stream) DMNDiagramsSession(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramsSession) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Node(org.kie.workbench.common.stunner.core.graph.Node) Mockito.mock(org.mockito.Mockito.mock) GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) DecisionServiceParameters_Inputs(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_Inputs) Mockito.spy(org.mockito.Mockito.spy) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ArrayList(java.util.ArrayList) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Elemental2DomUtil(org.jboss.errai.common.client.dom.elemental2.Elemental2DomUtil) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) Before(org.junit.Before) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Mockito.verify(org.mockito.Mockito.verify) ParameterGroup(org.kie.workbench.common.dmn.client.widgets.decisionservice.parameters.parametergroup.ParameterGroup) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Mockito.never(org.mockito.Mockito.never) HTMLDivElement(elemental2.dom.HTMLDivElement) DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Assert.assertEquals(org.junit.Assert.assertEquals) DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Example 90 with Mock

use of org.mockito.Mock in project kie-wb-common by kiegroup.

the class ValidationActionTest method loadingCompletedOnSuccess.

@Test
public void loadingCompletedOnSuccess() {
    final Command loadingCompleted = mock(Command.class);
    new ValidationAction(editorSessionCommands, () -> {
    /*  */
    }, loadingCompleted, s -> {
    /*  */
    }).validate();
    verify(validateSessionCommand).execute(violationsArgumentCapture.capture());
    violationsArgumentCapture.getValue().onSuccess();
    verify(loadingCompleted).execute();
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) EditorSessionCommands(org.kie.workbench.common.stunner.client.widgets.editor.EditorSessionCommands) Mock(org.mockito.Mock) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Collection(java.util.Collection) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Captor(org.mockito.Captor) Mockito.verify(org.mockito.Mockito.verify) HashSet(java.util.HashSet) Consumer(java.util.function.Consumer) DiagramElementViolation(org.kie.workbench.common.stunner.core.validation.DiagramElementViolation) Mockito.never(org.mockito.Mockito.never) ArgumentCaptor(org.mockito.ArgumentCaptor) Command(com.google.gwt.user.client.Command) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ValidateSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.doReturn(org.mockito.Mockito.doReturn) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) Command(com.google.gwt.user.client.Command) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) ValidateSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand) Test(org.junit.Test)

Aggregations

Mock (org.mockito.Mock)135 Mockito.mock (org.mockito.Mockito.mock)109 Test (org.junit.Test)104 Before (org.junit.Before)96 Mockito.verify (org.mockito.Mockito.verify)89 Mockito.when (org.mockito.Mockito.when)82 List (java.util.List)81 RunWith (org.junit.runner.RunWith)76 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)65 Collections (java.util.Collections)56 ArrayList (java.util.ArrayList)55 ArgumentCaptor (org.mockito.ArgumentCaptor)52 Mockito.spy (org.mockito.Mockito.spy)48 Arrays (java.util.Arrays)44 Assert.assertEquals (org.junit.Assert.assertEquals)41 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)41 Mockito.doReturn (org.mockito.Mockito.doReturn)41 Map (java.util.Map)40 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)38 Mockito.never (org.mockito.Mockito.never)37