Skip to content

Commit

Permalink
since PRO now sends us data{start_task: true} we can set this
Browse files Browse the repository at this point in the history
on the lane activity.
  • Loading branch information
apotonick committed Dec 9, 2023
1 parent 0d3d349 commit 61ad8f5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/trailblazer/workflow/collaboration/lane.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def self.Lane(intermediate, **tuples)
implementation_task =
case task_ref.data[:type]
when :start_event
Lane.compile_start_event(task_ref, links)
Lane.compile_start_event(task_ref, links) # TODO: test explicit start event in json or remove this!
when :task
# run some kind of Normalizer for tasks
id = task_ref.id
Expand Down
4 changes: 2 additions & 2 deletions lib/trailblazer/workflow/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def self.find_start_event(ctx, lane:, **)
ctx[:start_event] = lane.elements.find { |el| el.id == "Start" }
end

# DISCUSS: do we "want" this, should we handle that in the export/convert code and create some Start event?
# In the PRO JSON, usually a catch event is marked as {start_task: true}.
def self.default_start_event(ctx, lane:, **)
ctx[:start_event] = lane.elements[0]
ctx[:start_event] = lane.elements.find { |node| node.data["start_task"] } || raise("no default start event found") # TODO: raise not tested.
end

def self.compute_termini_map(ctx, lane:, **)
Expand Down
10 changes: 7 additions & 3 deletions test/lane_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ def update_with_circuit_interface((ctx, flow_options), **)
#<Trailblazer::Workflow::Event::Throw/[:throw, "Event_1oucl4z"]>
{Trailblazer::Activity::Right} => #<Trailblazer::Workflow::Event::Suspend/[:suspend, "suspend-Gateway_01p7uj7"]>
#<Trailblazer::Activity::TaskBuilder::Task user_proc=#<Method: #<Module:0x>.create>>
{Trailblazer::Activity::Right} => #<Trailblazer::Workflow::Event::Throw/[:throw, "throw-after-Activity_0wwfenp"]>
{Trailblazer::Activity::Left} => #<Trailblazer::Workflow::Event::Throw/[:throw, "Event_0odjl3c"]>
#<Method: LaneTest#update_with_circuit_interface(_, **) test/lane_test.rb:18>
{Trailblazer::Activity::Right} => #<Trailblazer::Workflow::Event::Throw/[:throw, "throw-after-Activity_0q9p56e"]>
{Trailblazer::Activity::Left} => #<Trailblazer::Workflow::Event::Throw/[:throw, "Event_0txlti3"]>
Expand All @@ -82,6 +79,9 @@ def update_with_circuit_interface((ctx, flow_options), **)
{Trailblazer::Activity::Left} => #<Trailblazer::Workflow::Event::Throw/[:throw, "Event_1oucl4z"]>
#<Trailblazer::Activity::TaskBuilder::Task user_proc=#<Method: #<Module:0x>.reject>>
{Trailblazer::Activity::Right} => #<Trailblazer::Workflow::Event::Throw/[:throw, "throw-after-Activity_0d9yewp"]>
#<Trailblazer::Activity::TaskBuilder::Task user_proc=#<Method: #<Module:0x>.create>>
{Trailblazer::Activity::Right} => #<Trailblazer::Workflow::Event::Throw/[:throw, "throw-after-Activity_0wwfenp"]>
{Trailblazer::Activity::Left} => #<Trailblazer::Workflow::Event::Throw/[:throw, "Event_0odjl3c"]>
#<Trailblazer::Workflow::Event::Catch/[:catch, "catch-before-Activity_0wwfenp"]>
{Trailblazer::Activity::Right} => #<Trailblazer::Activity::TaskBuilder::Task user_proc=#<Method: #<Module:0x>.create>>
#<Trailblazer::Workflow::Event::Throw/[:throw, "throw-after-Activity_0wwfenp"]>
Expand Down Expand Up @@ -135,6 +135,10 @@ def update_with_circuit_interface((ctx, flow_options), **)
#<Trailblazer::Workflow::Event::Suspend/[:suspend, "suspend-gw-to-catch-before-Activity_1hgscu3"]>
)

#@ test {start_task}
assert_equal lane_activity.to_h[:circuit].to_h[:start_task].inspect, %(#<Trailblazer::Workflow::Event::Catch start_task=true type=:catch_event semantic=[:catch, "catch-before-Activity_0wwfenp"]>)


# it "runs as expected" do

# start_from: ["catch-before-Create"]
Expand Down

0 comments on commit 61ad8f5

Please sign in to comment.