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:
committed by
Grzegorz Piwowarek
parent
e89f5ace7a
commit
87e2047eb5
@@ -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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user