Skip to content

Commit

Permalink
chore: Add ULongArray to supported data types
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrylo committed Mar 18, 2024
1 parent b3d887c commit 16bb945
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import io.grpc.ManagedChannel
import io.kotest.assertions.nondeterministic.eventually
import io.kotest.core.spec.style.BehaviorSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import io.kotest.matchers.string.shouldContain
import io.mockk.clearMocks
import io.mockk.every
Expand Down Expand Up @@ -106,7 +107,7 @@ class DataBrokerConnectionTest : BehaviorSpec({
val response = dataBrokerConnection.update(updateRequest)

then("No error should appear") {
Assertions.assertFalse(response.hasError())
response.hasError() shouldBe false
}

and("When fetching it afterwards") {
Expand Down Expand Up @@ -177,12 +178,11 @@ class DataBrokerConnectionTest : BehaviorSpec({
`when`("Updating the node with an invalid value") {
val invalidHeartRate = VssDriver.VssHeartRate(-5) // UInt on DataBroker side
val vssNodeUpdateRequest = VssNodeUpdateRequest(invalidHeartRate)
dataBrokerConnection.update(vssNodeUpdateRequest)
val response = dataBrokerConnection.update(vssNodeUpdateRequest)

val fetchRequest = VssNodeFetchRequest(invalidHeartRate)
val fetchedVssHeartRate = dataBrokerConnection.fetch(fetchRequest)
then("the updated value should be ignored") {
fetchedVssHeartRate.value shouldBe 60
then("the updated show") {
val errorResponse = response.firstOrNull { it.errorsCount >= 1 }
errorResponse shouldNotBe null
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ interface VssSignal<out T : Any> : VssNode {
val value: T

/**
* The VSS data type which is compatible with the data broker. This may differ from the [value] type because
* The VSS data type which is compatible with the Databroker. This may differ from the [value] type because
* Java compatibility needs to be ensured and inline classes like [UInt] (Kotlin) are not known to Java.
*
* ### Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ internal class VssNodeSpecModel(
"boolean[]" -> BooleanArray::class.asTypeName()
"int8[]", "int16[]", "int32[]" -> IntArray::class.asTypeName()
"uint8[]", "uint16[]", "uint32[]" -> UIntArray::class.asTypeName()
"int64[]", "uint64[]" -> LongArray::class.asTypeName()
"int64[]" -> LongArray::class.asTypeName()
"uint64[]" -> ULongArray::class.asTypeName()
"float[]" -> FloatArray::class.asTypeName()
else -> Any::class.asTypeName()
}
Expand All @@ -93,6 +94,7 @@ internal class VssNodeSpecModel(
UInt::class.asTypeName() -> Int::class.asTypeName()
ULong::class.asTypeName() -> Long::class.asTypeName()
UIntArray::class.asTypeName() -> IntArray::class.asTypeName()
ULongArray::class.asTypeName() -> LongArray::class.asTypeName()
else -> datatypeTypeName
}
}
Expand All @@ -114,9 +116,10 @@ internal class VssNodeSpecModel(
Array::class.parameterizedBy(String::class) -> "emptyArray<String>()"
IntArray::class.asTypeName() -> "IntArray(0)"
BooleanArray::class.asTypeName() -> "BooleanArray(0)"
FloatArray::class.asTypeName() -> "FloatArray(0)"
LongArray::class.asTypeName() -> "LongArray(0)"
ULongArray::class.asTypeName() -> "ULongArray(0)"
UIntArray::class.asTypeName() -> "UIntArray(0)"
FloatArray::class.asTypeName() -> "FloatArray(0)"

else -> throw IllegalArgumentException("No default value found for $valueTypeName!")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class VssNodeSpecModelTest : BehaviorSpec({
propertySpec.toString() shouldContain "kotlin.Int = 0"
}

then("it should the correct inline class data type") {
then("it should have the correct inline class data type") {
val propertySpec = classSpec.propertySpecs.find { it.name == "dataType" }

propertySpec?.getter.toString() shouldContain "kotlin.UInt::class"
Expand Down Expand Up @@ -99,7 +99,7 @@ class VssNodeSpecModelTest : BehaviorSpec({
propertySpec.toString() shouldContain "kotlin.LongArray = LongArray(0)"
}

then("it should the correct inline class data type") {
then("it should have the correct inline class data type") {
val propertySpec = classSpec.propertySpecs.find { it.name == "dataType" }

propertySpec?.getter.toString() shouldContain "kotlin.LongArray::class"
Expand Down

0 comments on commit 16bb945

Please sign in to comment.