From 5684bc4813ffdbe26af73cb3cf6a1f62abbadedb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 10 Jan 2017 07:04:03 +0100 Subject: [PATCH] Move createSone() method to test base class --- .../net/pterodactylus/sone/fcp/GetLocalSonesCommandTest.kt | 13 ------------- .../kotlin/net/pterodactylus/sone/fcp/SoneCommandTest.kt | 11 +++++++++++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/test/kotlin/net/pterodactylus/sone/fcp/GetLocalSonesCommandTest.kt b/src/test/kotlin/net/pterodactylus/sone/fcp/GetLocalSonesCommandTest.kt index e3cda98..bd7ddac 100644 --- a/src/test/kotlin/net/pterodactylus/sone/fcp/GetLocalSonesCommandTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/fcp/GetLocalSonesCommandTest.kt @@ -1,9 +1,6 @@ package net.pterodactylus.sone.fcp import net.pterodactylus.sone.core.Core -import net.pterodactylus.sone.data.Profile -import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo @@ -21,16 +18,6 @@ class GetLocalSonesCommandTest : SoneCommandTest() { assertThat(command.requiresWriteAccess(), equalTo(false)) } - private fun createSone(id: String, name: String, firstName: String, lastName: String, time: Long) = mock().apply { - whenever(this.id).thenReturn(id) - whenever(this.name).thenReturn(name) - whenever(profile).thenReturn(Profile(this).apply { - this.firstName = firstName - this.lastName = lastName - }) - whenever(this.time).thenReturn(time) - } - @Test fun `command returns local sones`() { val localSones = setOf( diff --git a/src/test/kotlin/net/pterodactylus/sone/fcp/SoneCommandTest.kt b/src/test/kotlin/net/pterodactylus/sone/fcp/SoneCommandTest.kt index f34b19c..8344531 100644 --- a/src/test/kotlin/net/pterodactylus/sone/fcp/SoneCommandTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/fcp/SoneCommandTest.kt @@ -4,6 +4,7 @@ import com.google.common.base.Optional import com.google.common.base.Optional.absent import freenet.support.SimpleFieldSet import net.pterodactylus.sone.core.Core +import net.pterodactylus.sone.data.Profile import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.freenet.fcp.FcpException import net.pterodactylus.sone.test.mock @@ -38,6 +39,16 @@ abstract class SoneCommandTest { whenever(core.getPostReply(anyString())).thenReturn(absent()) } + protected fun createSone(id: String, name: String, firstName: String, lastName: String, time: Long) = mock().apply { + whenever(this.id).thenReturn(id) + whenever(this.name).thenReturn(name) + whenever(profile).thenReturn(Profile(this).apply { + this.firstName = firstName + this.lastName = lastName + }) + whenever(this.time).thenReturn(time) + } + protected fun executeCommandAndExpectFcpException() { expectedException.expect(FcpException::class.java) command.execute(parameters) -- 2.7.4