From f55577d9fc4bb521d324a3c8848afb6600ef965d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 8 Jan 2017 01:44:45 +0100 Subject: [PATCH] Convert FCP interface test to Kotlin --- .../pterodactylus/sone/fcp/FcpInterfaceTest.java | 57 ---------------------- .../net/pterodactylus/sone/fcp/FcpInterfaceTest.kt | 56 +++++++++++++++++++++ 2 files changed, 56 insertions(+), 57 deletions(-) delete mode 100644 src/test/java/net/pterodactylus/sone/fcp/FcpInterfaceTest.java create mode 100644 src/test/java/net/pterodactylus/sone/fcp/FcpInterfaceTest.kt diff --git a/src/test/java/net/pterodactylus/sone/fcp/FcpInterfaceTest.java b/src/test/java/net/pterodactylus/sone/fcp/FcpInterfaceTest.java deleted file mode 100644 index d1c31ad..0000000 --- a/src/test/java/net/pterodactylus/sone/fcp/FcpInterfaceTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package net.pterodactylus.sone.fcp; - -import static net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.ALWAYS; -import static net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.NO; -import static net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.WRITING; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired; -import net.pterodactylus.sone.fcp.event.FcpInterfaceActivatedEvent; -import net.pterodactylus.sone.fcp.event.FcpInterfaceDeactivatedEvent; -import net.pterodactylus.sone.fcp.event.FullAccessRequiredChanged; - -import org.junit.Test; - -/** - * Unit test for {@link FcpInterface} and its subclasses. - * - * @author David ‘Bombe’ Roden - */ -public class FcpInterfaceTest { - - private final FcpInterface fcpInterface = new FcpInterface(null); - - @Test - public void fcpInterfaceCanBeActivated() { - fcpInterface.fcpInterfaceActivated(new FcpInterfaceActivatedEvent()); - assertThat(fcpInterface.isActive(), is(true)); - } - - @Test - public void fcpInterfaceCanBeDeactivated() { - fcpInterface.fcpInterfaceDeactivated(new FcpInterfaceDeactivatedEvent()); - assertThat(fcpInterface.isActive(), is(false)); - } - - private void setAndVerifyAccessRequired(FullAccessRequired fullAccessRequired) { - fcpInterface.fullAccessRequiredChanged(new FullAccessRequiredChanged(fullAccessRequired)); - assertThat(fcpInterface.getFullAccessRequired(), is(fullAccessRequired)); - } - - @Test - public void setFullAccessRequiredCanSetAccessToNo() { - setAndVerifyAccessRequired(NO); - } - - @Test - public void setFullAccessRequiredCanSetAccessToWriting() { - setAndVerifyAccessRequired(WRITING); - } - - @Test - public void setFullAccessRequiredCanSetAccessToAlways() { - setAndVerifyAccessRequired(ALWAYS); - } - -} diff --git a/src/test/java/net/pterodactylus/sone/fcp/FcpInterfaceTest.kt b/src/test/java/net/pterodactylus/sone/fcp/FcpInterfaceTest.kt new file mode 100644 index 0000000..1ec9473 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/fcp/FcpInterfaceTest.kt @@ -0,0 +1,56 @@ +package net.pterodactylus.sone.fcp + +import net.pterodactylus.sone.core.Core +import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired +import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.ALWAYS +import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.NO +import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired.WRITING +import net.pterodactylus.sone.fcp.event.FcpInterfaceActivatedEvent +import net.pterodactylus.sone.fcp.event.FcpInterfaceDeactivatedEvent +import net.pterodactylus.sone.fcp.event.FullAccessRequiredChanged +import net.pterodactylus.sone.test.mock +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo +import org.junit.Test + +/** + * Unit test for [FcpInterface] and its subclasses. + */ +class FcpInterfaceTest { + + private val core = mock() + private val fcpInterface = FcpInterface(core) + + @Test + fun `fcp interface can be activated`() { + fcpInterface.fcpInterfaceActivated(FcpInterfaceActivatedEvent()) + assertThat(fcpInterface.isActive, equalTo(true)) + } + + @Test + fun `fcp interface can be deactivated`() { + fcpInterface.fcpInterfaceDeactivated(FcpInterfaceDeactivatedEvent()) + assertThat(fcpInterface.isActive, equalTo(false)) + } + + private fun setAndVerifyAccessRequired(fullAccessRequired: FullAccessRequired) { + fcpInterface.fullAccessRequiredChanged(FullAccessRequiredChanged(fullAccessRequired)) + assertThat(fcpInterface.fullAccessRequired, equalTo(fullAccessRequired)) + } + + @Test + fun `set full access required can set access to no`() { + setAndVerifyAccessRequired(NO) + } + + @Test + fun `set full access required can set access to writing`() { + setAndVerifyAccessRequired(WRITING) + } + + @Test + fun `set full access required can set access to always`() { + setAndVerifyAccessRequired(ALWAYS) + } + +} -- 2.7.4