package org.docksidestage.remote.maihama.showbase.wx;

import javax.annotation.Resource;

import org.dbflute.remoteapi.mock.MockHttpClient;
import org.docksidestage.remote.maihama.showbase.wx.remogen.routing.resola.RemoteWxRemogenRoutingResolaReturn;
import org.docksidestage.remote.maihama.showbase.wx.remogen.tricky.nobody.RemoteWxRemogenTrickyNobodyReturn;
import org.docksidestage.unit.UnitFortressWebTestCase;
import org.lastaflute.web.servlet.request.RequestManager;

/**
 * @author jflute
 */
public class RemoteMaihamaShowbaseWxBhvTest extends UnitFortressWebTestCase {

    @Resource
    private RequestManager requestManager;

    public void test_requestRemogenTrickyNobody_bodyNotPresent() {
        // ## Arrange ##
        String json = "{key=sea, value=mystic}";
        MockHttpClient client = MockHttpClient.create(response -> {
            response.peekRequest(request -> {
                log(request);
                assertFalse(request.getBody().isPresent());
            });
            response.asJsonDirectly(json, request -> true);
        });
        registerMock(client);
        RemoteMaihamaShowbaseWxBhv bhv = new RemoteMaihamaShowbaseWxBhv(requestManager);
        inject(bhv);

        // ## Act ##
        RemoteWxRemogenTrickyNobodyReturn ret = bhv.requestRemogenTrickyNobody();

        // ## Assert ##
        assertEquals("sea", ret.key);
        assertEquals("mystic", ret.value);
    }

    public void test_requestRemogenRoutingResola_basic() {
        // ## Arrange ##
        String json = "{method=resola}";
        MockHttpClient client = MockHttpClient.create(response -> {
            response.peekRequest(request -> {
                log(request);
                assertFalse(request.getBody().isPresent());
            });
            response.asJsonDirectly(json, request -> true);
        });
        registerMock(client);
        RemoteMaihamaShowbaseWxBhv bhv = new RemoteMaihamaShowbaseWxBhv(requestManager);
        inject(bhv);

        // ## Act ##
        RemoteWxRemogenRoutingResolaReturn ret = bhv.requestRemogenRoutingResola(1);

        // ## Assert ##
        log(ret);
    }
}

@@ -116,27 +116,218 @@
 api.
-mock.MockHttpClient
+exception.RemoteApiPathVariableNullElementException;%0Aimport org.dbflute.remoteapi.mock.MockHttpClient;%0Aimport org.docksidestage.remote.maihama.showbase.wx.remogen.routing.piari.RemoteWxRemogenRoutingPiariReturn
 ;%0Aim
@@ -821,16 +821,289 @@
 nager;%0A%0A
+    // ===================================================================================%0A    //                                                                              Tricky%0A    //                                                                              ======%0A
     publ
@@ -1884,16 +1884,2377 @@
 %0A    %7D%0A%0A
+    // ===================================================================================%0A    //                                                                             Routing%0A    //                                                                             =======%0A    // -----------------------------------------------------%0A    //                                    Optional Parameter%0A    //                                    ------------------%0A    public void test_requestRemogenRoutingPiari_optionalParameter_basic() %7B%0A        // ## Arrange ##%0A        String json = %22%7Bmethod=resola%7D%22;%0A        MockHttpClient client = MockHttpClient.create(response -%3E %7B%0A            response.peekRequest(request -%3E %7B%0A                log(request);%0A                assertContains(request.getUrl(), %22piari/plaza%22);%0A                assertFalse(request.getBody().isPresent());%0A            %7D);%0A            response.asJsonDirectly(json, request -%3E true);%0A        %7D);%0A        registerMock(client);%0A        RemoteMaihamaShowbaseWxBhv bhv = new RemoteMaihamaShowbaseWxBhv(requestManager);%0A        inject(bhv);%0A%0A        // ## Act ##%0A        RemoteWxRemogenRoutingPiariReturn ret = bhv.requestRemogenRoutingPiari(%22plaza%22);%0A%0A        // ## Assert ##%0A        log(ret);%0A    %7D%0A%0A    public void test_requestRemogenRoutingPiari_optionalParameter_empty() %7B%0A        // ## Arrange ##%0A        String json = %22%7Bmethod=resola%7D%22;%0A        MockHttpClient client = MockHttpClient.create(response -%3E %7B%0A            response.peekRequest(request -%3E %7B%0A                log(request);%0A                assertContains(request.getUrl(), %22piari%22);%0A                assertNotContains(request.getUrl(), %22piari/plaza%22);%0A                assertFalse(request.getBody().isPresent());%0A            %7D);%0A            response.asJsonDirectly(json, request -%3E true);%0A        %7D);%0A        registerMock(client);%0A        RemoteMaihamaShowbaseWxBhv bhv = new RemoteMaihamaShowbaseWxBhv(requestManager);%0A        inject(bhv);%0A%0A        // ## Act ##%0A        // ## Assert ##%0A        assertException(RemoteApiPathVariableNullElementException.class, () -%3E %7B // not supported for now%0A            bhv.requestRemogenRoutingPiari(null);%0A        %7D);%0A    %7D%0A%0A    // -----------------------------------------------------%0A    //                                               Wording%0A    //                                               -------%0A
     publ
@@ -4294,16 +4294,24 @@
 gResola_
+wording_
 basic() 

make test_requestRemogenRoutingPiari_optionalParameter_basic()