package me.chyxion.tigon.webmvc.test;

import java.util.Map;
import org.junit.Test;
import java.util.HashMap;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * @version 0.0.1
 * @since 0.0.1
 * @author Shaun Chyxion <br>
 * chyxion@163.com <br>
 * Jan 27, 2015 3:27:08 PM
 */
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = Main.class)
@SpringBootTest
public class SiteControllerTest {

    @Autowired
    private ControllerTestTool t;

    @Test
    public void testIndex() {
        t.print(t.get("/"));
    }

    @Test
    public void testRaw() {
        t.print(t.get("/raw"));
    }

    @Test
    public void testInt() {
        t.print(t.get("/int"));
    }

    @Test
    public void testFtl() {
        t.print(t.get("/test"));
    }

    @Test
    public void testViewModels() {
        t.print(t.get("/view-model"));
    }

    @Test
    public void testListResult() {
        t.print(t.get("/list-result"));
    }

    @Test
    public void testListResult1() {
        t.print(t.get("/list-result1"));
    }

    @Test
    public void testExtJsCommon() {
        t.print(t.get("/assets/js/extjs-commons.js"));
    }

    @Test
    public void testPost() {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", "id");
        params.put("name", "Shaun Chyxion");
        params.put("gender", "");
        t.print(t.post("/post", params));
    }

    @Test
    public void testRequired() {
        Map<String, Object> params = new HashMap<String, Object>();
        // params.put("param", "");
        t.print(t.post("/required", params));
    }
}
