package com.izouma.nineth.service;

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.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;


@SpringBootTest
@RunWith(SpringRunner.class)
public class StatisticServiceTest {

    @Autowired
    private StatisticService statisticService;
    @Autowired
    private CacheService     cacheService;

    @Test
    public void total() {
        System.out.println(statisticService.total());
    }

//    @Test
//    public void userTrend() {
//        System.out.println(statisticService.userTrend(7));
//    }

    @Test
    public void orderNumTrend() {
        System.out.println(statisticService.orderNumTrend(7));
    }

    @Test
    public void orderPriceTrend() {
        System.out.println(statisticService.orderPriceTrend(7));
    }

    @Test
    public void top() {
        LocalDate now = LocalDate.now();
        LocalDate endDate = now.minusDays(now.getDayOfWeek().getValue());
        LocalDateTime start = LocalDateTime.of(endDate.minusDays(6), LocalTime.MIN);
        System.out.println(start);
        String top = statisticService.top(start, LocalDateTime.of(endDate, LocalTime.MAX), 50);
        System.out.println(top);
    }

    @Test
    public void test() {
        cacheService.clearWeekTop();
    }
}