Skip to content

Commit 9fc9a0f

Browse files
committed
FIN-275 update the test strategy for BPMN testing
1 parent 0a931f9 commit 9fc9a0f

25 files changed

+1535
-792
lines changed

bpmn-process/src/.camunda/element-templates/contract.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"description": "The JSON representation of the contract.",
8181
"binding": {
8282
"type": "camunda:inputParameter",
83-
"name": "category"
83+
"name": "contract"
8484
},
8585
"constraint": {
8686
"notEmpty": true

bpmn-process/src/main/java/com/jongsoft/finance/bpmn/delegate/user/ParseUserConfigurationDelegate.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.jongsoft.finance.StorageService;
55
import com.jongsoft.finance.serialized.ExportJson;
66
import com.jongsoft.finance.serialized.RuleConfigJson;
7+
import com.jongsoft.lang.Control;
78
import jakarta.inject.Singleton;
89
import lombok.extern.slf4j.Slf4j;
910
import org.camunda.bpm.engine.delegate.DelegateExecution;
@@ -39,21 +40,29 @@ public void execute(DelegateExecution execution) throws Exception {
3940
.map(json -> mapper.readSafe(json, ExportJson.class))
4041
.getOrThrow(() -> new RuntimeException("Unable to parse json file"));
4142

42-
String ruleStorageToken = storageService.store(
43-
mapper.writeSafe(RuleConfigJson.builder()
44-
.slug("profile-import")
45-
.rules(profileJson.getRules())
46-
.build()).getBytes(StandardCharsets.UTF_8));
43+
if (profileJson.getRules() != null && !profileJson.getRules().isEmpty()) {
44+
String ruleStorageToken = storageService.store(
45+
mapper.writeSafe(RuleConfigJson.builder()
46+
.slug("profile-import")
47+
.rules(profileJson.getRules())
48+
.build()).getBytes(StandardCharsets.UTF_8));
49+
execution.setVariableLocal("ruleStorageToken", ruleStorageToken);
50+
} else {
51+
execution.setVariableLocal("ruleStorageToken", null);
52+
}
4753

4854
execution.setVariableLocal("accounts", serialize(profileJson.getAccounts()));
4955
execution.setVariableLocal("budgetPeriods", serialize(profileJson.getBudgetPeriods()));
5056
execution.setVariableLocal("contracts", serialize(profileJson.getContracts()));
5157
execution.setVariableLocal("categories", serialize(profileJson.getCategories()));
52-
execution.setVariableLocal("tags", profileJson.getTags());
53-
execution.setVariableLocal("ruleStorageToken", ruleStorageToken);
58+
execution.setVariableLocal("tags", Control.Option(profileJson.getTags()).getOrSupply(List::of));
5459
}
5560

5661
List<String> serialize(List<?> input) {
62+
if (input == null) {
63+
return List.of();
64+
}
65+
5766
return input.stream()
5867
.map(mapper::writeSafe)
5968
.filter(Objects::nonNull)

bpmn-process/src/main/resources/bpmn/profile/user.profile.import.bpmn

Lines changed: 161 additions & 130 deletions
Large diffs are not rendered by default.

bpmn-process/src/main/resources/bpmn/transaction/transaction.rules.import.bpmn

Lines changed: 148 additions & 148 deletions
Large diffs are not rendered by default.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://www.pledger.io/schemas/account.schema.json",
4+
"title": "Account",
5+
"description": "A account is a financial account that can be used to record transactions.",
6+
"type": "object",
7+
"properties": {
8+
"name": {
9+
"type": "string"
10+
},
11+
"description": {
12+
"type": "string"
13+
},
14+
"currency": {
15+
"type": "string"
16+
},
17+
"icon": {
18+
"type": "string"
19+
},
20+
"interest": {
21+
"type": "number"
22+
},
23+
"periodicity": {
24+
"type": "string"
25+
},
26+
"iban": {
27+
"type": "string"
28+
},
29+
"bic": {
30+
"type": "string"
31+
},
32+
"number": {
33+
"type": "string"
34+
},
35+
"type": {
36+
"type": "string"
37+
}
38+
},
39+
"required": ["name", "currency", "type"]
40+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://www.yourwebsite.com/schemas/budget.schema.json",
4+
"title": "Budget",
5+
"type": "object",
6+
"properties": {
7+
"start": {
8+
"type": "string",
9+
"format": "date"
10+
},
11+
"end": {
12+
"type": "string",
13+
"format": "date"
14+
},
15+
"expectedIncome": {
16+
"type": "number"
17+
},
18+
"expenses": {
19+
"type": "array",
20+
"items": {
21+
"type": "object",
22+
"properties": {
23+
"name": {
24+
"type": "string"
25+
},
26+
"lowerBound": {
27+
"type": "number"
28+
},
29+
"upperBound": {
30+
"type": "number"
31+
}
32+
},
33+
"required": ["name", "lowerBound", "upperBound"]
34+
}
35+
}
36+
},
37+
"required": ["start", "expectedIncome", "expenses"]
38+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://www.pledger.io/schemas/category.schema.json",
4+
"title": "Category",
5+
"type": "object",
6+
"properties": {
7+
"label": {
8+
"type": "string"
9+
},
10+
"description": {
11+
"type": "string"
12+
}
13+
},
14+
"required": [
15+
"label"
16+
]
17+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://www.pledger.io/schemas/contract.schema.json",
4+
"title": "Contract",
5+
"type": "object",
6+
"properties": {
7+
"name": {
8+
"type": "string"
9+
},
10+
"description": {
11+
"type": "string"
12+
},
13+
"company": {
14+
"type": "string"
15+
},
16+
"contract": {
17+
"type": "string",
18+
"description": "The HEX encoded PDF that contains the actual contract."
19+
},
20+
"terminated": {
21+
"type": "boolean"
22+
},
23+
"start": {
24+
"type": "string",
25+
"format": "date"
26+
},
27+
"end": {
28+
"type": "string",
29+
"format": "date"
30+
}
31+
},
32+
"required": ["name", "description", "company", "terminated", "start", "end"]
33+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://www.pledger.io/schemas/profile.schema.json",
4+
"title": "Profile",
5+
"type": "object",
6+
"properties": {
7+
"accounts": {
8+
"type": "array",
9+
"items": {
10+
"ref": "https://www.pledger.io/schemas/account.schema.json"
11+
}
12+
},
13+
"categories": {
14+
"type": "array",
15+
"items": {
16+
"$ref": "https://www.pledger.io/schemas/category.schema.json"
17+
}
18+
},
19+
"contracts": {
20+
"type": "array",
21+
"items": {
22+
"$ref": "https://www.pledger.io/schemas/contract.schema.json"
23+
}
24+
},
25+
"rules": {
26+
"type": "array",
27+
"items": {
28+
"$ref": "https://www.pledger.io/schemas/rule.schema.json"
29+
}
30+
},
31+
"budgetPeriods": {
32+
"type": "array",
33+
"items": {
34+
"$ref": "https://www.pledger.io/schemas/budget.schema.json"
35+
}
36+
},
37+
"tags": {
38+
"type": "array",
39+
"items": {
40+
"type": "string"
41+
}
42+
}
43+
}
44+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://www.pledger.io/schemas/rule.schema.json",
4+
"title": "Transaction Rule",
5+
"type": "object",
6+
"properties": {
7+
"rules": {
8+
"type": "array",
9+
"items": {
10+
"$ref": "#/$defs/rule"
11+
}
12+
}
13+
},
14+
"$defs": {
15+
"rule": {
16+
"type": "object",
17+
"properties": {
18+
"name": {
19+
"type": "string"
20+
},
21+
"description": {
22+
"type": "string"
23+
},
24+
"restrictive": {
25+
"type": "boolean"
26+
},
27+
"active": {
28+
"type": "boolean"
29+
},
30+
"sort": {
31+
"type": "number"
32+
},
33+
"group": {
34+
"type": "string"
35+
},
36+
"conditions": {
37+
"type": "array",
38+
"items": {
39+
"$ref": "#/$defs/condition"
40+
}
41+
},
42+
"changes": {
43+
"type": "array",
44+
"items": {
45+
"$ref": "#/$defs/change"
46+
}
47+
}
48+
},
49+
"required": [
50+
"conditions",
51+
"changes",
52+
"name"
53+
]
54+
},
55+
"condition": {
56+
"type": "object",
57+
"properties": {
58+
"field": {
59+
"$ref": "#/$defs/column"
60+
},
61+
"value": {
62+
"type": "string"
63+
}
64+
},
65+
"required": [
66+
"field",
67+
"value"
68+
]
69+
},
70+
"change": {
71+
"type": "object",
72+
"properties": {
73+
"field": {
74+
"$ref": "#/$defs/column"
75+
},
76+
"operation": {
77+
"type": "string",
78+
"enum": [
79+
"EQUALS",
80+
"CONTAINS",
81+
"STARTS_WITH",
82+
"LESS_THAN",
83+
"MORE_THAN"
84+
]
85+
},
86+
"value": {
87+
"type": "string"
88+
}
89+
},
90+
"required": [
91+
"field",
92+
"value"
93+
]
94+
},
95+
"column": {
96+
"type": "string",
97+
"enum": [
98+
"SOURCE_ACCOUNT",
99+
"TO_ACCOUNT",
100+
"DESCRIPTION",
101+
"AMOUNT",
102+
"CATEGORY",
103+
"CHANGE_TRANSFER_TO",
104+
"CHANGE_TRANSFER_FROM",
105+
"BUDGET",
106+
"CONTRACT",
107+
"TAGS"
108+
]
109+
}
110+
}
111+
}

0 commit comments

Comments
 (0)