1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.fit.core;
20
21 import static org.junit.jupiter.api.Assertions.assertFalse;
22 import static org.junit.jupiter.api.Assertions.assertNotNull;
23 import static org.junit.jupiter.api.Assertions.assertTrue;
24 import static org.junit.jupiter.api.Assumptions.assumeFalse;
25 import static org.junit.jupiter.api.Assumptions.assumeTrue;
26
27 import java.io.IOException;
28 import javax.ws.rs.core.Response;
29 import org.apache.syncope.client.lib.SyncopeClientFactoryBean;
30 import org.apache.syncope.common.lib.to.BpmnProcess;
31 import org.apache.syncope.fit.AbstractITCase;
32 import org.junit.jupiter.api.BeforeAll;
33 import org.junit.jupiter.api.BeforeEach;
34 import org.junit.jupiter.api.Test;
35
36 public class BpmnProcessITCase extends AbstractITCase {
37
38 private static String USER_WORKFLOW_KEY = null;
39
40 @BeforeAll
41 public static void findDefault() {
42 assumeFalse(CLIENT_FACTORY.getContentType() == SyncopeClientFactoryBean.ContentType.YAML);
43 assumeTrue(IS_FLOWABLE_ENABLED);
44
45 BPMN_PROCESS_SERVICE.list().stream().
46 filter(BpmnProcess::isUserWorkflow).findAny().
47 ifPresent(process -> USER_WORKFLOW_KEY = process.getKey());
48 assertNotNull(USER_WORKFLOW_KEY);
49 }
50
51 @BeforeEach
52 public void check() {
53 assumeFalse(CLIENT_FACTORY.getContentType() == SyncopeClientFactoryBean.ContentType.YAML);
54 assumeTrue(IS_FLOWABLE_ENABLED);
55 }
56
57 @Test
58 public void exportUserWorkflowProcess() throws IOException {
59 Response response = BPMN_PROCESS_SERVICE.get(USER_WORKFLOW_KEY);
60 assertTrue(response.getMediaType().toString().
61 startsWith(CLIENT_FACTORY.getContentType().getMediaType().toString()));
62 String definition = response.readEntity(String.class);
63 assertNotNull(definition);
64 assertFalse(definition.isEmpty());
65 }
66
67 @Test
68 public void updateUserWorkflowProcess() throws IOException {
69 Response response = BPMN_PROCESS_SERVICE.get(USER_WORKFLOW_KEY);
70 String definition = response.readEntity(String.class);
71
72 BPMN_PROCESS_SERVICE.set(USER_WORKFLOW_KEY, definition);
73 }
74 }