package me.chyxion.tigon.test;

import me.chyxion.tigon.model.M3;

import me.chyxion.tigon.mybatis.Search;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

/**
 * @version 0.0.1
 * @since 0.0.1
 * @author Shaun Chyxion <br>
 * chyxion@163.com <br>
 * May 13, 2016 10:45:07 AM
 */
public class TestDriver {
    private static final Logger log = 
        LoggerFactory.getLogger(TestDriver.class);
    
    @Test
    public void run() {
        M3<String, String> m3 = new M3<String, String>();
        log.info("M3 [{}].", m3.updateMap());
        log.info("M3 [{}].", m3.cols());
    }

    @Test
    public void runSearch() {
        Search search = new Search(1).eq("name", 2).or("gender", "F").or("gender", "M");
        System.err.println(StringUtils.join(search.assemble(), ""));
        search = new Search().or(
                new Search().or("Bar", "Foo")
                        .eq("foo", "bar")
                        .ne("ne_col", "1")
                        .ne("not_null", null)
                        .notNull("not_null2")
                        .or(new Search().eq("sub_or0", 1).eq("sub_or2", 2))
                        .in("in_col", new Object[] {"1", 2, 3})
                        .like("col_like", "%Shaun%")
                        .or("Or0", "OrValue")
                        .or("Or2", "OrValue2")
            ).eq("name", 2).isNull("gaga");
        System.err.println(StringUtils.join(search.assemble(), ""));
    }

    @Test
    public void runArray() {
        Object array = new String[] {"1", "2"};
        System.err.println(Arrays.asList((Object[]) array));
        new Search().in("foo", new String[]{});
    }
}
