Skip to content

Commit 7bc6500

Browse files
author
Robert Winkler
committed
Fixed compile issues
1 parent 8823974 commit 7bc6500

File tree

7 files changed

+15
-23
lines changed

7 files changed

+15
-23
lines changed

kotlin-wot-binding-http/src/main/kotlin/http/HttpProtocolServer.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ fun Application.setupRouting(servient: Servient) {
9393
}
9494
}
9595
route("/properties/{name}") {
96+
/*
9697
get("/observable") {
9798
call.respond("Observing property", typeInfo<String>())
9899
}
100+
*/
99101
get {
100102
val id = call.parameters["id"] ?: return@get call.response.status(HttpStatusCode.BadRequest)
101103
val propertyName = call.parameters["name"]
@@ -116,6 +118,7 @@ fun Application.setupRouting(servient: Servient) {
116118
if (!property.readOnly) {
117119
val newValue = call.receive<Any>()
118120
// TODO handle write logic
121+
119122
call.response.status(HttpStatusCode.OK)
120123
} else {
121124
call.response.status(HttpStatusCode.BadRequest)

kotlin-wot-binding-http/src/test/kotlin/http/HttpProtocolServerTest.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import io.ktor.client.*
1010
import io.ktor.client.call.*
1111
import io.ktor.client.plugins.contentnegotiation.*
1212
import io.ktor.client.request.*
13-
import io.ktor.client.statement.*
1413
import io.ktor.http.*
1514
import io.ktor.serialization.jackson.*
1615
import io.ktor.server.engine.*
@@ -26,8 +25,8 @@ class HttpProtocolServerTest {
2625
private val mockServer: EmbeddedServer<*, *> = mockk()
2726
private val exposedThing: ExposedThing = ExposedThing(
2827
thing("test") {
29-
property("property1"){
30-
type = "integer"
28+
intProperty("property1"){
29+
title = "title"
3130
}
3231
action("action1"){
3332

@@ -121,10 +120,10 @@ class HttpProtocolServerTest {
121120
// Perform GET request on "/"
122121
val response = client.get("/")
123122

124-
println(response.bodyAsText())
125-
126123
val things : List<ExposedThing> = response.body()
127124

125+
assertEquals(1, things.size)
126+
128127
assertEquals(HttpStatusCode.OK, response.status)
129128
assertContains(things, exposedThing)
130129
}
@@ -141,8 +140,6 @@ class HttpProtocolServerTest {
141140
// Perform GET request on "/test"
142141
val response = client.get("/${exposedThing.id}")
143142

144-
println(response.bodyAsText())
145-
146143
val thing : ExposedThing = response.body()
147144

148145
assertEquals(HttpStatusCode.OK, response.status)
@@ -181,6 +178,7 @@ class HttpProtocolServerTest {
181178
}
182179

183180
assertEquals(HttpStatusCode.OK, response.status)
181+
184182
}
185183

186184
private fun ApplicationTestBuilder.httpClient(): HttpClient {

kotlin-wot/src/main/kotlin/Servient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class Servient(
198198
}
199199
}
200200

201-
fun getCredentials(id: String?): Any {
201+
fun getCredentials(id: String?): String {
202202
log.debug("Servient looking up credentials for '{}'", id)
203203
return "credentialStore.get(id)"
204204
}

kotlin-wot/src/main/kotlin/binding/ProtocolClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ interface ProtocolClient {
4545
* @param credentials
4646
* @return
4747
*/
48-
fun setSecurity(metadata: List<SecurityScheme>, credentials: Any): Boolean {
48+
fun setSecurity(metadata: List<SecurityScheme>, credentials: Map<String, String>): Boolean {
4949
return false
5050
}
5151

kotlin-wot/src/main/kotlin/thing/ConsumedThing.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ConsumedThing(private val servient: Servient, private val thing: Thing) :
7777
log.debug("'{}' setting credentials for '{}'", id, client)
7878

7979
val metadata = security.mapNotNull { key -> securityDefinitions[key] }
80-
client.setSecurity(metadata, servient.getCredentials(id))
80+
client.setSecurity(metadata, mapOf( "credentials" to servient.getCredentials(id)))
8181
}
8282
return scheme to client
8383
}

kotlin-wot/src/main/kotlin/thing/ExposedThing.kt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -238,23 +238,14 @@ data class Thing (
238238
@JsonInclude(NON_EMPTY) override var uriVariables: MutableMap<String, DataSchema<@Contextual Any>>? = null
239239
) : ThingDescription {
240240

241-
242-
243-
244-
/*
245-
fun Thing.property(name: String, configure: ThingProperty<Any>.() -> Unit) {
246-
this.properties[name] = ThingProperty<Any>().apply(configure)
247-
}
248-
*/
249-
250241
fun Thing.stringProperty(name: String, configure: StringProperty.() -> Unit) {
251-
this.properties[name] = StringProperty().apply(configure) as ThingProperty<Any>
242+
this.properties[name] = StringProperty().apply(configure)
252243
}
253244
fun Thing.intProperty(name: String, configure: IntProperty.() -> Unit) {
254-
this.properties[name] = IntProperty().apply(configure) as ThingProperty<Any>
245+
this.properties[name] = IntProperty().apply(configure)
255246
}
256247
fun Thing.booleanProperty(name: String, configure: BooleanProperty.() -> Unit) {
257-
this.properties[name] = BooleanProperty().apply(configure) as ThingProperty<Any>
248+
this.properties[name] = BooleanProperty().apply(configure)
258249
}
259250

260251
fun Thing.action(name: String, configure: ThingAction<Any, Any>.() -> Unit) {

kotlin-wot/src/main/kotlin/thing/event/ExposedThingEvent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import kotlinx.serialization.Transient
1919
import org.slf4j.LoggerFactory
2020

2121
@Serializable
22-
data class ExposedThingEvent<T, S, C>(private val event: ThingEvent<T, S, C> = ThingEvent()) : EventAffordance<T, S, C> by event {
22+
data class ExposedThingEvent<T, S, C>(private val event: EventAffordance<T, S, C> = ThingEvent()) : EventAffordance<T, S, C> by event {
2323

2424
@Transient @JsonIgnore private val state : EventState<T> = EventState()
2525

0 commit comments

Comments
 (0)