Skip to content

Commit

Permalink
Merge pull request #80 from OSGP/feature/FDP-2551-command-result-hand…
Browse files Browse the repository at this point in the history
…er-refactoring

FDP-2551 ~ Updates result handlers
  • Loading branch information
smvdheijden authored Nov 29, 2024
2 parents 51b4cb1 + bf334f6 commit c287683
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class FirmwareCommandResultHandler(
val commandFeedbackService: CommandFeedbackService
) : CommandResultHandler(commandService, commandFeedbackService) {

private val succesUrc = "OTA:SUC"
private val successUrc = "OTA:SUC"
private val errorUrcs = listOf("OTA:CSER", "OTA:HSER", "OTA:RST", "OTA:SWNA", "OTA:FLER")

override val supportedCommandType = CommandType.FIRMWARE

override fun hasSucceeded(deviceId: String, body: JsonNode) = succesUrc in body.urcs()
override fun hasSucceeded(deviceId: String, body: JsonNode) = successUrc in body.urcs()

override fun hasFailed(deviceId: String, body: JsonNode) = body.urcs().any { it in errorUrcs }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import org.springframework.stereotype.Component
class PskCommandResultHandler(commandService: CommandService, commandFeedbackService: CommandFeedbackService) :
CommandResultHandler(commandService, commandFeedbackService) {

private val succesUrc = "PSK:TMP"
private val successUrc = "PSK:TMP"
private val errorUrcs = listOf("PSK:DLER", "PSK:HSER")

override val supportedCommandType = CommandType.PSK

override fun hasSucceeded(deviceId: String, body: JsonNode) = succesUrc in body.urcs()
override fun hasSucceeded(deviceId: String, body: JsonNode) = successUrc in body.urcs()

override fun hasFailed(deviceId: String, body: JsonNode) = body.urcs().any { it in errorUrcs }
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class PskSetCommandResultHandler(

private val logger = KotlinLogging.logger {}

private val succesUrc = "PSK:SET"
private val successUrc = "PSK:SET"
private val errorUrcs = listOf("PSK:DLER", "PSK:HSER", "PSK:EQER")

override val supportedCommandType = CommandType.PSK_SET

override fun hasSucceeded(deviceId: String, body: JsonNode) = succesUrc in body.urcs()
override fun hasSucceeded(deviceId: String, body: JsonNode) = successUrc in body.urcs()

override fun hasFailed(deviceId: String, body: JsonNode) = body.urcs().any { it in errorUrcs }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import org.springframework.stereotype.Component
class RebootCommandResultHandler(commandService: CommandService, commandFeedbackService: CommandFeedbackService) :
CommandResultHandler(commandService, commandFeedbackService) {

private val succesUrcs = listOf("INIT", "WDR")
private val successUrc = "INIT"

override val supportedCommandType = CommandType.REBOOT

override fun hasSucceeded(deviceId: String, body: JsonNode) = body.urcs().containsAll(succesUrcs)
override fun hasSucceeded(deviceId: String, body: JsonNode) = successUrc in body.urcs()

override fun hasFailed(deviceId: String, body: JsonNode) = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class RebootCommandResultHandlerTest {
fun hasSucceededTestSource(): Stream<Arguments> =
Stream.of(
Arguments.of(listOf("INIT", "WDR"), "0", true),
Arguments.of(listOf("INIT"), "0", false),
Arguments.of(listOf("INIT"), "0", true),
Arguments.of(listOf("WDR"), "0", false),
Arguments.of(listOf("PSK:TMP", "PSK:SET"), "!PSK:######;PSK:######SET", false),
)
Expand Down

0 comments on commit c287683

Please sign in to comment.