package org.burroloco.donkey.input.http;

import au.net.netstorm.boost.bullet.incredibles.core.Weaken;
import au.net.netstorm.boost.sniper.marker.HasFixtures;
import au.net.netstorm.boost.sniper.marker.LazyFields;
import au.net.netstorm.boost.sniper.marker.OverlaysWeb;
import au.net.netstorm.boost.spider.api.runtime.Nu;
import org.burroloco.config.core.Config;
import org.burroloco.donkey.config.HttpMessage;
import org.burroloco.donkey.data.cake.Cake;
import org.burroloco.donkey.data.cake.Slice;
import org.burroloco.donkey.glue.testcase.DonkeyTestCase;
import org.burroloco.donkey.transformation.gargler.Gargler;
import org.burroloco.util.date.Dates;

import java.util.Date;

public class HttpRequestHandlerMolecularTest extends DonkeyTestCase implements HasFixtures, LazyFields, OverlaysWeb {
    private static final String MESSAGE = "Hello World";
    private HttpRequestHandler subject;
    Gargler garglerMock;
    Config configDummy;
    Dates datesMock;
    Date dateDummy;
    Weaken weaken;
    Dates dates;
    Nu nu;

    public void overlay() {
    }

    public void fixtures() {
        wire.ref(datesMock).to(Dates.class);
        wire.ref(garglerMock).to(Gargler.class);
        subject = nu.nu(HttpRequestHandler.class, configDummy);
    }

    public void testHttpSlurp() throws InterruptedException {
        expect.oneCall(datesMock, dateDummy, "now");
        expect.oneCall(garglerMock, VOID, "slosh", configDummy, cake());
        subject.handleRequest(MESSAGE);
    }

    private Cake cake() {
        Cake out = nu.nu(Cake.class);
        out.add(slice(nu.nu(HttpMessage.class, MESSAGE)));
        return out;
    }

    private Slice slice(HttpMessage message) {
        Slice slice = nu.nu(Slice.class);
        slice.add("Message", weaken.w(message));
        slice.add("Date", dateDummy);
        return slice;
    }
}
@@ -39,69 +39,8 @@
 p;%0A%0A
-import au.net.netstorm.boost.bullet.incredibles.core.Weaken;%0A
 impo
@@ -150,64 +150,8 @@
 ds;%0A
-import au.net.netstorm.boost.sniper.marker.OverlaysWeb;%0A
 impo
@@ -243,56 +243,8 @@
 ig;%0A
-import org.burroloco.donkey.config.HttpMessage;%0A
 impo
@@ -615,21 +615,8 @@
 elds
-, OverlaysWeb
  %7B%0A 
@@ -809,85 +809,14 @@
     
-Weaken weaken;%0A    Dates dates;%0A    Nu nu;%0A%0A    public void overlay() %7B%0A    %7D
+Nu nu;
 %0A%0A  
@@ -1186,17 +1186,25 @@
 gDummy, 
-c
+expectedC
 ake());%0A
@@ -1267,17 +1267,25 @@
 te Cake 
-c
+expectedC
 ake() %7B%0A
@@ -1326,141 +1326,8 @@
 s);%0A
-        out.add(slice(nu.nu(HttpMessage.class, MESSAGE)));%0A        return out;%0A    %7D%0A%0A    private Slice slice(HttpMessage message) %7B%0A
     
@@ -1397,25 +1397,15 @@
 e%22, 
-weaken.w(message)
+MESSAGE
 );%0A 
@@ -1437,24 +1437,48 @@
 dateDummy);%0A
+        out.add(slice);%0A
         retu
@@ -1484,18 +1484,16 @@
 urn 
-slice
+out
 ;%0A    %7D%0A
 %7D
@@ -1491,9 +1491,10 @@
 ;%0A    %7D%0A
+%0A
 %7D

HttpRequestHandler.