Search in sources :

Example 11 with ViewImpl

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

the class GraphUtilsTest method testNonReusableSubprocess.

@Test
public void testNonReusableSubprocess() {
    Element<View<UserTask>> element = new NodeImpl<>("UUID");
    View<UserTask> userTaskView = new ViewImpl<>(new UserTask(), Bounds.create());
    element.setContent(userTaskView);
    assertFalse(GraphUtils.isReusableSubProcess(element));
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 12 with ViewImpl

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

the class CallActivityConverterTest method setUp.

@Before
public void setUp() {
    final ReusableSubprocess definition = new ReusableSubprocess(new BPMNGeneralSet(), new ReusableSubprocessTaskExecutionSet(), new DataIOSet(), new BackgroundSet(), new FontSet(), new RectangleDimensionsSet(), new SimulationSet(), new AdvancedData());
    final View<ReusableSubprocess> view = new ViewImpl<>(definition, Bounds.create());
    Node<View<ReusableSubprocess>, Edge> node = new NodeImpl<>(UUID);
    node.setContent(view);
    when(callActivity.getId()).thenReturn(UUID);
    when(callActivity.getCalledElement()).thenReturn(CALLED_ELEMENT);
    when(factoryManager.newNode(eq(UUID), eq(ReusableSubprocess.class))).thenReturn(node);
    when(propertyReaderFactory.of(callActivity)).thenReturn(propertyReader);
    when(propertyReader.getName()).thenReturn(NAME);
    when(propertyReader.getDocumentation()).thenReturn(DOCUMENTATION);
    when(propertyReader.getAssignmentsInfo()).thenReturn(ASSIGNMENTS_INFO);
    when(propertyReader.getBounds()).thenReturn(BOUNDS);
    when(propertyReader.getSimulationSet()).thenReturn(SIMULATION_SET);
    when(propertyReader.getRectangleDimensionsSet()).thenReturn(RECTANGLE_DIMENSIONS_SET);
    when(propertyReader.getFontSet()).thenReturn(FONT_SET);
    when(propertyReader.getBackgroundSet()).thenReturn(BACKGROUND_SET);
    when(propertyReader.isIndependent()).thenReturn(INDEPENDENT);
    when(propertyReader.isAbortParent()).thenReturn(ABORT_PARENT);
    when(propertyReader.isWaitForCompletion()).thenReturn(WAIT_FOR_COMPLETION);
    when(propertyReader.isAsync()).thenReturn(IS_ASYNC);
    when(propertyReader.isSequential()).thenReturn(SEQUENTIAL);
    when(propertyReader.getCollectionOutput()).thenReturn(COLLECTION_OUTPUT);
    when(propertyReader.getCollectionInput()).thenReturn(COLLECTION_INPUT);
    when(propertyReader.getDataInput()).thenReturn(DATA_INPUT);
    when(propertyReader.getDataOutput()).thenReturn(DATA_OUTPUT);
    when(propertyReader.getCompletionCondition()).thenReturn(COMPLETION_CONDITION);
    when(propertyReader.getOnEntryAction()).thenReturn(ON_ENTRY_ACTION);
    when(propertyReader.getOnExitAction()).thenReturn(ON_EXIT_ACTION);
    when(propertyReader.getSlaDueDate()).thenReturn(SLA_DUE_DATE);
    converter = new CallActivityConverter(factoryManager, propertyReaderFactory);
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) RectangleDimensionsSet(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) FontSet(org.kie.workbench.common.stunner.bpmn.definition.property.font.FontSet) AdvancedData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.AdvancedData) SimulationSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet) BackgroundSet(org.kie.workbench.common.stunner.bpmn.definition.property.background.BackgroundSet) ReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) ReusableSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.ReusableSubprocessTaskExecutionSet) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Before(org.junit.Before)

Example 13 with ViewImpl

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

the class MapSelectionControlTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    ShapeViewExtStub shapeView = new ShapeViewExtStub(shapeEventHandler, hasControlPoints);
    when(rootElement.getUUID()).thenReturn(ROOT_UUID);
    when(rootElement.getContent()).thenReturn(new ViewImpl<>(rootDefinition, Bounds.create(0, 0, 10, 10)));
    when(element.getUUID()).thenReturn(ELEMENT_UUID);
    when(element.getContent()).thenReturn(new ViewImpl<>(definition, Bounds.create(0, 0, 10, 10)));
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getCanvasRootUUID()).thenReturn(ROOT_UUID);
    when(canvasHandler.getCanvas()).thenReturn(canvas);
    when(canvasHandler.getAbstractCanvas()).thenReturn(canvas);
    when(canvasHandler.getGraphIndex()).thenReturn(index);
    when(canvas.getShape(eq(ELEMENT_UUID))).thenReturn(shape);
    when(canvas.getShapes()).thenReturn(Collections.singletonList(shape));
    when(shape.getUUID()).thenReturn(ELEMENT_UUID);
    when(shape.getShapeView()).thenReturn(shapeView);
    when(shapeEventHandler.supports(eq(ViewEventType.MOUSE_CLICK))).thenReturn(true);
    this.tested = new MapSelectionControl(e -> elementSelectedEvent.fire((CanvasSelectionEvent) e), e -> clearSelectionEvent.fire((CanvasClearSelectionEvent) e));
    this.tested.setReadonly(false);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) CanvasClearSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent) HasEventHandlers(org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers) Mock(org.mockito.Mock) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) RunWith(org.junit.runner.RunWith) HasControlPoints(org.kie.workbench.common.stunner.core.client.shape.view.HasControlPoints) AbstractCanvas(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvas) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) Sets(org.kie.soup.commons.util.Sets) Shape(org.kie.workbench.common.stunner.core.client.shape.Shape) Captor(org.mockito.Captor) CanvasSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent) ArgumentCaptor(org.mockito.ArgumentCaptor) CanvasShapeRemovedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasShapeRemovedEvent) ShapeState(org.kie.workbench.common.stunner.core.client.shape.ShapeState) Element(org.kie.workbench.common.stunner.core.graph.Element) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Before(org.junit.Before) ViewEventType(org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEventType) Index(org.kie.workbench.common.stunner.core.graph.processing.index.Index) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) MouseClickHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickHandler) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) ShapeView(org.kie.workbench.common.stunner.core.client.shape.view.ShapeView) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Mockito.verify(org.mockito.Mockito.verify) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent) Mockito.never(org.mockito.Mockito.never) Assert.assertFalse(org.junit.Assert.assertFalse) ShapeViewExtStub(org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub) Optional(java.util.Optional) EventSourceMock(org.uberfire.mocks.EventSourceMock) Collections(java.util.Collections) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) ShapeViewExtStub(org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub) Before(org.junit.Before)

Example 14 with ViewImpl

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

the class ReusableSubprocessConverterTest method testToFlowElement_autostart.

@Test
public void testToFlowElement_autostart() {
    final ReusableSubprocess definition = new ReusableSubprocess();
    definition.getExecutionSet().setAdHocAutostart(new AdHocAutostart(true));
    final View<BaseReusableSubprocess> view = new ViewImpl<>(definition, Bounds.create());
    final Node<View<BaseReusableSubprocess>, ?> node = new NodeImpl<>(java.util.UUID.randomUUID().toString());
    node.setContent(view);
    final PropertyWriter propertyWriter = tested.toFlowElement(node);
    assertTrue(CallActivityPropertyWriter.class.isInstance(propertyWriter));
    assertTrue(CustomElement.autoStart.of(propertyWriter.getFlowElement()).get());
}
Also used : CallActivityPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CallActivityPropertyWriter) BaseReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseReusableSubprocess) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) ReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess) BaseReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseReusableSubprocess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) AdHocAutostart(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocAutostart) View(org.kie.workbench.common.stunner.core.graph.content.view.View) CallActivityPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CallActivityPropertyWriter) PropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriter) Test(org.junit.Test)

Example 15 with ViewImpl

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

the class ReusableSubprocessConverterTest method testToFlowElementForAbortParent.

private void testToFlowElementForAbortParent(boolean independent, boolean abortParent, boolean expectedAbortParent) {
    final ReusableSubprocess definition = new ReusableSubprocess();
    definition.getExecutionSet().setIndependent(new Independent(independent));
    definition.getExecutionSet().setAbortParent(new AbortParent(abortParent));
    final View<BaseReusableSubprocess> view = new ViewImpl<>(definition, Bounds.create());
    final Node<View<BaseReusableSubprocess>, ?> node = new NodeImpl<>(java.util.UUID.randomUUID().toString());
    node.setContent(view);
    final PropertyWriter propertyWriter = tested.toFlowElement(node);
    assertEquals(expectedAbortParent, CustomElement.abortParent.of(propertyWriter.getFlowElement()).get());
}
Also used : BaseReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseReusableSubprocess) Independent(org.kie.workbench.common.stunner.bpmn.definition.property.task.Independent) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) ReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess) BaseReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseReusableSubprocess) AbortParent(org.kie.workbench.common.stunner.bpmn.definition.property.task.AbortParent) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) CallActivityPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CallActivityPropertyWriter) PropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriter)

Aggregations

ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)54 Test (org.junit.Test)40 View (org.kie.workbench.common.stunner.core.graph.content.view.View)35 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)35 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)17 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 Before (org.junit.Before)11 Node (org.kie.workbench.common.stunner.core.graph.Node)10 QName (javax.xml.namespace.QName)9 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)9 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)9 ReusableSubprocess (org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess)9 TDecision (org.kie.dmn.model.v1_2.TDecision)7 BaseReusableSubprocess (org.kie.workbench.common.stunner.bpmn.definition.BaseReusableSubprocess)7 HashMap (java.util.HashMap)6 AdHocSubProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter)6 CallActivityPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CallActivityPropertyWriter)6 PropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriter)6 SubProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter)6 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)6