package space.nstart.pcp.complan.types

import org.junit.jupiter.api.Test
import space.nstart.pcp.complan.JacksonConfig
import java.util.UUID
import kotlin.test.assertEquals
import kotlin.test.assertNull

class RequestItemDTOTest {

    private val objectMapper = JacksonConfig().objectMapper()

    @Test
    fun `request item supports nullable priority and intervals from request service`() {
        val requestId = UUID.fromString("39ef7800-d20c-4aae-8041-00208c4551b2")
        val body = """
            {
              "id": "$requestId",
              "name": "Гибралтар",
              "geometry": "POLYGON ((-5.909782 35.691644, -4.797418 35.691644, -4.797418 36.589956, -5.909782 36.589956, -5.909782 35.691644))",
              "intervalBegin": "2000-01-01T00:00:00",
              "intervalEnd": "2100-01-01T00:00:00",
              "resolution": 1.0,
              "priority": null,
              "importance": 0.5,
              "appType": 0,
              "intervals": null
            }
        """.trimIndent()

        val result = objectMapper.readValue(body, RequestItemDTO::class.java)

        assertEquals(requestId, result.id)
        assertEquals("Гибралтар", result.name)
        assertNull(result.priority)
        assertNull(result.intervals)
    }
}
