Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fdp 2874 alarm info #47

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import org.gxf.crestdevicesimulator.simulator.response.exception.InvalidCommandE
* * On success: a downlink containing the alarm thresholds will be returned in the next message sent
* * On failure: "INFO:DLER" URC will be returned in the next message sent
*/
class InfoAlarmCommandHandler : CommandHandler {
class InfoAlarmsCommandHandler : CommandHandler {
private val logger = KotlinLogging.logger {}
private val commandRegex: Regex = "INFO:AL([2-7]|ARM)".toRegex()
private val commandRegex: Regex = "INFO:AL([2-7]|ARMS)".toRegex()

override fun canHandleCommand(command: String) = commandRegex.matches(command)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource

class InfoAlarmCommandHandlerTest {
private val commandHandler = InfoAlarmCommandHandler()
class InfoAlarmsCommandHandlerTest {
private val commandHandler = InfoAlarmsCommandHandler()

private lateinit var simulatorState: SimulatorState

Expand All @@ -24,7 +24,7 @@ class InfoAlarmCommandHandlerTest {
}

@ParameterizedTest
@ValueSource(strings = ["INFO:ALARM", "INFO:AL7"])
@ValueSource(strings = ["INFO:ALARMS", "INFO:AL7"])
fun `canHandleCommand should return true when called with valid command`(command: String) {
val actualResult = commandHandler.canHandleCommand(command)
assertThat(actualResult).isTrue
Expand All @@ -38,16 +38,16 @@ class InfoAlarmCommandHandlerTest {
}

@Test
fun `handleCommand should handle info alarm command`() {
val command = "INFO:ALARM"
fun `handleCommand should handle info alarms command`() {
val command = "INFO:ALARMS"
val alarmThresholdValues = AlarmThresholdValues(6, 0, 500, 1000, 1500, 10)
simulatorState.addAlarmThresholds(alarmThresholdValues)

commandHandler.handleCommand(command, simulatorState)

val expectedDownlink =
"""
"INFO:ALARM",{"AL0":[0,0,0,0,0],"AL1":[0,0,0,0,0],"AL2":[0,0,0,0,0],"AL3":[0,0,0,0,0],
"INFO:ALARMS",{"AL0":[0,0,0,0,0],"AL1":[0,0,0,0,0],"AL2":[0,0,0,0,0],"AL3":[0,0,0,0,0],
"AL4":[0,0,0,0,0],"AL5":[0,0,0,0,0],"AL6":[0,500,1000,1500,10],"AL7":[0,0,0,0,0]}
"""
.trimIndent()
Expand Down
Loading