package net.kencochrane.raven.event.helper;

import mockit.Expectations;
import mockit.Injectable;
import mockit.Mocked;
import mockit.Verifications;
import net.kencochrane.raven.event.EventBuilder;
import net.kencochrane.raven.event.interfaces.HttpInterface;
import net.kencochrane.raven.event.interfaces.SentryInterface;
import net.kencochrane.raven.servlet.RavenServletRequestListener;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import javax.servlet.http.HttpServletRequest;

public class HttpEventBuilderHelperTest {
    private HttpEventBuilderHelper httpEventBuilderHelper;
    @Injectable
    private EventBuilder mockEventBuilder;
    @Mocked("getServletRequest")
    private RavenServletRequestListener ravenServletRequestListener;

    @BeforeMethod
    public void setUp() throws Exception {
        httpEventBuilderHelper = new HttpEventBuilderHelper();
    }

    @Test
    public void testNoRequest() throws Exception {
        httpEventBuilderHelper.helpBuildingEvent(mockEventBuilder);

        new Verifications() {{
            mockEventBuilder.addSentryInterface((SentryInterface) any);
            times = 0;
        }};
    }

    @Test
    public void testWithRequest(@Injectable final HttpServletRequest mockHttpServletRequest) throws Exception {
        new Expectations() {{
            RavenServletRequestListener.getServletRequest();
            result = mockHttpServletRequest;
        }};

        httpEventBuilderHelper.helpBuildingEvent(mockEventBuilder);

        new Verifications() {{
            mockEventBuilder.addSentryInterface(this.<HttpInterface>withNotNull());
        }};
    }
}

@@ -771,16 +771,144 @@
 istener;
+%0A    @Injectable%0A    private HttpServletRequest mockHttpServletRequest;%0A    @Mocked%0A    private HttpInterface mockHttpInterface;
 %0A%0A    @B
@@ -1085,32 +1085,162 @@
 ows Exception %7B%0A
+        new Expectations() %7B%7B%0A            RavenServletRequestListener.getServletRequest();%0A            result = null;%0A        %7D%7D;%0A
         httpEven
@@ -1439,32 +1439,32 @@
    %7D%0A%0A    @Test%0A
+
     public void 
@@ -1483,67 +1483,8 @@
 est(
-@Injectable final HttpServletRequest mockHttpServletRequest
 ) th

Update the unit tests to take into account the copy of the HttpServletRequest