-
Notifications
You must be signed in to change notification settings - Fork 90
/
OverridingProcessStateDefinitionManagerTest.scala
66 lines (54 loc) · 2.95 KB
/
OverridingProcessStateDefinitionManagerTest.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package pl.touk.nussknacker.engine.api.deployment
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import pl.touk.nussknacker.engine.api.deployment.StateDefinitionDetails.UnknownIcon
import pl.touk.nussknacker.engine.api.deployment.StateStatus.StatusName
class OverridingProcessStateDefinitionManagerTest extends AnyFunSuite with Matchers {
val DefaultState: StateStatus = StateStatus("DEFAULT_STATE")
val DefaultStateToOverride: StateStatus = StateStatus("OVERRIDE_THIS_STATE")
val CustomState: StateStatus = StateStatus("CUSTOM_STATE")
val CustomStateThatOverrides: StateStatus = StateStatus("OVERRIDE_THIS_STATE")
private val icon = UnknownIcon
private val defaultStateDefinitionManager: ProcessStateDefinitionManager = new ProcessStateDefinitionManager {
override def stateDefinitions: Map[StatusName, StateDefinitionDetails] = Map(
DefaultState.name -> StateDefinitionDetails("Default", icon, "dummy", "Default description"),
DefaultStateToOverride.name -> StateDefinitionDetails(
"Default to override",
icon,
"dummy",
"Default description to override"
)
)
override def statusActions(stateStatus: StateStatus): List[ScenarioActionName] = Nil
}
test("should combine delegate state definitions with custom overrides") {
// here we use default set of states and apply custom extensions and overrides
val manager = new OverridingProcessStateDefinitionManager(
statusDescriptionsPF = {
case DefaultState => "Calculated description for default, e.g. schedule date"
case CustomState => "Calculated description for custom, e.g. schedule date"
},
customStateDefinitions = Map(
CustomState.name -> StateDefinitionDetails("Custom", icon, "dummy", "Custom description"),
CustomStateThatOverrides.name -> StateDefinitionDetails(
"Custom that overrides",
icon,
"dummy",
"Custom description that overrides"
)
),
delegate = defaultStateDefinitionManager
)
// eventually expect to have 3 states: CustomState, CustomStateToOverride and DelegateState
val definitionsMap = manager.stateDefinitions
definitionsMap should have size 3
// Raw definitions that are displayed as filter options
definitionsMap(DefaultState.name).description shouldBe "Default description"
definitionsMap(CustomState.name).description shouldBe "Custom description"
definitionsMap(CustomStateThatOverrides.name).description shouldBe "Custom description that overrides"
// Description assigned to a scenario, with custom calculations
manager.statusDescription(DefaultState) shouldBe "Calculated description for default, e.g. schedule date"
manager.statusDescription(CustomState) shouldBe "Calculated description for custom, e.g. schedule date"
manager.statusDescription(CustomStateThatOverrides) shouldBe "Custom description that overrides"
}
}