11package com .example .activitiwithspring ;
22
3- import static org .junit .Assert .assertEquals ;
4-
5- import java .util .Arrays ;
6- import java .util .List ;
7-
3+ import com .fasterxml .jackson .databind .ObjectMapper ;
84import org .activiti .engine .RuntimeService ;
95import org .activiti .engine .runtime .ProcessInstance ;
106import org .junit .Before ;
2117import org .springframework .test .web .servlet .setup .MockMvcBuilders ;
2218import org .springframework .web .context .WebApplicationContext ;
2319
24- import com .fasterxml .jackson .databind .ObjectMapper ;
20+ import java .util .Arrays ;
21+ import java .util .List ;
22+
23+ import static org .junit .Assert .assertEquals ;
2524
2625@ RunWith (SpringJUnit4ClassRunner .class )
2726@ WebAppConfiguration
2827@ SpringBootTest
29- public class ActivitiControllerTest {
30- private static final Logger logger = LoggerFactory .getLogger (ActivitiControllerTest .class );
28+ public class ActivitiControllerIntegrationTest {
29+ private static final Logger logger = LoggerFactory .getLogger (ActivitiControllerIntegrationTest .class );
3130 private MockMvc mockMvc ;
3231
3332 @ Autowired
@@ -39,10 +38,10 @@ public class ActivitiControllerTest {
3938 @ Before
4039 public void setUp () {
4140 this .mockMvc = MockMvcBuilders .webAppContextSetup (this .wac )
42- .build ();
41+ .build ();
4342
4443 for (ProcessInstance instance : runtimeService .createProcessInstanceQuery ()
45- .list ()) {
44+ .list ()) {
4645 runtimeService .deleteProcessInstance (instance .getId (), "Reset Processes" );
4746 }
4847 }
@@ -51,41 +50,41 @@ public void setUp() {
5150 public void givenProcess_whenStartProcess_thenIncreaseInProcessInstanceCount () throws Exception {
5251
5352 String responseBody = this .mockMvc .perform (MockMvcRequestBuilders .get ("/start-process" ))
54- .andReturn ()
55- .getResponse ()
56- .getContentAsString ();
53+ .andReturn ()
54+ .getResponse ()
55+ .getContentAsString ();
5756 assertEquals ("Process started. Number of currently running process instances = 1" , responseBody );
5857
5958 responseBody = this .mockMvc .perform (MockMvcRequestBuilders .get ("/start-process" ))
60- .andReturn ()
61- .getResponse ()
62- .getContentAsString ();
59+ .andReturn ()
60+ .getResponse ()
61+ .getContentAsString ();
6362 assertEquals ("Process started. Number of currently running process instances = 2" , responseBody );
6463
6564 responseBody = this .mockMvc .perform (MockMvcRequestBuilders .get ("/start-process" ))
66- .andReturn ()
67- .getResponse ()
68- .getContentAsString ();
65+ .andReturn ()
66+ .getResponse ()
67+ .getContentAsString ();
6968 assertEquals ("Process started. Number of currently running process instances = 3" , responseBody );
7069 }
7170
7271 @ Test
7372 public void givenProcess_whenProcessInstance_thenReceivedRunningTask () throws Exception {
7473
7574 this .mockMvc .perform (MockMvcRequestBuilders .get ("/start-process" ))
76- .andReturn ()
77- .getResponse ();
75+ .andReturn ()
76+ .getResponse ();
7877 ProcessInstance pi = runtimeService .createProcessInstanceQuery ()
79- .orderByProcessInstanceId ()
80- .desc ()
81- .list ()
82- .get (0 );
78+ .orderByProcessInstanceId ()
79+ .desc ()
80+ .list ()
81+ .get (0 );
8382
8483 logger .info ("process instance = " + pi .getId ());
8584 String responseBody = this .mockMvc .perform (MockMvcRequestBuilders .get ("/get-tasks/" + pi .getId ()))
86- .andReturn ()
87- .getResponse ()
88- .getContentAsString ();
85+ .andReturn ()
86+ .getResponse ()
87+ .getContentAsString ();
8988
9089 ObjectMapper mapper = new ObjectMapper ();
9190 List <TaskRepresentation > tasks = Arrays .asList (mapper .readValue (responseBody , TaskRepresentation [].class ));
@@ -98,19 +97,19 @@ public void givenProcess_whenProcessInstance_thenReceivedRunningTask() throws Ex
9897 public void givenProcess_whenCompleteTaskA_thenReceivedNextTask () throws Exception {
9998
10099 this .mockMvc .perform (MockMvcRequestBuilders .get ("/start-process" ))
101- .andReturn ()
102- .getResponse ();
100+ .andReturn ()
101+ .getResponse ();
103102 ProcessInstance pi = runtimeService .createProcessInstanceQuery ()
104- .orderByProcessInstanceId ()
105- .desc ()
106- .list ()
107- .get (0 );
103+ .orderByProcessInstanceId ()
104+ .desc ()
105+ .list ()
106+ .get (0 );
108107
109108 logger .info ("process instance = " + pi .getId ());
110109 String responseBody = this .mockMvc .perform (MockMvcRequestBuilders .get ("/complete-task-A/" + pi .getId ()))
111- .andReturn ()
112- .getResponse ()
113- .getContentAsString ();
110+ .andReturn ()
111+ .getResponse ()
112+ .getContentAsString ();
114113
115114 ObjectMapper mapper = new ObjectMapper ();
116115 TaskRepresentation task = mapper .readValue (responseBody , TaskRepresentation .class );
0 commit comments