Skip to content

Commit

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

FDP-2551 ~ Updates RSP result handlers after testing
  • Loading branch information
smvdheijden authored Dec 5, 2024
2 parents c287683 + 1cec748 commit adf500a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.springframework.stereotype.Component
class Rsp2CommandResultHandler(commandService: CommandService, commandFeedbackService: CommandFeedbackService) :
RspCommandResultHandler(commandService, commandFeedbackService) {

override val confirmationDownlinkInUrc = "CMD:RSP2"
override val successUrc = "RSP2:OK"
override val errorUrc = "RSP2:DLER"

override val supportedCommandType = CommandType.RSP2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ import org.springframework.stereotype.Component
class RspCommandResultHandler(commandService: CommandService, commandFeedbackService: CommandFeedbackService) :
CommandResultHandler(commandService, commandFeedbackService) {

val confirmationDownlinkInUrc = "CMD:RSP"
val successUrc = "RSP:OK"
val errorUrc = "RSP:DLER"

override val supportedCommandType = CommandType.RSP

override fun hasSucceeded(deviceId: String, body: JsonNode) =
confirmationDownlinkInUrc in body.downlinks() && errorUrc !in body.urcs()
override fun hasSucceeded(deviceId: String, body: JsonNode) = successUrc in body.urcs()

override fun hasFailed(deviceId: String, body: JsonNode) = errorUrc in body.urcs()
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ class Rsp2CommandResultHandlerTest {
@JvmStatic
fun hasSucceededTestSource(): Stream<Arguments> =
Stream.of(
Arguments.of(listOf<String>(), "CMD:RSP2", true),
Arguments.of(listOf("PSK:TMP"), "!PSK:######;CMD:RSP2", true),
Arguments.of(listOf("PSK:TMP"), "!CMD:RSP2;PSK:######", true),
Arguments.of(listOf("RSP2:OK"), "CMD:RSP2", true),
Arguments.of(listOf<String>(), "CMD:RSP2", false),
Arguments.of(listOf("PSK:TMP", "RSP2:OK"), "!PSK:######;CMD:RSP2", true),
Arguments.of(listOf("RSP2:OK", "PSK:TMP"), "!CMD:RSP2;PSK:######", true),
Arguments.of(listOf("RSP2:DLER"), "CMD:RSP2", false),
Arguments.of(listOf("RSP2:DLER", "PSK:TMP"), "!CMD:RSP2;PSK:######", false),
Arguments.of(listOf("INIT", "WDR"), "0", false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ class RspCommandResultHandlerTest {
@JvmStatic
fun hasSucceededTestSource(): Stream<Arguments> =
Stream.of(
Arguments.of(listOf<String>(), "CMD:RSP", true),
Arguments.of(listOf("PSK:TMP"), "!PSK:######;CMD:RSP", true),
Arguments.of(listOf("PSK:TMP"), "!CMD:RSP;PSK:######", true),
Arguments.of(listOf("RSP:OK"), "CMD:RSP", true),
Arguments.of(listOf<String>(), "CMD:RSP", false),
Arguments.of(listOf("PSK:TMP", "RSP:OK"), "!PSK:######;CMD:RSP", true),
Arguments.of(listOf("RSP:OK", "PSK:TMP"), "!CMD:RSP;PSK:######", true),
Arguments.of(listOf("RSP:DLER"), "CMD:RSP", false),
Arguments.of(listOf("RSP:DLER", "PSK:TMP"), "!CMD:RSP;PSK:######", false),
Arguments.of(listOf("INIT", "WDR"), "0", false),
Expand Down

0 comments on commit adf500a

Please sign in to comment.