package com.publicuhc.commands.proxies;

import com.publicuhc.commands.requests.CommandRequest;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.MatchResult;

import static org.powermock.api.mockito.PowerMockito.mock;

@RunWith(PowerMockRunner.class)
public class CommandProxyTest {

    private CommandProxy proxy;
    private TestTrigger trigger;

    @Test
    public void testTrigger() throws NoSuchMethodException, ProxyTriggerException {
        //set up the proxy
        proxy.setCommandMethod(trigger.getClass().getMethod("triggerMethod",CommandRequest.class));
        //make a fake request
        CommandRequest request = mock(CommandRequest.class);

        //trigger the proxy
        proxy.trigger(request);
    }

    @Before
    public void onStartUp() {
        proxy = new CommandProxy();
        trigger = mock(TestTrigger.class);
        proxy.setInstance(trigger);
    }

    private static class TestTrigger {
        public void triggerMethod(CommandRequest request){
        }
    }
}

@@ -388,16 +388,53 @@
 esult;%0A%0A
+import static org.mockito.Mockito.*;%0A
 import s
@@ -484,16 +484,16 @@
 o.mock;%0A
-
 %0A@RunWit
@@ -801,24 +801,31 @@
 hod(%22trigger
+Command
 Method%22,Comm
@@ -995,16 +995,82 @@
 equest);
+%0A%0A        verify(trigger, times(1)).triggerCommandMethod(request);
 %0A    %7D%0A%0A
@@ -1190,16 +1190,16 @@
 class);%0A
+
         
@@ -1235,122 +1235,7 @@
    %7D
-%0A%0A    private static class TestTrigger %7B%0A        public void triggerMethod(CommandRequest request)%7B%0A        %7D%0A    %7D
 %0A%7D%0A

verify method called