package com.cesgroup.cesmonitor.test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.cesgroup.cesmonitor.bean.EventInfo;
import com.cesgroup.cesmonitor.common.JSON;
import com.cesgroup.cesmonitor.dao.AlarmListMapper;
import com.cesgroup.cesmonitor.entity.Usage;
import com.cesgroup.cesmonitor.service.AlarmListService;
import com.cesgroup.cesmonitor.service.FormViewService;
import com.cesgroup.cesmonitor.service.OverviewService;
import com.cesgroup.cesmonitor.service.TjService;
import com.zabbix4j.trigger.TriggerGetResponse;
import com.zabbix4j.trigger.TriggerGetResponse.Result;

public class TjTest extends MyTest {

    @Autowired
    TjService tjService;

    @Autowired
    AlarmListService alarmListService;

    @Autowired
    OverviewService overViewService;

    @Autowired
    FormViewService formViewService;

    @Autowired
    AlarmListMapper alarmListMapper;

    @Test
    public void listHost() {
        try {
            List<Usage> list = tjService.listProblums();
            //logger.debug(Util.toJSON2(list));
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    //    @Test
    //    public void getGroup(){
    //        List<AlarmInfo> list = alarmListService.findAlarmMsgByHostId(10108);
    //       System.out.println(JSON.toJson(list));
    //    }

    @Test
    public void test1() {
        List<EventInfo> list = overViewService.findEventMsgByObjectId(15639);
        System.out.println(JSON.toJson(list));
    }

    @Test
    public void test2() {
        List<TriggerGetResponse.Result> list = formViewService.getTriggers(10539);
        for (Result result : list) {
            System.out.println(result.getDescription());
        }

    }
    //    @Test
    //    public void test3(){
    //        List<AlarmInfo> list = alarmListService.findAlarmMsgByFilter(6, 10108 ,null, "-1", "-1", (long)1501545600, (long)1506816000);
    //       System.out.println(JSON.toJson(list));
    //    }

    @Test
    public void test4() throws ParseException {
        //Date start = new Date(2017 - 10 - 06);
        //        if (startTime != null) {
        //            startTime = new Date(startTime.getTime() / 1000);
        //        }
        //        if (endTime != null) {
        //            endTime = new Date(endTime.getTime() / 1000);
        //        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = sdf.parse("2017-10-06");
        //        start = new Date(start.getTime()/1000);
        System.out.println(date.getTime());
    }

    //    @Test
    //    public void test5(){
    //
    //        List<AlarmInfo> list = alarmListService.findAllAlarmInfo();
    //        System.out.println(JSON.toJson(list));
    //    }
    //
    //    @Test
    //    public void test6(){
    //        Page page = alarmListService.getPage(23, -1, -1);
    //        System.out.println(JSON.toJson(page));
    //        System.out.println("shu+"+page.getTotalPage());
    //    }
    //
}
