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
7 import org.junit.Before
9 import org.mockito.Mockito.verify
12 * Unit test for [LockSoneCommand].
14 class LockSoneCommandTest : SoneCommandTest() {
16 override fun createCommand(core: Core) = LockSoneCommand(core)
20 whenever(core.getSone("RemoteSoneId")).thenReturn(remoteSone)
21 whenever(core.getSone("LocalSoneId")).thenReturn(localSone)
22 whenever(localSone.id).thenReturn("LocalSoneId")
26 fun `command requires write access`() {
27 assertThat(command.requiresWriteAccess, equalTo(true))
31 fun `request without any parameters results in FCP exception`() {
32 requestWithoutAnyParameterResultsInFcpException()
36 fun `request with invalid sone parameter results in FCP exception`() {
37 requestWithInvalidSoneParameterResultsInFcpException()
41 fun `request with valid remote sone parameter results in FCP exception`() {
42 requestWithValidRemoteSoneParameterResultsInFcpException()
46 fun `request with local sone parameter locks the sone`() {
47 parameters += "Sone" to "LocalSoneId"
48 val replyParameters = command.execute(parameters).replyParameters
49 assertThat(replyParameters["Message"], equalTo("SoneLocked"))
50 assertThat(replyParameters["Sone"], equalTo("LocalSoneId"))
51 verify(core).lockSone(localSone)