🔥 Replace debug flag collection with simple flag
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / fcp / GetLocalSonesCommandTest.kt
1 package net.pterodactylus.sone.fcp
2
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
7 import org.junit.Test
8
9 /**
10  * Unit test for [GetLocalSonesCommand].
11  */
12 class GetLocalSonesCommandTest : SoneCommandTest() {
13
14         private val sone1 = createSone("Id1", "Name1", "First1", "Last1", 1000L)
15         private val sone2 = createSone("Id2", "Name2", "First2", "Last2", 2000L)
16
17         override fun createCommand(core: Core) = GetLocalSonesCommand(core)
18
19         @Test
20         fun `command does not require write access`() {
21                 assertThat(command.requiresWriteAccess, equalTo(false))
22         }
23
24         @Test
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))
34         }
35
36 }