Skip to content

Commit 55158f8

Browse files
author
Robert Winkler
committed
Disable Integration Tests
1 parent 46801b1 commit 55158f8

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

kotlin-wot-integration-tests/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ plugins {
88
id("io.spring.dependency-management") version "1.1.7"
99
}
1010

11-
//tasks.named<Test>("test") {
12-
// enabled = false
13-
//}
11+
tasks.named<Test>("test") {
12+
enabled = false
13+
}
1414

1515
dependencies {
1616
// Replace the following with the starter dependencies of specific modules you wish to use

kotlin-wot-integration-tests/src/test/kotlin/integration/QuickTest.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ package ai.ancf.lmos.wot.integration
44
import ai.ancf.lmos.sdk.agents.WotConversationalAgent
55
import ai.ancf.lmos.sdk.agents.lastMessage
66
import ai.ancf.lmos.sdk.agents.toAgentRequest
7-
import ai.ancf.lmos.sdk.model.AgentEvent
87
import kotlinx.coroutines.runBlocking
8+
import org.eclipse.lmos.arc.agents.AgentEvent
99
import java.util.concurrent.CountDownLatch
1010
import kotlin.test.Test
1111

@@ -36,10 +36,16 @@ class QuickTest {
3636

3737
val agent = WotConversationalAgent.create("http://localhost:8181/scraper")
3838

39+
/*
3940
agent.consumeEvent("agentEvent", AgentEvent::class) {
4041
println("Event: $it")
4142
latch.countDown()
4243
}
44+
*/
45+
agent.consumeEvent("agentEvent", AgentEvent::class).collect {
46+
println("Event: $it")
47+
latch.countDown()
48+
}
4349

4450
//val command = "What is the state of my lamp?"
4551
val command = "Scrape the page https://eclipse.dev/lmos/\""

lmos-kotlin-sdk-base/src/main/kotlin/sdk/agents/ConversationalAgent.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ai.ancf.lmos.sdk.agents
33
import ai.ancf.lmos.sdk.model.AgentRequest
44
import ai.ancf.lmos.sdk.model.AgentResult
55
import ai.ancf.lmos.sdk.model.Message
6+
import kotlinx.coroutines.flow.Flow
67
import kotlin.reflect.KClass
78

89
interface ConversationalAgent {
@@ -11,6 +12,7 @@ interface ConversationalAgent {
1112

1213
interface ConsumedConversationalAgent: ConversationalAgent {
1314
suspend fun <T : Any> consumeEvent(eventName: String, clazz: KClass<T>, listener: EventListener<T>)
15+
suspend fun <T : Any> consumeEvent(eventName: String, clazz: KClass<T>) : Flow<T>
1416
}
1517

1618
fun interface EventListener<T> {

lmos-kotlin-sdk-client/src/main/kotlin/sdk/WotConversationalAgent.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import ai.ancf.lmos.wot.binding.http.HttpsProtocolClientFactory
1010
import ai.ancf.lmos.wot.binding.websocket.WebSocketProtocolClientFactory
1111
import ai.ancf.lmos.wot.thing.ConsumedThing
1212
import io.opentelemetry.instrumentation.annotations.WithSpan
13+
import kotlinx.coroutines.flow.Flow
14+
import kotlinx.coroutines.flow.map
1315
import org.slf4j.Logger
1416
import org.slf4j.LoggerFactory
1517
import kotlin.reflect.KClass
@@ -53,7 +55,19 @@ class WotConversationalAgent private constructor(private val thing : ConsumedThi
5355
listener.handleEvent(parsedEvent)
5456
} catch (e: Exception) {
5557
log.error("Failed to parse event", e)
58+
throw e
5659
}
5760
})
5861
}
62+
63+
override suspend fun <T : Any> consumeEvent(eventName: String, clazz: KClass<T>): Flow<T> {
64+
return thing.consumeEvent(eventName).map { event ->
65+
try {
66+
JsonMapper.instance.treeToValue(event.value(), clazz.java)
67+
} catch (e: Exception) {
68+
log.error("Failed to parse event", e)
69+
throw e
70+
}
71+
}
72+
}
5973
}

0 commit comments

Comments
 (0)