Skip to content

Commit a3bd789

Browse files
test: add tests for room historical data extractor api
1 parent 8c6ac38 commit a3bd789

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/test/kotlin/infrastructure/api/RoomApiTest.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import application.presenter.api.model.EnvironmentalDataApiDto
1212
import application.presenter.api.model.RoomApiDto
1313
import application.presenter.api.model.RoomApiDtoType
1414
import application.presenter.api.model.RoomEntry
15+
import entity.zone.RoomEnvironmentalData
1516
import infrastructure.api.KtorTestingUtility.apiTestApplication
1617
import infrastructure.api.util.ApiResponses
1718
import io.kotest.assertions.ktor.client.shouldHaveStatus
@@ -126,4 +127,22 @@ class RoomApiTest : StringSpec({
126127
client.delete("/api/v1/rooms/${roomEntry.id}") shouldHaveStatus HttpStatusCode.NotFound
127128
}
128129
}
130+
131+
"It should be possible to ask for historical room environmental data of an existing room" {
132+
apiTestApplication {
133+
insertRoom(roomEntry)
134+
val response = client.get("/api/v1/rooms/data/${roomEntry.id}")
135+
response shouldHaveStatus HttpStatusCode.OK
136+
Json.decodeFromString<ApiResponses.ResponseEntryList<ApiResponses.ResponseTimedEntry<
137+
RoomEnvironmentalData>>>(
138+
response.bodyAsText()
139+
).total shouldBe 0
140+
}
141+
}
142+
143+
"It should handle the get request on the historical room environmental data of a non existing room" {
144+
apiTestApplication {
145+
client.get("/api/v1/rooms/data/${roomEntry.id}") shouldHaveStatus HttpStatusCode.NotFound
146+
}
147+
}
129148
})

0 commit comments

Comments
 (0)