package com.njcn.gather.aireport.testreport.pojo.vo;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.time.LocalDateTime;

class TestReportVOTest {

    @Test
    void getStateShouldUseDefaultDisplayWhenStateIsBlank() {
        TestReportVO report = new TestReportVO();

        Assertions.assertEquals("-", report.getState());
    }

    @Test
    void getStateShouldReturnOriginalValueWhenStateExists() {
        TestReportVO report = new TestReportVO();
        report.setState("02");

        Assertions.assertEquals("02", report.getState());
    }

    @Test
    void timeJsonShouldUseConfiguredDateFormats() throws Exception {
        TestReportVO report = new TestReportVO();
        report.setCheckTime(LocalDate.of(2026, 6, 29));
        report.setCreateTime(LocalDateTime.of(2026, 6, 29, 9, 8, 7));
        report.setUpdateTime(LocalDateTime.of(2026, 6, 29, 18, 16, 14));

        String json = new ObjectMapper().writeValueAsString(report);

        Assertions.assertTrue(json.contains("\"checkTime\":\"2026-06-29\""));
        Assertions.assertTrue(json.contains("\"createTime\":\"2026-06-29 09:08:07\""));
        Assertions.assertTrue(json.contains("\"updateTime\":\"2026-06-29 18:16:14\""));
        Assertions.assertFalse(json.contains("2026-06-29T09"));
        Assertions.assertFalse(json.contains("2026-06-29T18"));
    }
}
