### Question:
PermissionsManager implements Reloadable { public boolean hasPermission(CommandSender sender, PermissionNode permissionNode) { if (permissionNode == null) { return true; } if (!(sender instanceof Player) || !isEnabled()) { return permissionNode.getDefaultPermission().evaluate(sender); } Player player = (Player) sender; return player.hasPermission(permissionNode.getNode()); } @Inject  PermissionsManager(Server server, PluginManager pluginManager, Settings settings); boolean isEnabled(); @Override void reload(); void onPluginEnable(String pluginName); void onPluginDisable(String pluginName); PermissionsSystemType getPermissionSystem(); boolean hasPermission(CommandSender sender, PermissionNode permissionNode); boolean hasPermission(JoiningPlayer joiningPlayer, PermissionNode permissionNode); boolean hasPermissionOffline(OfflinePlayer player, PermissionNode permissionNode); boolean hasPermissionOffline(String name, PermissionNode permissionNode); boolean hasGroupSupport(); Collection<String> getGroups(OfflinePlayer player); String getPrimaryGroup(OfflinePlayer player); boolean isInGroup(OfflinePlayer player, String groupName); boolean addGroup(OfflinePlayer player, String groupName); boolean addGroups(OfflinePlayer player, Collection<String> groupNames); boolean removeGroup(OfflinePlayer player, String groupName); boolean removeGroups(OfflinePlayer player, Collection<String> groupNames); boolean setGroup(OfflinePlayer player, String groupName); boolean removeAllGroups(OfflinePlayer player); void loadUserData(UUID uuid); void loadUserData(String name);  }### Answer:
@Test public void shouldUseDefaultPermissionForCommandSender() { PermissionNode node = TestPermissions.LOGIN; CommandSender sender = mock(CommandSender.class); boolean result = permissionsManager.hasPermission(sender, node); assertThat(result, equalTo(true)); }
@Test public void shouldGrantToOpCommandSender() { PermissionNode node = TestPermissions.DELETE_USER; CommandSender sender = mock(CommandSender.class); given(sender.isOp()).willReturn(true); boolean result = permissionsManager.hasPermission(sender, node); assertThat(result, equalTo(true)); }
@Test public void shouldDenyPermissionEvenForOpCommandSender() { PermissionNode node = TestPermissions.WORLD_DOMINATION; CommandSender sender = mock(CommandSender.class); boolean result = permissionsManager.hasPermission(sender, node); assertThat(result, equalTo(false)); }
@Test public void shouldAllowForNonOpPlayer() { PermissionNode node = TestPermissions.LOGIN; Player player = mock(Player.class); boolean result = permissionsManager.hasPermission(player, node); assertThat(result, equalTo(true)); }
@Test public void shouldDenyForNonOpPlayer() { PermissionNode node = TestPermissions.DELETE_USER; Player player = mock(Player.class); boolean result = permissionsManager.hasPermission(player, node); assertThat(result, equalTo(false)); }
@Test public void shouldAllowForOpPlayer() { PermissionNode node = TestPermissions.DELETE_USER; Player player = mock(Player.class); given(player.isOp()).willReturn(true); boolean result = permissionsManager.hasPermission(player, node); assertThat(result, equalTo(true)); }
@Test public void shouldDenyEvenForOpPlayer() { PermissionNode node = TestPermissions.WORLD_DOMINATION; Player player = mock(Player.class); boolean result = permissionsManager.hasPermission(player, node); assertThat(result, equalTo(false)); }
@Test public void shouldHandleNullPermissionForCommandSender() { PermissionNode node = null; CommandSender sender = mock(CommandSender.class); boolean result = permissionsManager.hasPermission(sender, node); assertThat(result, equalTo(true)); }
@Test public void shouldHandleNullPermissionForPlayer() { PermissionNode node = null; Player player = mock(Player.class); boolean result = permissionsManager.hasPermission(player, node); assertThat(result, equalTo(true)); }