generated from OSGP/gxf-service-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from OSGP/feature/FDP-2874-alarm-msgs
FDP-2874: Fixed handling of Alarm device messages
- Loading branch information
Showing
9 changed files
with
92 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
application/src/test/kotlin/org/gxf/crestdeviceservice/model/DeviceMessageTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-FileCopyrightText: Copyright Contributors to the GXF project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.gxf.crestdeviceservice.model | ||
|
||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
|
||
class DeviceMessageTest { | ||
private val mapper = jacksonObjectMapper() | ||
|
||
private val jsonMessage = | ||
""" | ||
{ | ||
"ID": 867787050253370, | ||
"URC": [ | ||
{ | ||
"DL": "!INFO:ALARMS" | ||
}, | ||
{ | ||
"AL0": [ 1, 2, 3, 4, 5 ], | ||
"AL1": [ 10, 20, 30, 40, 50 ], | ||
"AL2": [ 100, 200, 300, 400, 500 ] | ||
} | ||
], | ||
"FMC": 3 | ||
} | ||
""" | ||
.trimIndent() | ||
private val deviceMessage = DeviceMessage(mapper.readTree(jsonMessage)) | ||
|
||
@Test | ||
fun `should return DL command from URC`() { | ||
assertThat(deviceMessage.getDownlinkCommand()).isEqualTo("!INFO:ALARMS") | ||
} | ||
|
||
@Test | ||
fun `should return object containing AL2`() { | ||
assertThat(deviceMessage.getUrcContainingField("AL2")).isNotNull | ||
assertThat(deviceMessage.getUrcContainingField("AL2").findValue("AL1").map { it.intValue() }) | ||
.containsExactly(10, 20, 30, 40, 50) | ||
} | ||
|
||
@Test | ||
fun `should return Fota Message Counter`() { | ||
assertThat(deviceMessage.getFotaMessageCounter()).isEqualTo(3) | ||
} | ||
} |