From: David ‘Bombe’ Roden Date: Sun, 8 Jan 2017 00:34:15 +0000 (+0100) Subject: Refactor FCP interface test slightly X-Git-Tag: 0.9.7^2~357 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8b159f6c1ebc844c75842a6d6a735c16abc5d8e5;p=Sone.git Refactor FCP interface test slightly --- diff --git a/src/test/java/net/pterodactylus/sone/fcp/FcpInterfaceTest.java b/src/test/java/net/pterodactylus/sone/fcp/FcpInterfaceTest.java index 2312907..d1c31ad 100644 --- a/src/test/java/net/pterodactylus/sone/fcp/FcpInterfaceTest.java +++ b/src/test/java/net/pterodactylus/sone/fcp/FcpInterfaceTest.java @@ -6,6 +6,7 @@ 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; @@ -33,25 +34,24 @@ public class FcpInterfaceTest { assertThat(fcpInterface.isActive(), is(false)); } + private void setAndVerifyAccessRequired(FullAccessRequired fullAccessRequired) { + fcpInterface.fullAccessRequiredChanged(new FullAccessRequiredChanged(fullAccessRequired)); + assertThat(fcpInterface.getFullAccessRequired(), is(fullAccessRequired)); + } + @Test public void setFullAccessRequiredCanSetAccessToNo() { - fcpInterface.fullAccessRequiredChanged( - new FullAccessRequiredChanged(NO)); - assertThat(fcpInterface.getFullAccessRequired(), is(NO)); + setAndVerifyAccessRequired(NO); } @Test public void setFullAccessRequiredCanSetAccessToWriting() { - fcpInterface.fullAccessRequiredChanged( - new FullAccessRequiredChanged(WRITING)); - assertThat(fcpInterface.getFullAccessRequired(), is(WRITING)); + setAndVerifyAccessRequired(WRITING); } @Test public void setFullAccessRequiredCanSetAccessToAlways() { - fcpInterface.fullAccessRequiredChanged( - new FullAccessRequiredChanged(ALWAYS)); - assertThat(fcpInterface.getFullAccessRequired(), is(ALWAYS)); + setAndVerifyAccessRequired(ALWAYS); } }