Search in sources :

Example 11 with EditExpressionEvent

use of org.kie.workbench.common.dmn.client.events.EditExpressionEvent in project kie-wb-common by kiegroup.

the class DecisionNavigatorNestedItemFactoryTest method testMakeOnClickCommand.

@Test
public void testMakeOnClickCommand() {
    final EditExpressionEvent expressionEvent = mock(EditExpressionEvent.class);
    final CanvasHandler canvasHandler = mock(CanvasHandler.class);
    final CanvasSelectionEvent event = mock(CanvasSelectionEvent.class);
    final String uuid = "uuid";
    when(dmnGraphUtils.getCanvasHandler()).thenReturn(canvasHandler);
    doReturn(event).when(factory).makeCanvasSelectionEvent(canvasHandler, uuid);
    doReturn(expressionEvent).when(factory).makeEditExpressionEvent(node);
    factory.makeOnClickCommand(node, uuid).execute();
    verify(canvasSelectionEvent).fire(event);
    verify(editExpressionEvent).fire(expressionEvent);
}
Also used : CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) CanvasSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) Test(org.junit.Test)

Example 12 with EditExpressionEvent

use of org.kie.workbench.common.dmn.client.events.EditExpressionEvent in project kie-wb-common by kiegroup.

the class DecisionNavigatorObserverTest method testSetActiveParent.

@Test
public void testSetActiveParent() {
    final EditExpressionEvent event = makeEditExpressionEvent();
    observer.init(presenter);
    observer.setActiveParent(event);
    verify(treePresenter).setActiveParentUUID(uuid);
}
Also used : EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) Test(org.junit.Test)

Example 13 with EditExpressionEvent

use of org.kie.workbench.common.dmn.client.events.EditExpressionEvent in project kie-wb-common by kiegroup.

the class DMNEditBusinessKnowledgeModelToolboxActionTest method testActionSetExpression.

@Test
public void testActionSetExpression() {
    tested.onMouseClick(canvasHandler, E_UUID, mouseClickEvent);
    final ArgumentCaptor<EditExpressionEvent> eventCaptor = ArgumentCaptor.forClass(EditExpressionEvent.class);
    verify(editExpressionEvent, times(1)).fire(eventCaptor.capture());
    final EditExpressionEvent editExprEvent = eventCaptor.getValue();
    final HasExpression hasExpression = editExprEvent.getHasExpression();
    Assertions.assertThatThrownBy(() -> hasExpression.setExpression(new DecisionTable())).isInstanceOf(UnsupportedOperationException.class).hasMessage("It is not possible to set the EncapsulatedLogic of a BusinessKnowledgeModel.");
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) Test(org.junit.Test)

Example 14 with EditExpressionEvent

use of org.kie.workbench.common.dmn.client.events.EditExpressionEvent in project kie-wb-common by kiegroup.

the class DMNEditBusinessKnowledgeModelToolboxActionTest method testActionWhenIsReadOnlyDiagram.

@Test
public void testActionWhenIsReadOnlyDiagram() {
    when(readOnlyProvider.isReadOnlyDiagram()).thenReturn(true);
    final ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, mouseClickEvent);
    assertEquals(tested, cascade);
    final ArgumentCaptor<EditExpressionEvent> eventCaptor = ArgumentCaptor.forClass(EditExpressionEvent.class);
    verify(editExpressionEvent, times(1)).fire(eventCaptor.capture());
    final EditExpressionEvent editExprEvent = eventCaptor.getValue();
    assertEquals(E_UUID, editExprEvent.getNodeUUID());
    final HasExpression hasExpression = editExprEvent.getHasExpression();
    assertEquals(bkm.getEncapsulatedLogic(), hasExpression.getExpression());
    assertEquals(bkm, hasExpression.asDMNModelInstrumentedBase());
    assertFalse(hasExpression.isClearSupported());
    assertEquals(bkm, editExprEvent.getHasName().get());
    assertEquals(session, editExprEvent.getSession());
    assertTrue(editExprEvent.isOnlyVisualChangeAllowed());
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) Test(org.junit.Test)

Example 15 with EditExpressionEvent

use of org.kie.workbench.common.dmn.client.events.EditExpressionEvent in project kie-wb-common by kiegroup.

the class DMNEditDecisionToolboxActionTest method testActionWhenIsReadOnlyDiagram.

@Test
public void testActionWhenIsReadOnlyDiagram() {
    when(readOnlyProvider.isReadOnlyDiagram()).thenReturn(true);
    final MouseClickEvent event = mock(MouseClickEvent.class);
    final ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, event);
    assertEquals(tested, cascade);
    final ArgumentCaptor<EditExpressionEvent> eventCaptor = ArgumentCaptor.forClass(EditExpressionEvent.class);
    verify(editExpressionEvent, times(1)).fire(eventCaptor.capture());
    final EditExpressionEvent editExprEvent = eventCaptor.getValue();
    assertEquals(E_UUID, editExprEvent.getNodeUUID());
    assertEquals(decision, editExprEvent.getHasExpression());
    assertEquals(decision, editExprEvent.getHasName().get());
    assertEquals(session, editExprEvent.getSession());
    assertTrue(editExprEvent.isOnlyVisualChangeAllowed());
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent) Test(org.junit.Test)

Aggregations

EditExpressionEvent (org.kie.workbench.common.dmn.client.events.EditExpressionEvent)15 Test (org.junit.Test)12 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)7 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)4 View (org.kie.workbench.common.stunner.core.graph.content.view.View)4 HasName (org.kie.workbench.common.dmn.api.definition.HasName)3 ClientSession (org.kie.workbench.common.stunner.core.client.session.ClientSession)3 MouseClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)2 Edge (org.kie.workbench.common.stunner.core.graph.Edge)2 Node (org.kie.workbench.common.stunner.core.graph.Node)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)1 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)1 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)1 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)1 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)1 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)1 CanvasSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent)1