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());
}
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);
}
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));
}
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);
}
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);
}
Aggregations