Skip to content

Commit f948cbe

Browse files
committed
Added DmnTester documentation.
1 parent 7f32346 commit f948cbe

File tree

11 files changed

+2142
-111
lines changed

11 files changed

+2142
-111
lines changed

00-docs/src/docs/company/03-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ lazy val apiConfig: ApiConfig =
4747
.withJiraUrls("COM" -> "https://issue.mycompany.ch/browse")
4848
```
4949

50-
## Default ApiConfig
50+
### Default ApiConfig
5151
This is the default Configuration:
5252
```scala
5353
// your company name like 'mycompany'

00-docs/src/docs/company/03-dmn.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,62 @@
1-
# 03-dmn
1+
# 03-dmn
2+
Use this to add Company specific DMNTester stuff like the configuration of the projects within the Company.
3+
4+
The following structure is generated by `./helperCompany.scala init`:
5+
6+
```bash
7+
03-dmn/src
8+
| main/resources
9+
| main/scala/company/dmn
10+
| | CompanyDmnTester.scala
11+
| test/scala/company/dmn
12+
```
13+
14+
## CompanyDmnTester
15+
The Company's base class to generate the DmnTester Configurations and start the Docker image.
16+
17+
Example (generated by `./helperCompany.scala init`):
18+
19+
```scala
20+
package mycompany.camundala.dmn
21+
22+
trait CompanyDmnTester extends DmnTesterConfigCreator:
23+
24+
override def starterConfig: DmnTesterStarterConfig =
25+
DmnTesterStarterConfig(companyName = "mycompany")
26+
27+
end CompanyDmnTester
28+
```
29+
30+
## DmnTesterStarterConfig
31+
You can customize the DmnTester Configuration.
32+
33+
```scala
34+
DmnTesterStarterConfig(
35+
companyName = "valiant",
36+
dmnPaths = Seq(localDmnPath)
37+
)
38+
```
39+
40+
### Default Config
41+
42+
Except for the `companyName` all other values are optional and preconfigured,
43+
and **should not be adjusted**.
44+
45+
Especially the `dmnPaths` might change in the future.
46+
47+
```scala
48+
// the name of the container that will be started
49+
containerName: String = "camunda-dmn-tester",
50+
// path to where the configs should be created in
51+
dmnConfigPaths: Seq[os.Path] = Seq(
52+
projectBasePath / "03-dmn" / "src" / "main" / "resources" / "dmnConfigs"
53+
),
54+
// paths where the DMNs are (could be in different places)
55+
dmnPaths: Seq[os.Path] = Seq(
56+
projectBasePath / "src" / "main" / "resources"
57+
),
58+
// the port the DMN Tester is started - e.g. http://localhost:8883
59+
exposedPort: Int = 8883,
60+
// the image version of the DMN Tester
61+
imageVersion: String = "latest"
62+
```

00-docs/src/docs/company/04-helper.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ case class CompanyDevHelper(projectName: String, subProjects: Seq[String] = Seq.
1313

1414
lazy val apiConfig: ApiConfig = ApiConfig("mycompany")//.withTenantId("mycompany")...
1515

16-
def deployConfig: Option[DeployConfig] = ???
17-
def devConfig: DevConfig = ???
18-
def dockerConfig: DockerConfig = ???
16+
lazy val deployConfig: Option[DeployConfig] = ???
17+
lazy val devConfig: DevConfig = ???
18+
lazy val dockerConfig: DockerConfig = ???
19+
lazy val publishConfig: Option[PublishConfig] = ???
1920

2021
```

00-docs/src/docs/functionalityDsls/dmnTester.md

Lines changed: 11 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@ Let's start with a basic example:
2222
package camundala.examples.invoice.dmn
2323
// import the projects bpmns (DMNs)
2424
import camundala.examples.invoice.bpmn.*
25-
// import Camundala dmn DSL / the DMN Tester starter
26-
import camundala.dmn.{DmnTesterConfigCreator, DmnTesterStarter}
27-
// define an object that extends ..
25+
2826
object ProjectDmnTester
29-
extends DmnTesterConfigCreator, // .. from a Config Creator DSL
30-
DmnTesterStarter, // .. from a starter - that runs the DMN Tester automatically
31-
App: // .. to run the Application
27+
extends CompanyDmnTester:
3228

3329
startDmnTester()
3430

@@ -50,11 +46,9 @@ end ProjectDmnTester
5046
### Run the DMN Tester
5147
In your _sbt-console_:
5248

53-
`runMain camundala.examples.invoice.dmn.ProjectDmnTester`
49+
`dmn/run`
5450

55-
## startDmnTester
56-
Starts the Docker container.
57-
This makes the whole process pretty nice and fast.
51+
This starts the Docker container and makes the whole process pretty nice and fast.
5852
The following steps are done:
5953

6054
- Check if the Container is already running.
@@ -69,10 +63,8 @@ You start from the DMN, that you defined, here an example:
6963

7064
```scala
7165
lazy val InvoiceAssignApproverDMN = collectEntries(
72-
decisionDefinitionKey = "example-invoice-c7-assignApprover",
7366
in = SelectApproverGroup(),
7467
out = Seq(ApproverGroup.management),
75-
descr = "Decision Table on who must approve the Invoice.",
7668
)
7769
```
7870

@@ -120,11 +112,11 @@ So if you have complex set of dependent DMN Tables you can test them separately,
120112
### .dmnPath
121113
To support different naming schemes, you can adjust the DMN file name the following way:
122114

123-
- Nothing to do, if the file name is `dmnBasePath / s"${decisionId}.dmn"`. (see configuration)
115+
- Nothing to do, if the file name is `dmnBasePath / s"${decisionId.replace("mycompany-", "")}.dmn"`. (see configuration)
124116
- The creation of the default path can be overridden:
125117
```scala
126118
protected def defaultDmnPath(dmnName: String): os.Path =
127-
dmnBasePath / s"${dmnName.replace("myPrefix-", "")}.dmn"
119+
dmnBasePath / s"$decisionId.dmn"
128120
```
129121
- A different name, but with the same _defaultDmnPath_:
130122
```scala
@@ -176,77 +168,12 @@ So it is a corner case if this is rather a test input.
176168

177169
The output variable can be whatever you want.
178170

179-
## Configuration
180-
The following is the default configuration:
181-
```scala
182-
case class DmnTesterStarterConfig(
183-
// the name of the container that will be started
184-
containerName: String = "camunda-dmn-tester",
185-
// path to where the configs should be created in
186-
dmnConfigPaths: Seq[os.Path] = Seq(
187-
projectBasePath / "src" / "it" / "resources" / "dmnConfigs"
188-
),
189-
// paths where the DMNs are (could be different places)
190-
dmnPaths: Seq[os.Path] = Seq(
191-
projectBasePath / "src" / "main" / "resources"
192-
),
193-
// the port the DMN Tester is started - e.g. http://localhost:8883
194-
exposedPort: Int = 8883,
195-
// the image version of the DMN Tester
196-
imageVersion: String = "latest"
197-
)
198-
```
199-
200-
You can override it via the following variables (you see the defaults):
201-
202-
```scala
203-
protected def starterConfig: DmnTesterStarterConfig = DmnTesterStarterConfig()
204-
// this is the project where you start the DmnCreator
205-
protected def projectBasePath: os.Path = os.pwd
206-
207-
// the path where the DMNs are
208-
protected def dmnBasePath: os.Path = starterConfig.dmnPaths.head
209-
// the path where the DMN Configs are
210-
protected def dmnConfigPath: os.Path = starterConfig.dmnConfigPaths.head
211-
// creating the Path to the DMN - by default the _dmnName_ is `decisionDmn.decisionDefinitionKey`.
212-
protected def defaultDmnPath(dmnName: String): os.Path = dmnBasePath / s"$dmnName.dmn"
213-
214-
```
215-
216-
Example of a general Tester you can use for all project, that also starts the DMN Tester:
217-
218-
```scala
219-
trait MyCompanyDmnTester extends DmnTesterConfigCreator, DmnTesterStarter:
220-
221-
private def localDmnPath = os.pwd / diagramPath
222-
223-
override protected def starterConfig: DmnTesterStarterConfig =
224-
DmnTesterStarterConfig(
225-
dmnPaths = Seq(localDmnPath)
226-
)
227-
override protected def defaultDmnPath(dmnName: String): os.Path =
228-
val dmnPath = dmnBasePath / s"${dmnName.replace("mycompany-", "")}.dmn"
229-
if(!dmnPath.toIO.exists())
230-
throw FileNotFoundException(s"There is no DMN in $dmnPath")
231-
dmnPath
232-
233-
startDmnTester()
234-
235-
end MyCompanyDmnTester
236-
```
237-
238-
So in the project you can focus on the creation of DMN Configurations, like:
239-
240-
```scala
241-
// runMain mycompany.nnk.dmn.ProjectDmnTester
242-
object ProjectDmnTester extends MyCompanyDmnTester, App:
243-
244-
createDmnConfigs(
245-
...
246-
)
171+
@:callout(info)
172+
Be aware that you must run the DMN Tester again, whenever you made changes (`sbt dmn/run`).
173+
@:@
247174

248-
end ProjectDmnTester
249-
```
175+
## Configuration
176+
See [03-dmn].
250177

251178
## Problem Handling
252179

03-dmn/src/main/scala/camundala/dmn/DmnTesterConfigCreator.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import java.time.LocalDateTime
1010
import scala.language.reflectiveCalls
1111
import scala.reflect.ClassTag
1212

13-
trait DmnTesterConfigCreator extends DmnConfigWriter:
13+
trait DmnTesterConfigCreator extends DmnConfigWriter, DmnTesterStarter:
1414

1515
// the path where the DMNs are
1616
protected def dmnBasePath: os.Path = starterConfig.dmnPaths.head
@@ -24,6 +24,7 @@ trait DmnTesterConfigCreator extends DmnConfigWriter:
2424
dmnPath
2525

2626
protected def createDmnConfigs(dmnTesterObjects: DmnTesterObject[?]*): Unit =
27+
startDmnTester
2728
dmnConfigs(dmnTesterObjects)
2829
.foreach(updateConfig(_, dmnConfigPath))
2930
println("Check it on http://localhost:8883")

03-dmn/src/main/scala/camundala/dmn/DmnTesterStarter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import scala.util.{Failure, Success, Try}
77

88
trait DmnTesterStarter extends DmnTesterHelpers, App:
99

10-
def startDmnTester(): Unit =
10+
lazy val startDmnTester: Unit =
1111
println("Check logs in Docker Console!")
1212
println(s"Open the browser: http://localhost:${starterConfig.exposedPort}")
1313
if checkIsRunning() then

04-helper/src/main/scala/camundala/helper/dev/company/CompanyWrapperGenerator.scala

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,12 @@ case class CompanyWrapperGenerator()(using config: DevConfig):
6363
private lazy val dmnWrapper =
6464
s"""package $companyName.camundala.dmn
6565
|
66-
|import camundala.dmn.*
66+
|trait CompanyDmnTester extends DmnTesterConfigCreator:
6767
|
68-
|/**
69-
| * Add here company specific stuff, to run the DMN Tester.
70-
| */
71-
|trait CompanyDmnTester extends DmnTesterConfigCreator, DmnTesterStarter:
68+
| override def starterConfig: DmnTesterStarterConfig =
69+
| DmnTesterStarterConfig(companyName = "$companyName")
7270
|
73-
| def starterConfig: DmnTesterStarterConfig =
74-
| DmnTesterStarterConfig( // adjust paths if needed
75-
| companyName = "$companyName",
76-
| )
71+
|end CompanyDmnTester
7772
|""".stripMargin
7873

7974
private lazy val simulationWrapper =

05-examples/demos/03-dmn/src/main/scala/camundala/examples/demos/dmn/ProjectDmnTester.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import bpmn.*
88
import java.time.LocalDateTime
99

1010
object ProjectDmnTester
11-
extends DmnTesterConfigCreator,
12-
DmnTesterStarter,
13-
App:
11+
extends DmnTesterConfigCreator:
1412

1513
private lazy val localDmnConfigPath: os.Path =
1614
os.pwd / "05-examples" / "demos" / "03-dmn" / "src" / "main" / "resources" / "dmnConfigs"
@@ -24,9 +22,7 @@ object ProjectDmnTester
2422
dmnPaths = Seq(localDmnPath),
2523
dmnConfigPaths = Seq(localDmnConfigPath)
2624
)
27-
28-
startDmnTester()
29-
25+
3026
createDmnConfigs(
3127
DecisionResultTypes.singleEntryDMN.testUnit
3228
.dmnPath("DecisionResultTypes")

0 commit comments

Comments
 (0)