camunda-workflow 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba961748beb590604ec47e0044a1ce7fa50f97d45bec52652a0e528011e4b2f3
4
- data.tar.gz: 3886388d63f770a0fa49686489cbb5a82e3884df697d52cbb9c28582ac5dd867
3
+ metadata.gz: 58f9e45eda5edf72f257ab51baba32f2220b0827a288d7a8b2ab273ff2835738
4
+ data.tar.gz: db225b2cda8437c4bec69cf70f351037174c35bef5a0dbf57155162e813ff996
5
5
  SHA512:
6
- metadata.gz: fc768ad2478ce728101e69d6c891e53e0045a0ea266a0c2d87d87109f0692cc9d7b3c554f4048c261d96d06e23c3c4f2b66a1054ceeb8f8804bcf3de1748bc05
7
- data.tar.gz: de9541842d8c4158a7bf7553a527ffd25a67fdd7dfb6d1b1da8fa5fe713cb58f01c41f0f2dc1d91984b903aae95d77c91b98ea1120661fcb2dd1d37109ec2420
6
+ metadata.gz: 184e3cca0f5ac05638470045b50aa053a7f31ff36be976e8ed429d5bdd6b4270643e8b2d79d38fb448f8d256ce5d6e7f8c9b303e12451c43e05609ac174e2344
7
+ data.tar.gz: 73b2bb72fa227bf85cd9fe5f9d54e3f61040b9760d0157d43ea90530de12fb4856b51aa7869fd45aeffb13cdfa84b2fc509b803a255af2352edc6ca47c25f72f
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  ## An opinionated interface to Camunda for Ruby/Rails apps
7
7
 
8
- [Her](https://github.com/remiprev/her) is used to communicate with the [Camunda REST API](https://docs.camunda.org/manual/latest/reference/rest/).
8
+ [Her](https://github.com/remiprev/her) is used to communicate with the [Camunda REST API](https://docs.camunda.org/manual/latest/reference/rest/) with a Ruby class corresponding to a Camunda external task.
9
9
 
10
10
  ### Add to your Gemfile
11
11
  ```ruby
@@ -13,9 +13,16 @@
13
13
  ```
14
14
 
15
15
  ## Camunda Integration with Ruby
16
- The process definitions key becomes the module name of your implementation classes and must be set to the name of a ruby style constant (screenshot example provided below). This same process definition key should be set as the topic name for external tasks. Tasks are pulled and fetched and locked and then run. We expect classes (ActiveJob) to implement each external task.
16
+ The process definitions key becomes the module name of your implementation classes and must be set to the name of a ruby style constant.
17
17
 
18
- ![image](https://www.evernote.com/l/Ajnoawx6CYhKha7OXUPkyeo6CjrxvSoTgOUB/image.png)
18
+ ![image](https://user-images.githubusercontent.com/498234/70742441-899ecf00-1ceb-11ea-9eb8-42dbb08dbd2d.png)
19
+
20
+
21
+ An external task is created with a Ruby class name for the id. And the process definition key should be set as the topic name.
22
+
23
+ ![image](https://user-images.githubusercontent.com/498234/70742635-fd40dc00-1ceb-11ea-8518-0fa5f6ea8028.png)
24
+
25
+ Tasks are pulled and fetched and locked and then run. We expect classes (ActiveJob) to implement each external task.
19
26
 
20
27
  ### Integration with your worker classes
21
28
 
@@ -64,7 +71,36 @@ allows one to have some tasks be handled outside the Rails app. It confirms that
64
71
 
65
72
  #### Starting the Camunda server for development
66
73
 
67
- Start the application: `mvn spring-boot:run`
74
+ [Java 7](https://www.java.com/en/) and [Apache Maven](https://maven.apache.org/install.html) are requirements to run
75
+ [Spring](https://docs.spring.io/spring-boot/docs/1.5.21.RELEASE/reference/html/getting-started-system-requirements.html).
76
+ Make sure all requirements for Spring are satisfied before starting Camunda engine via spring boot.
77
+
78
+ Start the application:
79
+ ```bash
80
+ cd bpmn/java_app
81
+ ```
82
+ ```bash
83
+ mvn spring-boot:run
84
+ ```
85
+ The following Rake commands are available to maintain the spring boot server.
86
+
87
+ ```Bash
88
+ # Install the spring-boot app dependencies.
89
+ rake camunda:install
90
+ ```
91
+ We suggest (not required) running the install command before running the spring boot server for the first time or if the pom.xml file is updated. The
92
+ install cleans up artifacts created by prior builds and installs the package dependencies into the local repository.
93
+
94
+ ```bash
95
+ # Start the Camunda spring boot app
96
+ rake camunda:run
97
+ ```
98
+
99
+ ```bash
100
+ # Runs spring boot test suite
101
+ rake camunda:test
102
+ ```
103
+
68
104
 
69
105
  Camunda-workflow defaults to an in-memory, h2 database engine. If you rather use a Postgres database engine, comment out the
70
106
  h2 database engine settings in the `pom.xml` file located in `bpmn/java_app`. Default settings for using Postgres are available in the `pom.xml` file.
@@ -110,7 +146,10 @@ The jar is in `target/camunda-bpm-springboot.jar`
110
146
  It will fail to start. Create a postgres database as a service in PCF and bind it to the application. The Springboot application is configured for Postgres and will then be able to start.
111
147
 
112
148
  #### Running java unit tests
113
- `mvn clean test`
149
+ ```bash
150
+ # Run in bpmn/java_app directory
151
+ mvn clean test
152
+ ```
114
153
 
115
154
  ## Usage
116
155
  ### Deploying a model
@@ -1,5 +1,5 @@
1
1
  module Camunda
2
2
  module Workflow
3
- VERSION = '0.1.4'.freeze
3
+ VERSION = '0.1.5'.freeze
4
4
  end
5
5
  end
@@ -7,23 +7,33 @@ module Camunda
7
7
  source_root File.expand_path('templates', __dir__)
8
8
  class_option :app_path, type: :string, default: 'bpmn/java_app'
9
9
  class_option :diagram_path, type: :string, default: 'bpmn/diagrams'
10
- # Copys all spring boot files into a rails application and provides a Camunda engine for testing.
10
+
11
+ # Links resources to a top level diagrams folder
12
+ def link_resources_folder
13
+ create_link File.join(bpmn_app_path, 'src/main/resources/'), File.join('../../../diagrams')
14
+ end
15
+
16
+ # Copies a sample bpmn file to help demonstrate the usage for camunda-workflow
17
+ def copy_sample_bpmn
18
+ copy_file 'sample.bpmn', File.join(diagram_path, 'sample.bpmn'), ''
19
+ copy_file 'ProcessScenarioTest.java', File.join(bpmn_app_path, 'src/test/java/unittest/ProcessScenarioTest.java')
20
+ end
21
+
22
+ # Copies all spring boot files into a rails application and provides a Camunda engine for testing.
11
23
  def copy_java_app_files
12
24
  copy_file 'pom.xml', File.join(bpmn_app_path, 'pom.xml')
13
25
  copy_file 'camunda.cfg.xml', File.join(bpmn_app_path, 'src/test/resources/camunda.cfg.xml')
26
+ copy_file 'logback.xml', File.join(bpmn_app_path, 'src/main/resources/logback.xml')
14
27
  copy_file 'application.properties', File.join(bpmn_app_path, 'src/main/resources/application.properties')
15
- copy_file 'ProcessScenarioTest.java', File.join(bpmn_app_path, 'src/test/java/unittest/ProcessScenarioTest.java')
16
28
  copy_file 'Camunda.java', File.join(bpmn_app_path, 'src/main/java/camunda/Camunda.java')
17
- end
18
-
19
- # Copys a sample bpmn file to help demonstrate the usage for camunda-workflow
20
- def link_resources_folder
21
- copy_file 'sample.bpmn', File.join(diagram_path, 'sample.bpmn'), ''
29
+ copy_file 'camunda.rake', 'lib/tasks/camunda.rake'
22
30
  end
23
31
 
24
32
  # Add spring boot files to .gitignore
25
33
  def add_to_ignores
26
- %w[.gitignore .cfignore].each do |file|
34
+ ignores = %w[.gitignore]
35
+ ignores << '.cfignore' if File.exist?('.cfignore')
36
+ ignores.each do |file|
27
37
  append_to_file file do
28
38
  "\n# BPMN Java app\n" +
29
39
  File.join(bpmn_app_path, 'target') +
@@ -1,11 +1,20 @@
1
- package example;
1
+ /*
2
+ * Process Scenario Test is a working example on how test bpmn files using
3
+ * camunda-bpm-assert-scenario. It uses the sample.bpmn file supplied with
4
+ * the generator and test the processes.
5
+ */
6
+
7
+ package camunda;
2
8
 
3
- import org.apache.ibatis.logging.LogFactory;
4
- import org.camunda.bpm.engine.ProcessEngine;
5
9
  import org.camunda.bpm.engine.test.Deployment;
6
10
  import org.camunda.bpm.engine.test.ProcessEngineRule;
11
+ import org.camunda.bpm.engine.variable.Variables;
12
+ import org.camunda.bpm.extension.process_test_coverage.junit.rules.TestCoverageProcessEngineRuleBuilder;
7
13
  import org.camunda.bpm.scenario.ProcessScenario;
8
- import org.camunda.bpm.spring.boot.starter.test.helper.StandaloneInMemoryTestConfiguration;
14
+ import org.camunda.bpm.scenario.Scenario;
15
+ import org.springframework.boot.test.context.SpringBootTest;
16
+ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
17
+ import org.springframework.test.context.junit4.SpringRunner;
9
18
  import org.junit.Before;
10
19
  import org.junit.ClassRule;
11
20
  import org.junit.Rule;
@@ -13,73 +22,50 @@ import org.junit.Test;
13
22
  import org.junit.runner.RunWith;
14
23
  import org.mockito.Mock;
15
24
  import org.mockito.MockitoAnnotations;
16
- import org.springframework.beans.factory.annotation.Autowired;
17
- import org.springframework.boot.test.context.SpringBootTest;
18
- import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
19
- import org.springframework.test.context.junit4.SpringRunner;
20
- import org.camunda.bpm.extension.process_test_coverage.junit.rules.TestCoverageProcessEngineRuleBuilder;
21
25
 
22
- import javax.annotation.PostConstruct;
23
-
24
- import static org.mockito.Matchers.*;
25
- import static org.mockito.Mockito.*;
26
+ import java.util.Map;
26
27
 
27
- import static org.junit.Assert.*;
28
- import static org.assertj.core.api.Assertions.*;
29
28
  import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
29
+ import static org.mockito.Mockito.*;
30
30
 
31
- /**
32
- * Test case starting an in-memory database-backed Process Engine.
33
- */
34
- @RunWith(SpringRunner.class)
31
+ @Deployment(resources = {
32
+ "sample.bpmn"
33
+ })
34
+ // Disabled SpringRunner for test until a graceful delayed solution for shutting down h2:mem database is in place.
35
+ // Test are run in multi processes so using DB_CLOSE_DELAY=-1 doesn't work.
36
+ //@RunWith(SpringRunner.class)
35
37
  @SpringBootTest(webEnvironment = WebEnvironment.NONE)
36
38
  public class ProcessScenarioTest {
39
+ @Rule
40
+ @ClassRule
41
+ public static ProcessEngineRule rule =
42
+ TestCoverageProcessEngineRuleBuilder.create()
43
+ .withDetailedCoverageLogging().build();
37
44
 
38
- private static final String PROCESS_DEFINITION_KEY = "timer";
39
-
40
- static {
41
- LogFactory.useSlf4jLogging(); // MyBatis
42
- }
43
-
44
- @Autowired
45
- ProcessEngine processEngine;
45
+ // Mock all waitstates in main process and call activity with a scenario
46
+ @Mock private ProcessScenario camundaWorkflow;
47
+ private Map<String, Object> variables;
46
48
 
47
- @Rule
48
- @ClassRule
49
- public static ProcessEngineRule rule;
50
49
 
51
- @Before
52
- public void setup() {
53
- MockitoAnnotations.initMocks(this);
54
- }
50
+ @Before
51
+ public void setupDefaultScenario() {
52
+ // Define scenarios by using camunda-bpm-assert-scenario:
53
+ MockitoAnnotations.initMocks(this);
55
54
 
56
- @Mock
57
- private ProcessScenario process;
55
+ when(camundaWorkflow.waitsAtUserTask("UserTask")).thenReturn((task) -> {
56
+ task.complete(withVariables("foo", "bar"));
57
+ });
58
58
 
59
- @PostConstruct
60
- void initRule() {
61
- rule = TestCoverageProcessEngineRuleBuilder.create(processEngine).build();
59
+ when(camundaWorkflow.waitsAtServiceTask("DoSomething")).thenReturn((task) -> {
60
+ task.complete(withVariables("approve", true));
61
+ });
62
62
  }
63
63
 
64
64
  @Test
65
- public void testHappyPath() {
66
- // Define scenarios by using camunda-bpm-assert-scenario:
67
-
68
- //ExecutableRunner starter = Scenario.run(myProcess) //
69
- // .startByKey(PROCESS_DEFINITION_KEY);
70
-
71
- // when(myProcess.waitsAtReceiveTask(anyString())).thenReturn((messageSubscription) -> {
72
- // messageSubscription.receive();
73
- // });
74
- // when(myProcess.waitsAtUserTask(anyString())).thenReturn((task) -> {
75
- // task.complete();
76
- // });
77
-
65
+ public void testHappyPath(){
66
+ //ExecutableRunner starter = Scenario.run(myProcess)
78
67
  // OK - everything prepared - let's go and execute the scenario
79
- //Scenario scenario = starter.execute();
80
-
81
- // now you can do some assertions
82
- //verify(myProcess).hasFinished("EndEvent");
83
- }
84
-
85
- }
68
+ Scenario.run(camundaWorkflow).startByKey("CamundaWorkflow").execute();
69
+ verify(camundaWorkflow).hasFinished("EndEventProcessEnded");
70
+ }
71
+ }
@@ -1,7 +1,7 @@
1
1
  #spring.datasource.url=jdbc:h2:./camunda-db;DB_CLOSE_ON_EXIT=false
2
2
 
3
3
 
4
-
4
+ #DB_CLOSE_ON_EXIT is set to false to prevent the database from shutting down before test are complete.
5
5
  spring.datasource.url=jdbc:h2:mem:camunda
6
6
  spring.datasource.username=sa
7
7
  spring.datasource.password=sa
@@ -0,0 +1,25 @@
1
+ # Runs Camunda spring-boot commands using rake.
2
+
3
+ task default: %w[run]
4
+
5
+ namespace :camunda do
6
+ # Path for the spring boot application.
7
+ mvn_path = 'bpmn/java_app'
8
+
9
+ # Starts the camunda engine e.g. mvn spring-boot:run.
10
+ desc 'Starts the Camunda spring-boot application.'
11
+ task :run do
12
+ system('mvn spring-boot:run', chdir: mvn_path)
13
+ end
14
+
15
+ # Runs spring boot test suite e.g. mvn test.
16
+ desc 'Runs test suite for Camunda spring-boot application'
17
+ task :test do
18
+ system('mvn test', chdir: mvn_path)
19
+ end
20
+ # Installs the spring-boot app dependencies mvn clean install.
21
+ desc 'Installs spring-boot dependencies for Camunda spring-boot app.'
22
+ task :install do
23
+ system('mvn clean install -DskipTests=true', chdir: mvn_path)
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ <configuration>
2
+
3
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4
+ <!-- encoders are assigned the type
5
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
6
+ <encoder>
7
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
8
+ </encoder>
9
+ </appender>
10
+
11
+ <logger name="org.camunda.bpm.scenario" level="debug" />
12
+ <logger name="org.camunda.bpm.engine.cmd" level="warn" />
13
+ <logger name="org.camunda.bpm.engine.cfg" level="warn" />
14
+ <logger name="org.camunda.bpm.engine.test" level="warn" />
15
+ <logger name="org.camunda.bpm.engine.bpmn.behavior" level="warn" />
16
+ <logger name="org.camunda.bpm.engine.cmmn.behavior" level="warn" />
17
+
18
+ <root level="warn">
19
+ <appender-ref ref="STDOUT" />
20
+ </root>
21
+
22
+ </configuration>
@@ -20,7 +20,7 @@
20
20
  and EE repository below
21
21
  -->
22
22
  <camundaSpringBoot.version>3.3.1</camundaSpringBoot.version>
23
- <springBoot.version>2.1.5.RELEASE</springBoot.version>
23
+ <springBoot.version>2.2.1.RELEASE</springBoot.version>
24
24
 
25
25
  <maven.compiler.source>1.8</maven.compiler.source>
26
26
  <maven.compiler.target>1.8</maven.compiler.target>
@@ -125,6 +125,12 @@
125
125
  <artifactId>jul-to-slf4j</artifactId>
126
126
  <scope>test</scope>
127
127
  </dependency>
128
+ <!-- Logback logging for better camunda-bpm-assert-scenario tests -->
129
+ <dependency>
130
+ <groupId>ch.qos.logback</groupId>
131
+ <artifactId>logback-classic</artifactId>
132
+ <version>1.2.3</version>
133
+ </dependency>
128
134
 
129
135
  <!-- Add your own dependencies here, if in compile scope, they are added to the jar -->
130
136
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camunda-workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ankur Sethi
@@ -179,6 +179,20 @@ dependencies:
179
179
  - - "~>"
180
180
  - !ruby/object:Gem::Version
181
181
  version: 5.0.0
182
+ - !ruby/object:Gem::Dependency
183
+ name: yard
184
+ requirement: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - "~>"
187
+ - !ruby/object:Gem::Version
188
+ version: 0.9.20
189
+ type: :development
190
+ prerelease: false
191
+ version_requirements: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - "~>"
194
+ - !ruby/object:Gem::Version
195
+ version: 0.9.20
182
196
  description: Integrate Camunda with Ruby via its REST api by expecting a Ruby class
183
197
  for each external task.
184
198
  email: []
@@ -219,6 +233,8 @@ files:
219
233
  - lib/generators/camunda/spring_boot/templates/ProcessScenarioTest.java
220
234
  - lib/generators/camunda/spring_boot/templates/application.properties
221
235
  - lib/generators/camunda/spring_boot/templates/camunda.cfg.xml
236
+ - lib/generators/camunda/spring_boot/templates/camunda.rake
237
+ - lib/generators/camunda/spring_boot/templates/logback.xml
222
238
  - lib/generators/camunda/spring_boot/templates/pom.xml
223
239
  - lib/generators/camunda/spring_boot/templates/sample.bpmn
224
240
  homepage: https://github.com/amalagaura/camunda-workflow