Skip to content

Commit 8c6bc52

Browse files
authored
Merge pull request #141 from folio-org/master
Sync with aggies sprint 10.
2 parents b3efed2 + f2e8baa commit 8c6bc52

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3464
-13551
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,4 @@ hs_err_pid*
7070

7171
.DS_Store
7272

73-
activemq-data/
7473
service/dependency-reduced-pom.xml

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,49 @@ docker build -t [docker repo]/folio/mod-workflow:[version] .
3535
docker push [docker repo]/folio/mod-workflow:[version]
3636
```
3737

38+
### Environment variables:
39+
40+
The environment variables most notable to deployment are described in the [Module Descriptor](https://github.com/folio-org/mod-workflow/blob/master/service/descriptors/ModuleDescriptor-template.json).
41+
42+
The following is a summary of many of them.
43+
44+
| Name | Default value | Description |
45+
|:-------------------------------|:---------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------|
46+
| DB_CHARSET | UTF-8 | Database charset. |
47+
| DB_DATABASE | okapi_modules | Postgres database name. |
48+
| DB_HOST | postgres | Postgres host name. |
49+
| DB_MAXPOOLSIZE | 5 | Database max pool size. |
50+
| DB_PASSWORD | - | Postgres user password. |
51+
| DB_PORT | 5432 | Postgres port. |
52+
| DB_QUERYTIMEOUT | 60000 | Database query timeout. |
53+
| DB_USERNAME | folio_admin | Postgres user name. |
54+
| JAVA_OPTIONS | `-XX:MaxRAMPercentage=75.0` | Java options. |
55+
| KAFKA_HOST | kafka | Kafka broker host name. |
56+
| KAFKA_PORT | 9092 | Kafka broker port. |
57+
| KAFKA_SECURITY_PROTOCOL | PLAINTEXT | Kafka security protocol used to communicate with brokers (SSL or PLAINTEXT). |
58+
| KAFKA_SSL_KEYSTORE_LOCATION | - | The location of the Kafka key store file. This is optional for client and can be used for two-way authentication for client. |
59+
| KAFKA_SSL_KEYSTORE_PASSWORD | - | The store password for the Kafka key store file. This is optional for client and only needed if `ssl.keystore.location` is configured. |
60+
| KAFKA_SSL_TRUSTSTORE_LOCATION | - | The location of the Kafka trust store file. |
61+
| KAFKA_SSL_TRUSTSTORE_PASSWORD | - | The password for the Kafka trust store file. If a password is not set, trust store file configured will still be used, but integrity checking is disabled. |
62+
| OKAPI_URL | `http://okapi:9130` | OKAPI URL used to login system user, required |
63+
| SERVER_PORT | 8081 | The port to listen on that must match the `PortBindings`. |
64+
| SERVER_SERVLET_CONTEXTPATH | / | The context path, or base path, to host at. |
65+
| SPRING_FLYWAY_ENABLED | false | Database migration support via Spring Flyway. |
66+
| SPRING_JPA_HIBERNATE_DDLAUTO | update | Auto-configure database on startup. |
67+
| TENANT_DEFAULTTENANT | diku | The name of the default tenant to use. |
68+
| TENANT_FORCETENANT | false | Forcibly add or overwrite the tenant name using the default tenant. |
69+
| TENANT_INITIALIZEDEFAULTTENANT | true | Perform initial auto-creation of tenant in the database (schema, tables, etc..). |
70+
| TENANT_RECREATEDEFAULTTENANT | false | When `TENANT_INITIALIZEDEFAULTTENANT` is true and the database already exists, then drop and re-create. |
71+
72+
73+
### Permissions
74+
75+
The permissions provided by this module are described in the [Module Descriptor](https://github.com/folio-org/mod-workflow/blob/master/service/descriptors/ModuleDescriptor-template.json) under `permissionSets`.
76+
77+
The permissions defined are here are specific to the module and are usually not directly added to any user.
78+
Instead, permissions available for assignment to users or accounts are found in the [ui-workflow Module Permission Sets](https://github.com/folio-org/ui-workflow/blob/main/package.json).
79+
These [ui-workflow](https://github.com/folio-org/ui-workflow) permissions are automatically exposed via the appropriate [stripe-ui](https://github.com/folio-org/stripes-ui) administration interface.
80+
3881
### Issue tracker
3982

4083
See project [FOLIO](https://issues.folio.org/browse/FOLIO)

components/src/test/java/org/folio/rest/workflow/model/AbstractGatewayTest.java

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
package org.folio.rest.workflow.model;
22

3+
import static org.folio.rest.workflow.enums.Direction.CONVERGING;
4+
import static org.folio.rest.workflow.enums.Direction.UNSPECIFIED;
35
import static org.folio.spring.test.mock.MockMvcConstant.VALUE;
46
import static org.junit.jupiter.api.Assertions.assertEquals;
57
import static org.springframework.test.util.ReflectionTestUtils.getField;
68
import static org.springframework.test.util.ReflectionTestUtils.setField;
79

810
import java.util.ArrayList;
11+
import java.util.HashMap;
912
import java.util.List;
13+
import java.util.Map;
14+
import java.util.stream.Stream;
15+
1016
import org.folio.rest.workflow.enums.Direction;
17+
import org.folio.rest.workflow.enums.InputAttribute;
1118
import org.junit.jupiter.api.BeforeEach;
1219
import org.junit.jupiter.api.Test;
1320
import org.junit.jupiter.api.extension.ExtendWith;
21+
import org.junit.jupiter.params.ParameterizedTest;
22+
import org.junit.jupiter.params.provider.Arguments;
23+
import org.junit.jupiter.params.provider.MethodSource;
1424
import org.mockito.Mock;
1525
import org.mockito.junit.jupiter.MockitoExtension;
1626

@@ -93,17 +103,17 @@ void setDeserializeAsWorksTest() {
93103

94104
@Test
95105
void getDirectionWorksTest() {
96-
setField(abstractGateway, "direction", Direction.CONVERGING);
106+
setField(abstractGateway, "direction", CONVERGING);
97107

98-
assertEquals(Direction.CONVERGING, abstractGateway.getDirection());
108+
assertEquals(CONVERGING, abstractGateway.getDirection());
99109
}
100110

101111
@Test
102112
void setDirectionWorksTest() {
103113
setField(abstractGateway, "direction", null);
104114

105-
abstractGateway.setDirection(Direction.CONVERGING);
106-
assertEquals(Direction.CONVERGING, getField(abstractGateway, "direction"));
115+
abstractGateway.setDirection(CONVERGING);
116+
assertEquals(CONVERGING, getField(abstractGateway, "direction"));
107117
}
108118

109119
@Test
@@ -121,6 +131,72 @@ void setNodesWorksTest() {
121131
assertEquals(nodes, getField(abstractGateway, "nodes"));
122132
}
123133

134+
@ParameterizedTest
135+
@MethodSource("providePrePersistFor")
136+
void prePersistWorksTest(Map<String, Object> initial, Map<String, Object> expected) {
137+
initial.forEach((String attribute, Object value) -> {
138+
setField(abstractGateway, attribute, value);
139+
});
140+
141+
abstractGateway.prePersist();
142+
143+
expected.forEach((String attribute, Object value) -> {
144+
assertEquals(value, getField(abstractGateway, attribute));
145+
});
146+
}
147+
148+
/**
149+
* Helper function for parameterized tests for the prePersist function.
150+
*
151+
* @return
152+
* The arguments array stream with the stream columns as:
153+
* - Arguments initial The initial values.
154+
* - Arguments expect The expected values.
155+
*/
156+
private static Stream<Arguments> providePrePersistFor() {
157+
final List<Node> nodeList = new ArrayList<>();
158+
nodeList.add(new NodeImpl());
159+
160+
final List<Node> emptyList = new ArrayList<>();
161+
162+
final ArrayList<InputAttribute> attrList = new ArrayList<>();
163+
attrList.add(InputAttribute.MAX);
164+
165+
return Stream.of(
166+
Arguments.of(
167+
helperFieldMap(null, null),
168+
helperFieldMap(UNSPECIFIED, emptyList)
169+
),
170+
Arguments.of(
171+
helperFieldMap(CONVERGING, null),
172+
helperFieldMap(CONVERGING, emptyList)
173+
),
174+
Arguments.of(
175+
helperFieldMap(null, nodeList),
176+
helperFieldMap(UNSPECIFIED, nodeList)
177+
)
178+
);
179+
}
180+
181+
/**
182+
* Helper for reducing inline code repititon for assignments.
183+
*
184+
* @param direction The direction value.
185+
* @param nodes The nodes value.
186+
*
187+
* @return The built arguments map.
188+
*/
189+
private static Map<String, Object> helperFieldMap(Direction direction, List<Node> nodes) {
190+
final Map<String, Object> map = new HashMap<>();
191+
192+
map.put("direction", direction);
193+
map.put("nodes", nodes);
194+
195+
return map;
196+
}
197+
124198
private static class Impl extends AbstractGateway { }
125199

200+
private static class NodeImpl extends Node { }
201+
126202
}

components/src/test/java/org/folio/rest/workflow/model/AbstractProcessTest.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@
66
import static org.springframework.test.util.ReflectionTestUtils.setField;
77

88
import java.util.ArrayList;
9+
import java.util.HashMap;
910
import java.util.List;
11+
import java.util.Map;
12+
import java.util.stream.Stream;
1013
import org.junit.jupiter.api.BeforeEach;
1114
import org.junit.jupiter.api.Test;
1215
import org.junit.jupiter.api.extension.ExtendWith;
16+
import org.junit.jupiter.params.ParameterizedTest;
17+
import org.junit.jupiter.params.provider.Arguments;
18+
import org.junit.jupiter.params.provider.MethodSource;
1319
import org.mockito.Mock;
1420
import org.mockito.junit.jupiter.MockitoExtension;
1521

@@ -135,6 +141,75 @@ void setNodesWorksTest() {
135141
assertEquals(nodes, getField(abstractProcess, "nodes"));
136142
}
137143

144+
@ParameterizedTest
145+
@MethodSource("providePrePersistFor")
146+
void prePersistWorksTest(Map<String, Object> initial, Map<String, Object> expected) {
147+
initial.forEach((String attribute, Object value) -> {
148+
setField(abstractProcess, attribute, value);
149+
});
150+
151+
abstractProcess.prePersist();
152+
153+
expected.forEach((String attribute, Object value) -> {
154+
assertEquals(value, getField(abstractProcess, attribute));
155+
});
156+
}
157+
158+
/**
159+
* Helper function for parameterized tests for the prePersist function.
160+
*
161+
* @return
162+
* The arguments array stream with the stream columns as:
163+
* - Arguments initial The initial values.
164+
* - Arguments expect The expected values.
165+
*/
166+
private static Stream<Arguments> providePrePersistFor() {
167+
final List<Node> nodeList = new ArrayList<>();
168+
nodeList.add(new NodeImpl());
169+
170+
final List<Node> emptyList = new ArrayList<>();
171+
172+
return Stream.of(
173+
Arguments.of(
174+
helperFieldMap(null, null, null),
175+
helperFieldMap(false, false, emptyList)
176+
),
177+
Arguments.of(
178+
helperFieldMap(true, null, null),
179+
helperFieldMap(true, false, emptyList)
180+
),
181+
Arguments.of(
182+
helperFieldMap(null, true, null),
183+
helperFieldMap(false, true, emptyList)
184+
),
185+
Arguments.of(
186+
helperFieldMap(null, null, nodeList),
187+
helperFieldMap(false, false, nodeList)
188+
)
189+
);
190+
}
191+
192+
/**
193+
* Helper for reducing inline code repititon for assignments.
194+
*
195+
* @param asyncBefore The asyncBefore value.
196+
* @param asyncAfter The asyncAfter value.
197+
* @param nodes The nodes value.
198+
*
199+
* @return The built arguments map.
200+
*/
201+
private static Map<String, Object> helperFieldMap(Boolean asyncBefore, Boolean asyncAfter, List<Node> nodes) {
202+
final Map<String, Object> map = new HashMap<>();
203+
204+
map.put("asyncBefore", asyncBefore);
205+
map.put("asyncAfter", asyncAfter);
206+
map.put("nodes", nodes);
207+
208+
return map;
209+
}
210+
138211
private static class Impl extends AbstractProcess { }
139212

213+
private static class NodeImpl extends Node { }
214+
140215
}

components/src/test/java/org/folio/rest/workflow/model/AbstractTaskTest.java

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@
66
import static org.springframework.test.util.ReflectionTestUtils.setField;
77

88
import java.util.ArrayList;
9+
import java.util.HashMap;
10+
import java.util.HashSet;
911
import java.util.List;
12+
import java.util.Map;
1013
import java.util.Set;
14+
import java.util.stream.Stream;
1115
import org.junit.jupiter.api.BeforeEach;
1216
import org.junit.jupiter.api.Test;
1317
import org.junit.jupiter.api.extension.ExtendWith;
18+
import org.junit.jupiter.params.ParameterizedTest;
19+
import org.junit.jupiter.params.provider.Arguments;
20+
import org.junit.jupiter.params.provider.MethodSource;
1421
import org.mockito.Mock;
1522
import org.mockito.junit.jupiter.MockitoExtension;
1623

@@ -156,6 +163,73 @@ void setAsyncAfterWorksTest() {
156163
assertEquals(true, getField(abstractTask, "asyncAfter"));
157164
}
158165

166+
@ParameterizedTest
167+
@MethodSource("providePrePersistFor")
168+
void prePersistWorksTest(Map<String, Object> initial, Map<String, Object> expected) {
169+
initial.forEach((String attribute, Object value) -> {
170+
setField(abstractTask, attribute, value);
171+
});
172+
173+
abstractTask.prePersist();
174+
175+
expected.forEach((String attribute, Object value) -> {
176+
assertEquals(value, getField(abstractTask, attribute));
177+
});
178+
}
179+
180+
/**
181+
* Helper function for parameterized tests for the prePersist function.
182+
*
183+
* @return
184+
* The arguments array stream with the stream columns as:
185+
* - Arguments initial The initial values.
186+
* - Arguments expect The expected values.
187+
*/
188+
private static Stream<Arguments> providePrePersistFor() {
189+
final Set<EmbeddedVariable> evList = new HashSet<>();
190+
evList.add(new EmbeddedVariable());
191+
192+
final Set<EmbeddedVariable> emptyList = new HashSet<>();
193+
194+
return Stream.of(
195+
Arguments.of(
196+
helperFieldMap(null, null, null),
197+
helperFieldMap(false, false, emptyList)
198+
),
199+
Arguments.of(
200+
helperFieldMap(true, null, null),
201+
helperFieldMap(true, false, emptyList)
202+
),
203+
Arguments.of(
204+
helperFieldMap(null, true, null),
205+
helperFieldMap(false, true, emptyList)
206+
),
207+
Arguments.of(
208+
helperFieldMap(null, null, evList),
209+
helperFieldMap(false, false, evList)
210+
)
211+
);
212+
}
213+
214+
/**
215+
* Helper for reducing inline code repititon for assignments.
216+
*
217+
* @param asyncBefore The asyncBefore value.
218+
* @param asyncAfter The asyncAfter value.
219+
* @param inputVariables The inputVariables value.
220+
*
221+
* @return The built arguments map.
222+
*/
223+
private static Map<String, Object> helperFieldMap(Boolean asyncBefore, Boolean asyncAfter, Set<EmbeddedVariable> inputVariables) {
224+
final Map<String, Object> map = new HashMap<>();
225+
226+
map.put("asyncBefore", asyncBefore);
227+
map.put("asyncAfter", asyncAfter);
228+
map.put("inputVariables", inputVariables);
229+
230+
return map;
231+
}
232+
159233
private static class Impl extends AbstractTask { }
160234

161235
}

0 commit comments

Comments
 (0)