From 3de7a7584e921484c7e1a3c24d2edbbdc8851eee Mon Sep 17 00:00:00 2001 From: ljacqu Date: Tue, 15 Dec 2015 09:00:41 +0100 Subject: [PATCH] Merge prefix tests for AdminPermission and PlayerPermission --- .../permission/AdminPermissionTest.java | 18 ++----------- .../permission/PlayerPermissionTest.java | 25 +++---------------- 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/src/test/java/fr/xephi/authme/permission/AdminPermissionTest.java b/src/test/java/fr/xephi/authme/permission/AdminPermissionTest.java index 9a8625ac0..0c2c2b16c 100644 --- a/src/test/java/fr/xephi/authme/permission/AdminPermissionTest.java +++ b/src/test/java/fr/xephi/authme/permission/AdminPermissionTest.java @@ -13,9 +13,9 @@ import static org.junit.Assert.fail; public class AdminPermissionTest { @Test - public void shouldStartWithAuthMePrefix() { + public void shouldStartWithAuthMeAdminPrefix() { // given - String requiredPrefix = "authme."; + String requiredPrefix = "authme.admin."; // when/then for (AdminPermission permission : AdminPermission.values()) { @@ -26,20 +26,6 @@ public class AdminPermissionTest { } } - @Test - public void shouldContainAdminBranch() { - // given - String requiredBranch = ".admin."; - - // when/then - for (AdminPermission permission : AdminPermission.values()) { - if (!permission.getNode().contains(requiredBranch)) { - fail("The permission '" + permission + "' does not contain with the required branch '" - + requiredBranch + "'"); - } - } - } - @Test public void shouldHaveUniqueNodes() { // given diff --git a/src/test/java/fr/xephi/authme/permission/PlayerPermissionTest.java b/src/test/java/fr/xephi/authme/permission/PlayerPermissionTest.java index 6afc0ac07..632a2cf3e 100644 --- a/src/test/java/fr/xephi/authme/permission/PlayerPermissionTest.java +++ b/src/test/java/fr/xephi/authme/permission/PlayerPermissionTest.java @@ -13,32 +13,13 @@ import static org.junit.Assert.fail; public class PlayerPermissionTest { @Test - public void shouldStartWithAuthMePrefix() { + public void shouldStartWithPlayerPrefix() { // given - String requiredPrefix = "authme."; + String playerBranch = "authme.player."; // when/then for (PlayerPermission permission : PlayerPermission.values()) { - if (!permission.getNode().startsWith(requiredPrefix)) { - fail("The permission '" + permission + "' does not start with the required prefix '" + requiredPrefix - + "'"); - } - } - } - - @Test - public void shouldContainPlayerBranch() { - // given - String playerBranch = ".player."; - String adminBranch = ".admin."; - - // when/then - for (PlayerPermission permission : PlayerPermission.values()) { - if (permission.getNode().contains(adminBranch)) { - fail("The permission '" + permission + "' should not use a node with the admin-specific branch '" - + adminBranch + "'"); - - } else if (!permission.getNode().contains(playerBranch)) { + if (!permission.getNode().startsWith(playerBranch)) { fail("The permission '" + permission + "' should use a node with the player-specific branch '" + playerBranch + "'"); }