Skip to content

Commit

Permalink
refactor more actions to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
enricocolasante committed Dec 7, 2023
1 parent 8528a45 commit 92309d9
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 60 deletions.

This file was deleted.

11 changes: 11 additions & 0 deletions src/main/java/org/hisp/dhis/rules/models/RuleActionCreateEvent.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.hisp.dhis.rules.models

data class RuleActionCreateEvent(
val programStage: String,
val content: String = "",
val data: String = ""
) : RuleAction {
override fun data(): String {
return data
}
}
12 changes: 0 additions & 12 deletions src/main/java/org/hisp/dhis/rules/models/RuleActionError.java

This file was deleted.

7 changes: 7 additions & 0 deletions src/main/java/org/hisp/dhis/rules/models/RuleActionError.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.hisp.dhis.rules.models

data class RuleActionError(val data: String) : RuleAction {
override fun data(): String {
return data
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ data class RuleEvaluationResult(
}

fun errorRule(rule: Rule, errorMessage: String): RuleEvaluationResult {
val effects = listOf(RuleEffect(rule.uid, RuleActionError.create(errorMessage), errorMessage))
val effects = listOf(RuleEffect(rule.uid, RuleActionError(errorMessage), errorMessage))
return RuleEvaluationResult(rule, effects, false, true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ class RuleEngineEffectTypesTest {

@Test
fun simpleConditionMustResultInCreateEventEffect() {
val ruleAction: RuleAction = RuleActionCreateEvent.create(
"test_action_content", "'event_uid;test_data_value_one'", "test_program_stage"
val ruleAction: RuleAction = RuleActionCreateEvent(
"test_program_stage",
"test_action_content", "'event_uid;test_data_value_one'"
)
val rule = Rule("true", listOf(ruleAction))
val ruleEngine = getRuleEngine(rule)
Expand Down

This file was deleted.

0 comments on commit 92309d9

Please sign in to comment.