1 package net.pterodactylus.sone.fcp
3 import net.pterodactylus.sone.core.Core
4 import net.pterodactylus.sone.test.whenever
5 import org.hamcrest.MatcherAssert.assertThat
6 import org.hamcrest.Matchers.equalTo
10 * Unit test for [GetLocalSonesCommand].
12 class GetLocalSonesCommandTest : SoneCommandTest() {
14 private val sone1 = createSone("Id1", "Name1", "First1", "Last1", 1000L)
15 private val sone2 = createSone("Id2", "Name2", "First2", "Last2", 2000L)
17 override fun createCommand(core: Core) = GetLocalSonesCommand(core)
20 fun `command does not require write access`() {
21 assertThat(command.requiresWriteAccess, equalTo(false))
25 fun `command returns local sones`() {
26 val localSones = setOf(sone1, sone2)
27 whenever(core.localSones).thenReturn(localSones)
28 val response = command.execute(null)
29 val replyParameters = response.replyParameters
30 assertThat(replyParameters["Message"], equalTo("ListLocalSones"))
31 assertThat(replyParameters["LocalSones.Count"], equalTo("2"))
32 assertThat(replyParameters.parseSone("LocalSones.0."), matchesSone(sone1))
33 assertThat(replyParameters.parseSone("LocalSones.1."), matchesSone(sone2))