Build optimization 1.08.2017 (#2351)
* Refactor Spring-activiti module * Refactor vavr module
This commit is contained in:
committed by
GitHub
parent
0c60af8437
commit
ed92182fbf
@@ -53,6 +53,23 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<forkCount>3</forkCount>
|
||||
<reuseForks>true</reuseForks>
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||
<exclude>**/*ManualTest.java</exclude>
|
||||
<exclude>**/JdbcTest.java</exclude>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package com.example.activitiwithspring;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.task.Task;
|
||||
@@ -12,12 +8,15 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
public class ActivitiController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ActivitiController.class);
|
||||
|
||||
@Autowired
|
||||
private RuntimeService runtimeService;
|
||||
|
||||
@@ -28,32 +27,30 @@ public class ActivitiController {
|
||||
public String startProcess() {
|
||||
runtimeService.startProcessInstanceByKey("my-process");
|
||||
return "Process started. Number of currently running process instances = " + runtimeService.createProcessInstanceQuery()
|
||||
.count();
|
||||
.count();
|
||||
}
|
||||
|
||||
@GetMapping("/get-tasks/{processInstanceId}")
|
||||
public List<TaskRepresentation> getTasks(@PathVariable String processInstanceId) {
|
||||
List<Task> usertasks = taskService.createTaskQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.list();
|
||||
.processInstanceId(processInstanceId)
|
||||
.list();
|
||||
|
||||
List<TaskRepresentation> tasks = usertasks.stream().map(task -> {
|
||||
TaskRepresentation taskRepresentation = new TaskRepresentation(task.getId(), task.getName(), task.getProcessInstanceId());
|
||||
return taskRepresentation;
|
||||
}).collect(Collectors.toList());
|
||||
return tasks;
|
||||
return usertasks.stream()
|
||||
.map(task -> new TaskRepresentation(task.getId(), task.getName(), task.getProcessInstanceId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@GetMapping("/complete-task-A/{processInstanceId}")
|
||||
public TaskRepresentation completeTaskA(@PathVariable String processInstanceId) {
|
||||
Task task = taskService.createTaskQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
taskService.complete(task.getId());
|
||||
logger.info("Task completed");
|
||||
task = taskService.createTaskQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
|
||||
return new TaskRepresentation(task.getId(), task.getName(), task.getProcessInstanceId());
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ActivitiWithSpringApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ActivitiWithSpringApplication.class, args);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package com.example.activitiwithspring;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.junit.Before;
|
||||
@@ -21,13 +17,16 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@WebAppConfiguration
|
||||
@SpringBootTest
|
||||
public class ActivitiControllerTest {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ActivitiControllerTest.class);
|
||||
public class ActivitiControllerIntegrationTest {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ActivitiControllerIntegrationTest.class);
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Autowired
|
||||
@@ -39,10 +38,10 @@ public class ActivitiControllerTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac)
|
||||
.build();
|
||||
.build();
|
||||
|
||||
for (ProcessInstance instance : runtimeService.createProcessInstanceQuery()
|
||||
.list()) {
|
||||
.list()) {
|
||||
runtimeService.deleteProcessInstance(instance.getId(), "Reset Processes");
|
||||
}
|
||||
}
|
||||
@@ -51,21 +50,21 @@ public class ActivitiControllerTest {
|
||||
public void givenProcess_whenStartProcess_thenIncreaseInProcessInstanceCount() throws Exception {
|
||||
|
||||
String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/start-process"))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
assertEquals("Process started. Number of currently running process instances = 1", responseBody);
|
||||
|
||||
responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/start-process"))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
assertEquals("Process started. Number of currently running process instances = 2", responseBody);
|
||||
|
||||
responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/start-process"))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
assertEquals("Process started. Number of currently running process instances = 3", responseBody);
|
||||
}
|
||||
|
||||
@@ -73,19 +72,19 @@ public class ActivitiControllerTest {
|
||||
public void givenProcess_whenProcessInstance_thenReceivedRunningTask() throws Exception {
|
||||
|
||||
this.mockMvc.perform(MockMvcRequestBuilders.get("/start-process"))
|
||||
.andReturn()
|
||||
.getResponse();
|
||||
.andReturn()
|
||||
.getResponse();
|
||||
ProcessInstance pi = runtimeService.createProcessInstanceQuery()
|
||||
.orderByProcessInstanceId()
|
||||
.desc()
|
||||
.list()
|
||||
.get(0);
|
||||
.orderByProcessInstanceId()
|
||||
.desc()
|
||||
.list()
|
||||
.get(0);
|
||||
|
||||
logger.info("process instance = " + pi.getId());
|
||||
String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/get-tasks/" + pi.getId()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
List<TaskRepresentation> tasks = Arrays.asList(mapper.readValue(responseBody, TaskRepresentation[].class));
|
||||
@@ -98,19 +97,19 @@ public class ActivitiControllerTest {
|
||||
public void givenProcess_whenCompleteTaskA_thenReceivedNextTask() throws Exception {
|
||||
|
||||
this.mockMvc.perform(MockMvcRequestBuilders.get("/start-process"))
|
||||
.andReturn()
|
||||
.getResponse();
|
||||
.andReturn()
|
||||
.getResponse();
|
||||
ProcessInstance pi = runtimeService.createProcessInstanceQuery()
|
||||
.orderByProcessInstanceId()
|
||||
.desc()
|
||||
.list()
|
||||
.get(0);
|
||||
.orderByProcessInstanceId()
|
||||
.desc()
|
||||
.list()
|
||||
.get(0);
|
||||
|
||||
logger.info("process instance = " + pi.getId());
|
||||
String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/complete-task-A/" + pi.getId()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
TaskRepresentation task = mapper.readValue(responseBody, TaskRepresentation.class);
|
||||
@@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class ActivitiWithSpringApplicationTests {
|
||||
public class ActivitiWithSpringApplicationIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
Reference in New Issue
Block a user