Merge prefix tests for AdminPermission and PlayerPermission

This commit is contained in:
ljacqu 2015-12-15 09:00:41 +01:00
parent bfebf6dc44
commit 3de7a7584e
2 changed files with 5 additions and 38 deletions

View File

@ -13,9 +13,9 @@ import static org.junit.Assert.fail;
public class AdminPermissionTest { public class AdminPermissionTest {
@Test @Test
public void shouldStartWithAuthMePrefix() { public void shouldStartWithAuthMeAdminPrefix() {
// given // given
String requiredPrefix = "authme."; String requiredPrefix = "authme.admin.";
// when/then // when/then
for (AdminPermission permission : AdminPermission.values()) { 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 @Test
public void shouldHaveUniqueNodes() { public void shouldHaveUniqueNodes() {
// given // given

View File

@ -13,32 +13,13 @@ import static org.junit.Assert.fail;
public class PlayerPermissionTest { public class PlayerPermissionTest {
@Test @Test
public void shouldStartWithAuthMePrefix() { public void shouldStartWithPlayerPrefix() {
// given // given
String requiredPrefix = "authme."; String playerBranch = "authme.player.";
// when/then // when/then
for (PlayerPermission permission : PlayerPermission.values()) { for (PlayerPermission permission : PlayerPermission.values()) {
if (!permission.getNode().startsWith(requiredPrefix)) { if (!permission.getNode().startsWith(playerBranch)) {
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)) {
fail("The permission '" + permission + "' should use a node with the player-specific branch '" fail("The permission '" + permission + "' should use a node with the player-specific branch '"
+ playerBranch + "'"); + playerBranch + "'");
} }