@@ -0,0 +1,2735 @@
+/*%0A * TesterTest.java%0A *%0A * Copyright (c) 2014. Graham Howden %3Cgraham_howden1 at yahoo.co.uk%3E.%0A *%0A * This file is part of PluginFramework.%0A *%0A * PluginFramework is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A *%0A * PluginFramework is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU General Public License for more details.%0A *%0A * You should have received a copy of the GNU General Public License%0A * along with PluginFramework.  If not, see %3Chttp ://www.gnu.org/licenses/%3E.%0A */%0A%0Apackage com.publicuhc.pluginframework.routing.tester;%0A%0Aimport org.bukkit.command.Command;%0Aimport org.bukkit.command.CommandSender;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.powermock.modules.junit4.PowerMockRunner;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0Aimport static org.powermock.api.mockito.PowerMockito.mock;%0Aimport static org.powermock.api.mockito.PowerMockito.when;%0A%0A@RunWith(PowerMockRunner.class)%0Apublic class PermissionTesterTest%0A%7B%0A    @Test%0A    public void test_permission_tester()%0A    %7B%0A        Command command = mock(Command.class);%0A        CommandSender sender = mock(CommandSender.class);%0A        String%5B%5D args = new String%5B0%5D;%0A%0A        PermissionTester tester = new PermissionTester();%0A%0A        //test no permissions set pass%0A        assertThat(tester.testCommand(command, sender, args)).isTrue();%0A%0A        //test missing permission fail%0A        tester.add(%22TEST.PERMISSION.1%22);%0A        when(sender.hasPermission(%22TEST.PERMISSION.1%22)).thenReturn(false);%0A        assertThat(tester.testCommand(command, sender, args)).isFalse();%0A%0A        //test permission pass%0A        when(sender.hasPermission(%22TEST.PERMISSION.1%22)).thenReturn(true);%0A        assertThat(tester.testCommand(command, sender, args)).isTrue();%0A%0A        //add another permission%0A        tester.add(%22TEST.PERMISSION.2%22);%0A%0A        //test matching all fail%0A        tester.setMatchingAll(true);%0A        when(sender.hasPermission(%22TEST.PERMISSION.2%22)).thenReturn(false);%0A        assertThat(tester.testCommand(command, sender, args)).isFalse();%0A%0A        //test not matching all pass%0A        tester.setMatchingAll(false);%0A        assertThat(tester.testCommand(command, sender, args)).isTrue();%0A%0A        //test matching all pass%0A        tester.setMatchingAll(true);%0A        when(sender.hasPermission(%22TEST.PERMISSION.2%22)).thenReturn(true);%0A        assertThat(tester.testCommand(command, sender, args)).isTrue();%0A    %7D%0A%7D%0A

test for permissiontester