From 062e4613574ed542e82cd2d814e32de2a4e751fe Mon Sep 17 00:00:00 2001 From: ljacqu Date: Fri, 5 Aug 2016 21:27:57 +0200 Subject: [PATCH] #337 Minor improvements in plugin.yml consistency test - Make static field immutable - Use stricter constraint for checking children paths - Improve error path logged upon error --- .../authme/permission/PermissionConsistencyTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/java/fr/xephi/authme/permission/PermissionConsistencyTest.java b/src/test/java/fr/xephi/authme/permission/PermissionConsistencyTest.java index 9ad69ec58..55c22eb85 100644 --- a/src/test/java/fr/xephi/authme/permission/PermissionConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/permission/PermissionConsistencyTest.java @@ -1,5 +1,6 @@ package fr.xephi.authme.permission; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import fr.xephi.authme.util.StringUtils; import org.bukkit.configuration.MemorySection; @@ -126,7 +127,7 @@ public class PermissionConsistencyTest { Map permissions = new HashMap<>(); addChildren(permsList, permissions); - return permissions; + return ImmutableMap.copyOf(permissions); } /** @@ -161,7 +162,8 @@ public class PermissionConsistencyTest { */ private static void validateChildren(PermissionDefinition definition, List errorList) { // Replace ending .* in path if present, e.g. authme.player.* -> authme.player - String root = definition.node.replaceAll("\\.\\*$", ""); + // Add ending '.' since we want all children to be children, i.e. authme.playertest would not be OK + String root = definition.node.replaceAll("\\.\\*$", "") + "."; List badChildren = new ArrayList<>(); for (String child : definition.children) { if (!child.startsWith(root)) { @@ -245,7 +247,7 @@ public class PermissionConsistencyTest { children.add(parentSection.getCurrentPath() + "." + entry.getKey()); } else { throw new IllegalStateException("Found child entry at '" + entry.getKey() + "' with value " - + "of unexpected type: '" + entry.getValue() + "'"); + + "of unexpected type: '" + parentSection.getCurrentPath() + "." + entry.getValue() + "'"); } } }