Search in sources :

Example 31 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class AbstractGraphCommandTest method mockView.

public static View mockView(final double x, final double y, final double w, final double h) {
    View view = mock(View.class);
    Bounds bounds = mockBounds(x, y, w, h);
    when(view.getBounds()).thenReturn(bounds);
    return view;
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Example 32 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class AbstractGraphCommandTest method init.

@SuppressWarnings("unchecked")
public void init(final double width, final double height) {
    MockitoAnnotations.initMocks(this);
    Bounds bounds = mockBounds(0, 0, width, height);
    when(graphContent.getBounds()).thenReturn(bounds);
    when(graph.getUUID()).thenReturn(GRAPH_UUID);
    when(graph.getContent()).thenReturn(graphContent);
    when(graph.nodes()).thenReturn(graphNodes);
    when(definitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.registry()).thenReturn(adapterRegistry);
    when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
    when(adapterManager.forProperty()).thenReturn(propertyAdapter);
    when(adapterRegistry.getDefinitionAdapter(any(Class.class))).thenReturn(definitionAdapter);
    when(adapterRegistry.getPropertyAdapter(any(Class.class))).thenReturn(propertyAdapter);
    when(graphCommandExecutionContext.getDefinitionManager()).thenReturn(definitionManager);
    when(graphCommandExecutionContext.getFactoryManager()).thenReturn(factoryManager);
    when(graphCommandExecutionContext.getRuleManager()).thenReturn(ruleManager);
    when(graphCommandExecutionContext.getGraphIndex()).thenReturn(graphIndex);
    when(graphCommandExecutionContext.getRuleSet()).thenReturn(ruleSet);
    when(graphIndex.getGraph()).thenReturn(graph);
    when(ruleManager.evaluate(any(RuleSet.class), any(RuleEvaluationContext.class))).thenReturn(EMPTY_VIOLATIONS);
}
Also used : RuleSet(org.kie.workbench.common.stunner.core.rule.RuleSet) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) RuleEvaluationContext(org.kie.workbench.common.stunner.core.rule.RuleEvaluationContext)

Example 33 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class DMNCommonActionsToolboxFactoryTest method testBuildToolboxForDecisionType.

@Test
@SuppressWarnings("unchecked")
public void testBuildToolboxForDecisionType() {
    final Node<View<Decision>, Edge> decisionNode = new NodeImpl<>("decisionNode1");
    final Decision decision = new Decision();
    final Bounds bounds = new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 150d));
    final View<Decision> nodeContent = new ViewImpl<>(decision, bounds);
    decisionNode.setContent(nodeContent);
    final Optional<Toolbox<?>> _toolbox = tested.build(canvasHandler, decisionNode);
    assertTrue(_toolbox.isPresent());
    Toolbox<?> toolbox = _toolbox.get();
    assertTrue(toolbox instanceof ActionsToolbox);
    final ActionsToolbox actionsToolbox = (ActionsToolbox) toolbox;
    assertEquals("decisionNode1", actionsToolbox.getElementUUID());
    assertEquals(2, actionsToolbox.size());
    final Iterator<ToolboxAction> actionsIt = actionsToolbox.iterator();
    assertEquals(deleteNodeAction, actionsIt.next());
    assertEquals(editDecisionToolboxAction, actionsIt.next());
    assertFalse(actionsIt.hasNext());
    verify(view, times(1)).init(eq(actionsToolbox));
    verify(view, times(2)).addButton(any(Glyph.class), anyString(), any(Consumer.class));
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) ActionsToolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolbox) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ActionsToolboxView(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolboxView) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) Consumer(java.util.function.Consumer) ToolboxAction(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ToolboxAction) ActionsToolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ActionsToolbox) Toolbox(org.kie.workbench.common.stunner.core.client.components.toolbox.Toolbox) Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 34 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class DMNEditDecisionToolboxActionTest method setup.

@Before
public void setup() throws Exception {
    decisionNode = new NodeImpl<>(E_UUID);
    decision = new Decision();
    final Bounds bounds = new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 150d));
    final View<Decision> nodeContent = new ViewImpl<>(decision, bounds);
    decisionNode.setContent(nodeContent);
    when(canvasHandler.getGraphIndex()).thenReturn(graphIndex);
    when(graphIndex.get(eq(E_UUID))).thenReturn(decisionNode);
    when(sessionManager.getCurrentSession()).thenReturn(session);
    this.tested = new DMNEditDecisionToolboxAction(sessionManager, translationService, editExpressionEvent);
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) Before(org.junit.Before)

Aggregations

Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)34 View (org.kie.workbench.common.stunner.core.graph.content.view.View)18 Test (org.junit.Test)16 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)14 Edge (org.kie.workbench.common.stunner.core.graph.Edge)13 Node (org.kie.workbench.common.stunner.core.graph.Node)13 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)12 Graph (org.kie.workbench.common.stunner.core.graph.Graph)7 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)6 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)6 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)5 Ignore (org.junit.Ignore)4 TestingGraphMockHandler (org.kie.workbench.common.stunner.core.TestingGraphMockHandler)4 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)4 RuleEvaluationContext (org.kie.workbench.common.stunner.core.rule.RuleEvaluationContext)4 Consumer (java.util.function.Consumer)2 Before (org.junit.Before)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel)2 Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)2 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)2