/*
 * Copyright 2014-2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package org.dbflute.intro.app.web.client;

import org.dbflute.intro.unit.UnitIntroTestCase;
import org.dbflute.utflute.lastaflute.mock.TestingJsonData;
import org.lastaflute.web.response.JsonResponse;

import java.util.List;

/**
 * @author jflute
 */
public class ClientActionTest extends UnitIntroTestCase {

    // ===================================================================================
    //                                                                               Test
    //                                                                              ======
    public void test_list_success() throws Exception {
        // ## Arrange ##
        ClientAction action = new ClientAction();
        inject(action);

        // ## Act ##
        JsonResponse<List<ClientRowResult>> response = action.list();

        // ## Assert ##
        showJson(response);
        TestingJsonData<List<ClientRowResult>> jsonData = validateJsonData(response);
        List<ClientRowResult> detailBeanList = jsonData.getJsonResult();
        assertHasAnyElement(detailBeanList);
    }
}

@@ -656,16 +656,145 @@
 lient;%0A%0A
+import org.dbflute.intro.app.logic.intro.IntroPhysicalLogic;%0Aimport org.dbflute.intro.bizfw.tellfailure.ClientNotFoundException;%0A
 import o
@@ -834,16 +834,16 @@
 stCase;%0A
-
 import o
@@ -944,16 +944,72 @@
 ponse;%0A%0A
+import javax.annotation.Resource;%0A%0Aimport java.io.File;%0A
 import j
@@ -1109,16 +1109,355 @@
 Case %7B%0A%0A
+    // ===================================================================================%0A    //                                                                           Attribute%0A    //                                                                           =========%0A    @Resource%0A    private IntroPhysicalLogic introPhysicalLogic;%0A%0A
     // =
@@ -2174,24 +2174,24 @@
 onResult();%0A
-
         asse
@@ -2228,11 +2228,1474 @@
 );%0A    %7D
+%0A%0A    public void test_operation_success() throws Exception %7B%0A        // ## Arrange ##%0A        ClientAction action = new ClientAction();%0A        inject(action);%0A%0A        // ## Act ##%0A        JsonResponse%3CClientOperationResult%3E response = action.operation(UnitIntroTestCase.TEST_CLIENT_PROJECT);%0A%0A        // ## Assert ##%0A        showJson(response);%0A        TestingJsonData%3CClientOperationResult%3E jsonData = validateJsonData(response);%0A        ClientOperationResult operation = jsonData.getJsonResult();%0A        assertEquals(UnitIntroTestCase.TEST_CLIENT_PROJECT, operation.projectName);%0A    %7D%0A%0A    public void test_operation_fail() throws Exception %7B%0A        // ## Arrange ##%0A        ClientAction action = new ClientAction();%0A        inject(action);%0A%0A        // ## Act ##%0A        try %7B%0A            action.operation(%22akirakaniokasii_project_name%22);%0A        %7D catch (ClientNotFoundException ignore) %7B%0A            markHere(%22client_not_found%22);%0A        %7D%0A        // ## Assert ##%0A        assertMarked(%22client_not_found%22);%0A    %7D%0A%0A    public void test_delete_success() throws Exception %7B%0A        // ## Arrange ##%0A        ClientAction action = new ClientAction();%0A        inject(action);%0A        File client = introPhysicalLogic.findClientDir(UnitIntroTestCase.TEST_CLIENT_PROJECT);%0A        assertTrue(client.exists());%0A%0A        // ## Act ##%0A        action.delete(UnitIntroTestCase.TEST_CLIENT_PROJECT);%0A%0A        // ## Assert ##%0A        assertFalse(client.exists());%0A    %7D
 %0A%7D%0A

add client action test