Adding source files for the tutorial BAEL-2788 (#6699)

* Adding source files for the tutorial BAEL-2788

* Made changes to the code for the review comments
This commit is contained in:
Kumar Chandrakant
2019-04-14 22:25:16 +05:30
committed by Grzegorz Piwowarek
parent e89f5ace7a
commit 87e2047eb5
13 changed files with 354 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
package com.baeldung.processes;
import static org.junit.Assert.assertEquals;
import java.util.HashMap;
import java.util.Map;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.test.Deployment;
import org.flowable.spring.impl.test.FlowableSpringExtension;
import org.flowable.task.api.Task;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(FlowableSpringExtension.class)
@ExtendWith(SpringExtension.class)
public class ArticleWorkflowUnitTest {
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@Test
@Deployment(resources = { "processes/article-workflow.bpmn20.xml" })
void articleApprovalTest() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("author", "test@baeldung.com");
variables.put("url", "http://baeldung.com/dummy");
runtimeService.startProcessInstanceByKey("articleReview", variables);
Task task = taskService.createTaskQuery()
.singleResult();
assertEquals("Review the submitted tutorial", task.getName());
variables.put("approved", true);
taskService.complete(task.getId(), variables);
assertEquals(0, runtimeService.createProcessInstanceQuery()
.count());
}
}