parent
c95cdc1c9b
commit
5668377307
|
@ -1,32 +1,44 @@
|
||||||
package info.nightscout.plugins.sync.tidepool.comm
|
package info.nightscout.plugins.sync.tidepool.comm
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.plugins.sync.tidepool.messages.AuthReplyMessage
|
import info.nightscout.plugins.sync.tidepool.messages.AuthReplyMessage
|
||||||
import info.nightscout.plugins.sync.tidepool.messages.DatasetReplyMessage
|
import info.nightscout.plugins.sync.tidepool.messages.DatasetReplyMessage
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class SessionTest {
|
class SessionTest {
|
||||||
|
|
||||||
|
private val session = Session("", "", null)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun populateBody() {
|
fun emptySession() {
|
||||||
val session = Session("", "", null)
|
assertThat(session.authReply).isNull()
|
||||||
Assertions.assertNull(session.authReply)
|
assertThat(session.datasetReply).isNull()
|
||||||
|
|
||||||
// test authReply
|
|
||||||
val authReplyMessage = AuthReplyMessage()
|
|
||||||
session.populateBody(authReplyMessage)
|
|
||||||
Assertions.assertEquals(authReplyMessage, session.authReply)
|
|
||||||
|
|
||||||
// test datasetReply
|
|
||||||
val datasetReplyMessage = DatasetReplyMessage()
|
|
||||||
Assertions.assertNull(session.datasetReply)
|
|
||||||
session.populateBody(datasetReplyMessage)
|
|
||||||
Assertions.assertEquals(datasetReplyMessage, session.datasetReply)
|
|
||||||
|
|
||||||
// test datasetReply as array
|
|
||||||
val list: List<DatasetReplyMessage> = listOf(datasetReplyMessage)
|
|
||||||
session.datasetReply = null
|
|
||||||
session.populateBody(list)
|
|
||||||
Assertions.assertEquals(datasetReplyMessage, session.datasetReply)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
|
fun authReply() {
|
||||||
|
val authReplyMessage = AuthReplyMessage()
|
||||||
|
|
||||||
|
session.populateBody(authReplyMessage)
|
||||||
|
|
||||||
|
assertThat(session.authReply).isEqualTo(authReplyMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun datasetReply() {
|
||||||
|
val datasetReplyMessage = DatasetReplyMessage()
|
||||||
|
|
||||||
|
session.populateBody(datasetReplyMessage)
|
||||||
|
|
||||||
|
assertThat(session.datasetReply).isEqualTo(datasetReplyMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun datasetReply_asList() {
|
||||||
|
val datasetReplyMessage = DatasetReplyMessage()
|
||||||
|
|
||||||
|
session.populateBody(listOf(datasetReplyMessage))
|
||||||
|
|
||||||
|
assertThat(session.datasetReply).isEqualTo(datasetReplyMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue