Search in sources :

Example 1 with TestDefinitionsWriter

use of org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter in project kie-wb-common by kiegroup.

the class SequenceFlowPropertyReaderTest method testGetConditionExpression.

private void testGetConditionExpression(ScriptTypeValue expectedValue, FormalExpression formalExpression) {
    TestDefinitionsWriter d = new TestDefinitionsWriter();
    PropertyReaderFactory factory = new PropertyReaderFactory(d.getDefinitionResolver());
    SequenceFlow sequenceFlow = mock(SequenceFlow.class);
    SequenceFlowPropertyReader propertyReader = factory.of(sequenceFlow);
    when(sequenceFlow.getConditionExpression()).thenReturn(formalExpression);
    assertEquals(expectedValue, propertyReader.getConditionExpression());
}
Also used : SequenceFlow(org.eclipse.bpmn2.SequenceFlow) TestDefinitionsWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter)

Example 2 with TestDefinitionsWriter

use of org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter in project kie-wb-common by kiegroup.

the class SequenceFlowPropertyReaderTest method get2Waypoints.

@Test
public void get2Waypoints() {
    TestDefinitionsWriter d = new TestDefinitionsWriter();
    PropertyReaderFactory factory = new PropertyReaderFactory(d.getDefinitionResolver());
    Bounds sourceBounds = boundsOf(10, 10, 50, 50);
    FlowNode source = d.mockNode(SOURCE_ID, sourceBounds);
    Bounds targetBounds = boundsOf(100, 100, 60, 60);
    FlowNode target = d.mockNode(TARGET_ID, targetBounds);
    Point sourcePoint = pointOf(10, 20);
    Point mid1 = pointOf(15, 25);
    Point mid2 = pointOf(20, 30);
    Point targetPoint = pointOf(100, 120);
    List<Point> waypoints = asList(sourcePoint, mid1, mid2, targetPoint);
    SequenceFlow el = d.sequenceFlowOf(SEQ_ID, source, target, waypoints);
    SequenceFlowPropertyReader p = factory.of(el);
    List<Point2D> controlPoints = p.getControlPoints();
    List<Point2D> expected = asList(Point2D.create(mid1.getX(), mid1.getY()), Point2D.create(mid2.getX(), mid2.getY()));
    assertEquals(expected, controlPoints);
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) Bounds(org.eclipse.dd.dc.Bounds) Point(org.eclipse.dd.dc.Point) TestDefinitionsWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter) FlowNode(org.eclipse.bpmn2.FlowNode) Test(org.junit.Test)

Example 3 with TestDefinitionsWriter

use of org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter in project kie-wb-common by kiegroup.

the class LanePropertyReaderTest method JBPM_7523_shouldPreserveNameChars.

@Test
public void JBPM_7523_shouldPreserveNameChars() {
    PropertyReaderFactory factory = new PropertyReaderFactory(new TestDefinitionsWriter().getDefinitionResolver());
    Lane lane = bpmn2.createLane();
    PropertyWriterFactory writerFactory = new PropertyWriterFactory();
    LanePropertyWriter w = writerFactory.of(lane);
    String aWeirdName = "   XXX  !!@@ <><> ";
    String aWeirdDoc = "   XXX  !!@@ <><> Docs ";
    w.setName(aWeirdName);
    w.setDocumentation(aWeirdDoc);
    LanePropertyReader r = factory.of(lane);
    assertThat(r.getName()).isEqualTo(asCData(aWeirdName));
    assertThat(r.getDocumentation()).isEqualTo(asCData(aWeirdDoc));
}
Also used : LanePropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.LanePropertyWriter) Lane(org.eclipse.bpmn2.Lane) TestDefinitionsWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) Test(org.junit.Test)

Example 4 with TestDefinitionsWriter

use of org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter in project kie-wb-common by kiegroup.

the class SequenceFlowPropertyReaderTest method getConnectionsWithWaypoints.

@Test
public void getConnectionsWithWaypoints() {
    TestDefinitionsWriter d = new TestDefinitionsWriter();
    PropertyReaderFactory factory = new PropertyReaderFactory(d.getDefinitionResolver());
    Bounds sourceBounds = boundsOf(10, 10, 50, 50);
    FlowNode source = d.mockNode(SOURCE_ID, sourceBounds);
    Bounds targetBounds = boundsOf(100, 100, 60, 60);
    FlowNode target = d.mockNode(TARGET_ID, targetBounds);
    Point sourcePoint = pointOf(10, 20);
    Point targetPoint = pointOf(100, 120);
    List<Point> waypoints = asList(sourcePoint, targetPoint);
    SequenceFlow el = d.sequenceFlowOf(SEQ_ID, source, target, waypoints);
    SequenceFlowPropertyReader p = factory.of(el);
    Connection sourceConnection = p.getSourceConnection();
    assertEquals(sourcePoint.getX() - sourceBounds.getX(), (float) sourceConnection.getLocation().getX(), 0);
    assertEquals(sourcePoint.getY() - sourceBounds.getY(), (float) sourceConnection.getLocation().getY(), 0);
    Connection targetConnection = p.getTargetConnection();
    assertEquals(targetPoint.getX() - targetBounds.getX(), (float) targetConnection.getLocation().getX(), 0);
    assertEquals(targetPoint.getY() - targetBounds.getY(), (float) targetConnection.getLocation().getY(), 0);
}
Also used : SequenceFlow(org.eclipse.bpmn2.SequenceFlow) Bounds(org.eclipse.dd.dc.Bounds) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) Point(org.eclipse.dd.dc.Point) TestDefinitionsWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter) FlowNode(org.eclipse.bpmn2.FlowNode) Test(org.junit.Test)

Example 5 with TestDefinitionsWriter

use of org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter in project kie-wb-common by kiegroup.

the class SequenceFlowPropertyReaderTest method getConnectionsNoWaypoints.

@Test
public void getConnectionsNoWaypoints() {
    TestDefinitionsWriter d = new TestDefinitionsWriter();
    PropertyReaderFactory factory = new PropertyReaderFactory(d.getDefinitionResolver());
    Bounds sourceBounds = boundsOf(10, 10, 50, 50);
    FlowNode source = d.mockNode(SOURCE_ID, sourceBounds);
    Bounds targetBounds = boundsOf(100, 100, 60, 60);
    FlowNode target = d.mockNode(TARGET_ID, targetBounds);
    List<Point> noWaypoints = Collections.emptyList();
    SequenceFlow el = d.sequenceFlowOf(SEQ_ID, source, target, noWaypoints);
    SequenceFlowPropertyReader p = factory.of(el);
    // this is inferred from behavior of the old marshallers
    Connection sourceConnection = p.getSourceConnection();
    assertEquals(sourceBounds.getWidth(), (float) sourceConnection.getLocation().getX(), 0);
    assertEquals(sourceBounds.getHeight() / 2f, (float) sourceConnection.getLocation().getY(), 0);
    Connection targetConnection = p.getTargetConnection();
    assertEquals(0.0f, (float) targetConnection.getLocation().getX(), 0);
    assertEquals(targetBounds.getHeight() / 2.0f, (float) targetConnection.getLocation().getY(), 0);
}
Also used : SequenceFlow(org.eclipse.bpmn2.SequenceFlow) Bounds(org.eclipse.dd.dc.Bounds) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) Point(org.eclipse.dd.dc.Point) TestDefinitionsWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter) FlowNode(org.eclipse.bpmn2.FlowNode) Test(org.junit.Test)

Aggregations

TestDefinitionsWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.TestDefinitionsWriter)6 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)5 Test (org.junit.Test)5 FlowNode (org.eclipse.bpmn2.FlowNode)4 Bounds (org.eclipse.dd.dc.Bounds)4 Point (org.eclipse.dd.dc.Point)4 Connection (org.kie.workbench.common.stunner.core.graph.content.view.Connection)2 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)2 Lane (org.eclipse.bpmn2.Lane)1 LanePropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.LanePropertyWriter)1 PropertyWriterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory)1