Skip to content

Commit

Permalink
chore(deps): update plugin kotlin-qa to v0.56.0
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] authored and DanySK committed Dec 10, 2023
1 parent d9ef0f8 commit 04ceb51
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DeviceCapabilities(
private val uid: Int,
private val networkManager: NetworkManager,
private val codePathFactory: CodePathFactory,
private val speaker: Speaker
private val speaker: Speaker,
) : AbstractExecutionContext<DeviceCapabilities>(SimpleExecutionEnvironment(), networkManager, codePathFactory),
Speaker {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object HelloProtelis {
repeat(deviceCount) {
g.addEdge(
devices[it],
devices[(it + 1) % deviceCount]
devices[(it + 1) % deviceCount],
)
}
devices.forEach { (it.networkManager as EmulatedNetworkManager).neighbors = Graphs.neighborSetOf(g, it) }
Expand All @@ -46,7 +46,7 @@ object HelloProtelis {
private fun setLeader(id: Int) =
devices[id].deviceCapabilities.executionEnvironment.put("leader", true)

private fun syncRunNTimes(n: Int) = repeat(n) {
private fun syncRunNTimes(n: Int) = repeat(n) { _ ->
devices.forEach { it.runCycle() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ class KotlinHelloTest : StringSpec() {
repeat(n) {
g.addEdge(
devices[it],
devices[(it + 1) % n]
devices[(it + 1) % n],
)
}
// Let every device know its neighbors and set the leader
devices.forEach { (it.networkManager as EmulatedNetworkManager).neighbors = Graphs.neighborSetOf(g, it) }
devices[leader].deviceCapabilities.executionEnvironment.put("leader", true)
// Run some cycles
repeat(iterations) {
repeat(iterations) { _ ->
devices.forEach { it.runCycle() }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object HelloProtelis {
devices += node
}
// Let the nodes make some iterations.
repeat(iterations) {
repeat(iterations) { _ ->
devices.forEach { it.runCycle() }
}
// Close the thread listening.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SocketNetworkManager(
private val uid: DeviceUID,
private val port: Int,
private val neighbors: Set<IPv4Host>,
private val address: String = "127.0.0.1"
private val address: String = "127.0.0.1",
) : NetworkManager {
private var messages: Map<DeviceUID, Map<CodePath, Any>> = emptyMap()
private var running = false
Expand Down Expand Up @@ -56,7 +56,7 @@ class SocketNetworkManager(
override fun failed(exc: Throwable, attachment: Any?) {
exc.printStackTrace()
}
}
},
)
}
try {
Expand Down Expand Up @@ -96,8 +96,10 @@ class SocketNetworkManager(
var client: AsynchronousSocketChannel? = null
var oos: ObjectOutputStream? = null
try {
client = AsynchronousSocketChannel.open()
val future = client!!.connect(InetSocketAddress(n.host, n.port))
client = checkNotNull(AsynchronousSocketChannel.open()) {
"Cannot open an asynchronous socket channel"
}
val future = client.connect(InetSocketAddress(n.host, n.port))
future.get()
oos = ObjectOutputStream(Channels.newOutputStream(client))
oos.writeObject(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class KotlinSocketTest : StringSpec() {
devices += d
speakers += s
}
repeat(iterations) {
repeat(iterations) { _ ->
devices.forEach { it.runCycle() }
}
devices.forEach { (it.networkManager as SocketNetworkManager).stop() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fun main() {
devices += node
}
// Let the nodes make some iterations.
repeat(iterations) {
repeat(iterations) { _ ->
devices.forEach { it.runCycle() }
}
// Close the thread listening.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class MqttNetworkManager(
address: String = defaultAddress,
port: Int = defaultPort,
private val qos: Int = defaultQoS,
private val neighbors: Set<String>
private val neighbors: Set<String>,
) : NetworkManager {
private var messages: Map<DeviceUID, Map<CodePath, Any>> = emptyMap()
private val broker = "tcp://$address:$port"
private var mqttClient = MqttAsyncClient(broker, uid.hashCode().toString(), MemoryPersistence())
private val mqttClient = MqttAsyncClient(broker, uid.hashCode().toString(), MemoryPersistence())

/**
* Starts the MQTT client and subscribes to the target topic.
Expand Down Expand Up @@ -54,7 +54,7 @@ class MqttNetworkManager(
* Shutdowns the MQTT client.
* @return the token to track the asynchronous task
*/
fun stop() = mqttClient.disconnect()
fun stop(): IMqttToken = mqttClient.disconnect()

/**
* Called by `ProtelisVM` during execution to send its current shared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class KotlinMqttTest : StringSpec() {
devices += d
speakers += s
}
repeat(iterations) {
repeat(iterations) { _ ->
devices.forEach { it.runCycle() }
}
devices.forEach { (it.networkManager as MqttNetworkManager).stop() }
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ mockito = [ "mockito-core", "mockito-junit-jupiter" ]
gitSemVer = "org.danilopianini.git-sensitive-semantic-versioning-gradle-plugin:2.0.4"
java-qa = "org.danilopianini.gradle-java-qa:1.28.0"
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-qa = "org.danilopianini.gradle-kotlin-qa:0.29.2"
kotlin-qa = "org.danilopianini.gradle-kotlin-qa:0.56.0"
multiJvmTesting = "org.danilopianini.multi-jvm-test-plugin:0.5.6"
shadowJar = "com.github.johnrengelman.shadow:8.1.1"

0 comments on commit 04ceb51

Please sign in to comment.