Test and data for cleaning up my smell. We now test explicitly whether a task has both a default_value and value_expression. If so, we raise an error.
This commit is contained in:
parent
81e55b6055
commit
420ef0b2b0
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/1.0" id="Definitions_4ddf19d" name="DRD" namespace="http://camunda.org/schema/1.0/dmn">
|
||||
<decision id="Decision_Value_Expression" name="Decision 1">
|
||||
<extensionElements>
|
||||
<biodi:bounds x="157" y="81" width="180" height="80" />
|
||||
</extensionElements>
|
||||
<decisionTable id="decisionTable_1">
|
||||
<input id="input_1" label="User Input">
|
||||
<inputExpression id="inputExpression_1" typeRef="boolean">
|
||||
<text>user_input</text>
|
||||
</inputExpression>
|
||||
</input>
|
||||
<output id="output_1" label="Lookup Output" name="lookup_output" typeRef="string" />
|
||||
<rule id="DecisionRule_1y5u0zy">
|
||||
<inputEntry id="UnaryTests_10u8r2i">
|
||||
<text>True</text>
|
||||
</inputEntry>
|
||||
<outputEntry id="LiteralExpression_1dshav8">
|
||||
<text>'black'</text>
|
||||
</outputEntry>
|
||||
</rule>
|
||||
<rule id="DecisionRule_0pnsbfu">
|
||||
<inputEntry id="UnaryTests_1lasqlz">
|
||||
<text>False</text>
|
||||
</inputEntry>
|
||||
<outputEntry id="LiteralExpression_1nrtq17">
|
||||
<text>'white'</text>
|
||||
</outputEntry>
|
||||
</rule>
|
||||
<rule id="DecisionRule_0ujcwwp">
|
||||
<inputEntry id="UnaryTests_139wk1t">
|
||||
<text></text>
|
||||
</inputEntry>
|
||||
<outputEntry id="LiteralExpression_0emea64">
|
||||
<text>'grey'</text>
|
||||
</outputEntry>
|
||||
</rule>
|
||||
</decisionTable>
|
||||
</decision>
|
||||
</definitions>
|
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_889ace0" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
|
||||
<bpmn:process id="Process_a7f16c2" isExecutable="true">
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>Flow_02xzhf3</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:sequenceFlow id="Flow_02xzhf3" sourceRef="StartEvent_1" targetRef="Activity_UserInput" />
|
||||
<bpmn:sequenceFlow id="Flow_0d46qnz" sourceRef="Activity_UserInput" targetRef="Activity_DecisionLookup" />
|
||||
<bpmn:sequenceFlow id="Flow_1d7sv9v" sourceRef="Activity_DecisionLookup" targetRef="Activity_PickColor" />
|
||||
<bpmn:userTask id="Activity_UserInput" name="User Input" camunda:formKey="UserInput">
|
||||
<bpmn:extensionElements>
|
||||
<camunda:formData>
|
||||
<camunda:formField id="user_input" label="Select Yes or No" type="boolean" defaultValue="True" />
|
||||
</camunda:formData>
|
||||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>Flow_02xzhf3</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_0d46qnz</bpmn:outgoing>
|
||||
</bpmn:userTask>
|
||||
<bpmn:businessRuleTask id="Activity_DecisionLookup" name="Decision Lookup" camunda:resultVariable="lookup_output" camunda:decisionRef="Decision_Value_Expression">
|
||||
<bpmn:incoming>Flow_0d46qnz</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_1d7sv9v</bpmn:outgoing>
|
||||
</bpmn:businessRuleTask>
|
||||
<bpmn:userTask id="Activity_PickColor" name="Pick a Color" camunda:formKey="MyFormKey">
|
||||
<bpmn:documentation><h1>Hello {{ lookup_output }}</h1></bpmn:documentation>
|
||||
<bpmn:extensionElements>
|
||||
<camunda:formData>
|
||||
<camunda:formField id="color_select" label="Pick a color" type="enum" defaultValue="white">
|
||||
<camunda:properties>
|
||||
<camunda:property id="value_expression" value="lookup_output" />
|
||||
</camunda:properties>
|
||||
<camunda:value id="black" name="Black" />
|
||||
<camunda:value id="white" name="White" />
|
||||
<camunda:value id="grey" name="Grey" />
|
||||
<camunda:value id="gray" name="Gray" />
|
||||
</camunda:formField>
|
||||
</camunda:formData>
|
||||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>Flow_1d7sv9v</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_01x96w8</bpmn:outgoing>
|
||||
</bpmn:userTask>
|
||||
<bpmn:sequenceFlow id="Flow_01x96w8" sourceRef="Activity_PickColor" targetRef="Activity_Display_Color" />
|
||||
<bpmn:manualTask id="Activity_Display_Color" name="Display Color">
|
||||
<bpmn:documentation><h1>Hello</h1>
|
||||
<div>You picked {{ color_select.label }}</div></bpmn:documentation>
|
||||
<bpmn:incoming>Flow_01x96w8</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_05tzoiy</bpmn:outgoing>
|
||||
</bpmn:manualTask>
|
||||
<bpmn:endEvent id="Event_074ypt0">
|
||||
<bpmn:incoming>Flow_05tzoiy</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="Flow_05tzoiy" sourceRef="Activity_Display_Color" targetRef="Event_074ypt0" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_a7f16c2">
|
||||
<bpmndi:BPMNEdge id="Flow_05tzoiy_di" bpmnElement="Flow_05tzoiy">
|
||||
<di:waypoint x="850" y="117" />
|
||||
<di:waypoint x="912" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_01x96w8_di" bpmnElement="Flow_01x96w8">
|
||||
<di:waypoint x="690" y="117" />
|
||||
<di:waypoint x="750" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_1d7sv9v_di" bpmnElement="Flow_1d7sv9v">
|
||||
<di:waypoint x="530" y="117" />
|
||||
<di:waypoint x="590" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_0d46qnz_di" bpmnElement="Flow_0d46qnz">
|
||||
<di:waypoint x="370" y="117" />
|
||||
<di:waypoint x="430" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_02xzhf3_di" bpmnElement="Flow_02xzhf3">
|
||||
<di:waypoint x="215" y="117" />
|
||||
<di:waypoint x="270" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
||||
<dc:Bounds x="179" y="99" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_0xfaikf_di" bpmnElement="Activity_UserInput">
|
||||
<dc:Bounds x="270" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_16u20va_di" bpmnElement="Activity_DecisionLookup">
|
||||
<dc:Bounds x="430" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_0dpzpf2_di" bpmnElement="Activity_PickColor">
|
||||
<dc:Bounds x="590" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_157v5xp_di" bpmnElement="Activity_Display_Color">
|
||||
<dc:Bounds x="750" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_074ypt0_di" bpmnElement="Event_074ypt0">
|
||||
<dc:Bounds x="912" y="99" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -1,4 +1,5 @@
|
|||
from tests.base_test import BaseTest
|
||||
import json
|
||||
|
||||
|
||||
class TestWorkflowEnumDefault(BaseTest):
|
||||
|
@ -36,3 +37,10 @@ class TestWorkflowEnumDefault(BaseTest):
|
|||
workflow_api = self.get_workflow_api(workflow)
|
||||
self.assertEqual('Activity_PickColor', self.get_workflow_api(workflow_api).next_task.name)
|
||||
self.assertEqual({'value': 'white', 'label': 'White'}, workflow_api.next_task.data['color_select'])
|
||||
|
||||
def test_enum_value_expression_and_default(self):
|
||||
spec_model = self.load_test_spec('enum_value_expression_fail')
|
||||
rv = self.app.get('/v1.0/workflow-specification/%s/validate' % spec_model.id, headers=self.logged_in_headers())
|
||||
|
||||
json_data = json.loads(rv.get_data(as_text=True))
|
||||
self.assertEqual(json_data[0]['code'], 'default value and value_expression')
|
||||
|
|
Loading…
Reference in New Issue