Search in sources :

Example 1 with EditExpressionEvent

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

the class DMNEditBusinessKnowledgeModelToolboxActionTest method testAction.

@Test
public void testAction() {
    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());
    assertFalse(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 2 with EditExpressionEvent

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

the class DMNEditDecisionToolboxActionTest method testAction.

@Test
public void testAction() {
    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());
    assertFalse(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)

Example 3 with EditExpressionEvent

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

the class DecisionNavigatorObserverTest method testOnNestedElementSelected.

@Test
public void testOnNestedElementSelected() {
    observer.init(presenter);
    observer.onNestedElementSelected(new EditExpressionEvent(clientSession, uuid, hasExpression, Optional.of(hasName), false));
    verify(presenter).refresh();
}
Also used : EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) Test(org.junit.Test)

Example 4 with EditExpressionEvent

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

the class DecisionNavigatorObserverTest method testSelectItemWhenExpressionIsNull.

@Test
public void testSelectItemWhenExpressionIsNull() {
    final EditExpressionEvent event = makeEditExpressionEvent();
    when(hasExpression.getExpression()).thenReturn(null);
    observer.init(presenter);
    observer.selectItem(event.getHasExpression());
    verify(treePresenter, never()).selectItem(Mockito.<String>any());
}
Also used : EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) Test(org.junit.Test)

Example 5 with EditExpressionEvent

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

the class DecisionNavigatorObserverTest method testSelectItemWhenExpressionIsNotNull.

@Test
public void testSelectItemWhenExpressionIsNotNull() {
    final EditExpressionEvent event = makeEditExpressionEvent();
    final Expression expression = mock(Expression.class);
    final Id id = mock(Id.class);
    when(hasExpression.getExpression()).thenReturn(expression);
    when(expression.getId()).thenReturn(id);
    when(id.getValue()).thenReturn(uuid);
    observer.init(presenter);
    observer.selectItem(event.getHasExpression());
    verify(treePresenter).selectItem(uuid);
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) 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