fix(acm2-107): finalize /all/flights contract and FLTR JSON payload
Close Q21 into C-11 and emit day-schedule FLTR-shaped JSON for Redis, schd, and query responses. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/** `GET /all/flights`:投影读、过滤共享航班、失败时 503(`US-12`、`C-11`、`Q21` 暂定)。 */
|
||||
/** `GET /all/flights`:投影读、过滤共享航班、失败时 503(`US-12`、`C-11`)。 */
|
||||
class FlightQueryControllerTest {
|
||||
|
||||
private val mapper = ObjectMapper()
|
||||
@@ -16,8 +16,8 @@ class FlightQueryControllerTest {
|
||||
@Test
|
||||
fun `returns bare JSON array of non-shared flights`() {
|
||||
val projection = StubFlightProjectionPort()
|
||||
projection.snapshots["1"] = """{"flid":"1","scalars":{"MAID":""}}"""
|
||||
projection.snapshots["2"] = """{"flid":"2","scalars":{"MAID":"1"}}"""
|
||||
projection.snapshots["1"] = """{"FLID":"1","FLNO":"CA001"}"""
|
||||
projection.snapshots["2"] = """{"FLID":"2","FLNO":"CA002","MAID":"1"}"""
|
||||
val controller = FlightQueryController(projection, mapper)
|
||||
|
||||
val response = controller.all()
|
||||
@@ -26,7 +26,8 @@ class FlightQueryControllerTest {
|
||||
val root = mapper.readTree(response.body()!!)
|
||||
assertTrue(root.isArray)
|
||||
assertEquals(1, root.size())
|
||||
assertEquals("1", root[0].path("flid").asText())
|
||||
assertEquals("1", root[0].path("FLID").asText())
|
||||
assertEquals("CA001", root[0].path("FLNO").asText())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.gzzn.omms.msgexchange.processing
|
||||
|
||||
import com.gzzn.omms.msgexchange.domain.flight.FlightSnapshot
|
||||
import com.gzzn.omms.msgexchange.domain.flight.FlightState
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/** 投影/`schd` 载荷是日计划 `FLTR` 转 JSON(`C-9`、`C-11`)。 */
|
||||
class FlightPayloadTest {
|
||||
|
||||
@Test
|
||||
fun `emits FLTR-shaped JSON and omits empty fields and internal version`() {
|
||||
val snapshot = FlightSnapshot(
|
||||
flid = "121112312",
|
||||
operationDay = null,
|
||||
state = FlightState.ACTIVE,
|
||||
stateVersion = 7,
|
||||
scalars = mapOf(
|
||||
"FLNO" to "UA724",
|
||||
"MAID" to "",
|
||||
"REMC" to "keep",
|
||||
),
|
||||
collections = mapOf(
|
||||
"GTDT" to listOf(mapOf("GATE" to "G28")),
|
||||
"DELY" to emptyList(),
|
||||
),
|
||||
)
|
||||
|
||||
val payload = flightPayload(snapshot)
|
||||
|
||||
assertEquals("121112312", payload["FLID"])
|
||||
assertEquals("UA724", payload["FLNO"])
|
||||
assertEquals("keep", payload["REMC"])
|
||||
assertEquals(listOf(mapOf("GATE" to "G28")), payload["GTDT"])
|
||||
assertFalse(payload.containsKey("MAID"))
|
||||
assertFalse(payload.containsKey("DELY"))
|
||||
assertFalse(payload.containsKey("stateVersion"))
|
||||
assertFalse(payload.containsKey("scalars"))
|
||||
assertFalse(payload.containsKey("collections"))
|
||||
assertFalse(payload.containsKey("flid"))
|
||||
assertTrue(payload.keys.first() == "FLID")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user