package com.elab.es.client.spring;

import com.elab.es.App;
import com.elab.es.client.annotation.EnableElastaticSearch;
import com.elab.es.db.PostDao;
import com.elab.es.model.Posts;
import junit.framework.TestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;

/**
 * @Module TODO
 * @Description TODO
 * @Author liukaixiong
 * @Date 2021/1/28 19:43
 */
@EnableElastaticSearch(basePackages = "com.elab.es.db")
@RunWith(SpringRunner.class)
@SpringBootTest(classes = App.class)
public class ElasticSearchScannerRegisterTest extends TestCase {

    @Autowired
    private PostDao postDao;

    @Test
    public void getConfigurableFactory() throws Exception {
        Posts posts = new Posts();
//        posts.setId("1");
        posts.setMessage("从前从前,有个人...");
        posts.setPostDate(new Date());
        posts.setUser("lkx");
        postDao.insert(posts);

        Posts posts1 = postDao.selectById("1");
        System.out.println(posts1);
    }
}