|
|
@@ -23,6 +23,7 @@ import java.util.Arrays;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import static org.hamcrest.Matchers.contains;
|
|
|
import static org.hamcrest.Matchers.hasSize;
|
|
|
import static org.hamcrest.Matchers.nullValue;
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
@@ -73,49 +74,58 @@ class CockpitCurrentEventsControllerTest {
|
|
|
.andExpect(jsonPath("$.data.filters.status").value(nullValue()))
|
|
|
.andExpect(jsonPath("$.data.pagination.page").value(1))
|
|
|
.andExpect(jsonPath("$.data.pagination.pageSize").value(100))
|
|
|
- .andExpect(jsonPath("$.data.pagination.total").value(5))
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(6))
|
|
|
.andExpect(jsonPath("$.data.pagination.totalPages").value(1))
|
|
|
.andExpect(jsonPath("$.data.pagination.hasMore").value(false))
|
|
|
.andExpect(jsonPath("$.data.sections.events.state").value("SUCCESS"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data", hasSize(5)))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-001"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].level").value(1))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].levelColor").value("RED"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].deviceCode").value("D-GAS-1"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].monitoringPointCode").value("MP-A-001"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].monitoringPointName").value("城区A-燃气1号点"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].industry").value("GAS"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].coordinateValidation.state").value("VALID"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].coordinateValidation.reason").value(nullValue()))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].coordinateValidation.renderable").value(true))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].coordinateValidation.crs").value("WGS84"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].thresholdMinValue").value(nullValue()))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].thresholdMaxValue").value(nullValue()))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].workOrderSummary.workOrderCode").value("WO-1"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].workOrderSummary.stateCode").value(3))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].workOrderSummary.stateName").value("处理中"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[1].eventNo").value("W-002"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[1].levelColor").value("YELLOW"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[1].workOrderSummary").value(nullValue()))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[2].eventNo").value("W-003"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[2].levelColor").value("BLUE"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[3].eventNo").value("W-004"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[3].levelColor").value("GREEN"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[3].coordinateValidation.state").value("INVALID"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[3].coordinateValidation.reason").value("LONGITUDE_OUT_OF_RANGE"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[3].coordinateValidation.renderable").value(false))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[3].monitoringPointCode").value(nullValue()))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[4].eventNo").value("W-005"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[4].levelColor").value("UNKNOWN"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data", hasSize(6)))
|
|
|
+ // 42bdb3db:未登记类型 W-006 保留,按时间排到正式行业事件之前。
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[*].eventNo").value(
|
|
|
+ contains("W-006", "W-001", "W-002", "W-003", "W-004", "W-005")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-006"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[0].industry").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[0].deviceCode").value("D-LEGACY"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[0].workOrderSummary").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].eventNo").value("W-001"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].level").value(1))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-001')].levelColor").value(contains("RED")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].deviceCode").value("D-GAS-1"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].monitoringPointCode").value("MP-A-001"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].monitoringPointName").value("城区A-燃气1号点"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].industry").value("GAS"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].coordinateValidation.state").value("VALID"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].coordinateValidation.reason").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].coordinateValidation.renderable").value(true))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].coordinateValidation.crs").value("WGS84"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].thresholdMinValue").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].thresholdMaxValue").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].workOrderSummary.workOrderCode").value("WO-1"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].workOrderSummary.stateCode").value(3))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].workOrderSummary.stateName").value("处理中"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[2].eventNo").value("W-002"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-002')].levelColor").value(contains("YELLOW")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[2].workOrderSummary").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[3].eventNo").value("W-003"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-003')].levelColor").value(contains("BLUE")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[4].eventNo").value("W-004"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-004')].levelColor").value(contains("GREEN")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[4].coordinateValidation.state").value("INVALID"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[4].coordinateValidation.reason").value("LONGITUDE_OUT_OF_RANGE"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[4].coordinateValidation.renderable").value(false))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[4].monitoringPointCode").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[5].eventNo").value("W-005"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-005')].levelColor").value(contains("UNKNOWN")))
|
|
|
// 2026-10-12 契约:W-005 坐标 110.381/28.461 落在主场景区内 → 可上图。
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[4].coordinateValidation.state").value("VALID"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[4].coordinateValidation.reason").value(nullValue()))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[4].coordinateValidation.renderable").value(true))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[4].workOrderSummary.stateName").value("已结案"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[5].coordinateValidation.state").value("VALID"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[5].coordinateValidation.reason").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[5].coordinateValidation.renderable").value(true))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[5].workOrderSummary.stateName").value("已结案"))
|
|
|
.andExpect(jsonPath("$.data.sections.workOrders.state").value("SUCCESS"))
|
|
|
.andExpect(jsonPath("$.data.sections.workOrders.reason").value("SUCCESS"))
|
|
|
.andExpect(jsonPath("$.data.mapFilter.mode").value("WARNING"))
|
|
|
- .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(5)));
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(6)))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.deviceCodes").value(
|
|
|
+ contains("D-DR-1", "D-GAS-1", "D-GAS-2", "D-LEGACY", "D-WS-1", "D-WS-2")));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@@ -146,20 +156,36 @@ class CockpitCurrentEventsControllerTest {
|
|
|
void levelColorsFollowOneRedTwoYellowThreeBlueFourGreen() throws Exception {
|
|
|
mockMvc.perform(get(ENDPOINT).param("mode", "WARNING"))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].levelColor").value("RED"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[1].levelColor").value("YELLOW"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[2].levelColor").value("BLUE"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[3].levelColor").value("GREEN"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[4].levelColor").value("UNKNOWN"));
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-001')].levelColor").value(contains("RED")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-002')].levelColor").value(contains("YELLOW")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-003')].levelColor").value(contains("BLUE")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-004')].levelColor").value(contains("GREEN")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-005')].levelColor").value(contains("UNKNOWN")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-006')].levelColor").value(contains("RED")));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void unknownOrNonFormalEventTypesAreDroppedFromTheList() throws Exception {
|
|
|
+ void unknownEventTypesStayVisibleUntilAnIndustryFilterIsApplied() throws Exception {
|
|
|
mockMvc.perform(get(ENDPOINT).param("mode", "WARNING"))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.pagination.total").value(5))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-001"))
|
|
|
- .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(5)));
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(6))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-006"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[0].industry").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[0].deviceCode").value("D-LEGACY"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-007')]", hasSize(0)))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.deviceCodes", hasSize(6)))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.deviceCodes").value(
|
|
|
+ contains("D-DR-1", "D-GAS-1", "D-GAS-2", "D-LEGACY", "D-WS-1", "D-WS-2")));
|
|
|
+
|
|
|
+ // 未登记类型保留不等于归入燃气;旧井盖夹具仍为 industry=null,保持原样。
|
|
|
+ mockMvc.perform(get(ENDPOINT).param("mode", "WARNING").param("industry", "GAS"))
|
|
|
+ .andExpect(status().isOk())
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(2))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[*].eventNo").value(contains("W-001", "W-002")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[*].industry").value(contains("GAS", "GAS")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-006')]", hasSize(0)))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.industry").value("GAS"))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.deviceCodes").value(contains("D-GAS-1", "D-GAS-2")));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@@ -181,8 +207,10 @@ class CockpitCurrentEventsControllerTest {
|
|
|
mockMvc.perform(get(ENDPOINT).param("mode", "WARNING"))
|
|
|
.andExpect(status().isOk())
|
|
|
.andExpect(jsonPath("$.data.sections.events.state").value("SUCCESS"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data", hasSize(5)))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data", hasSize(6)))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-006"))
|
|
|
.andExpect(jsonPath("$.data.sections.events.data[0].workOrderSummary").value(nullValue()))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-001')].workOrderSummary").value(contains(nullValue())))
|
|
|
.andExpect(jsonPath("$.data.sections.workOrders.state").value("FAILED"))
|
|
|
.andExpect(jsonPath("$.data.sections.workOrders.reason").value("WORK_ORDER_SECTION_UNAVAILABLE"))
|
|
|
.andExpect(jsonPath("$.data.sections.workOrders.message").value("工单状态分区暂不可用"));
|
|
|
@@ -210,20 +238,26 @@ class CockpitCurrentEventsControllerTest {
|
|
|
.param("page", "1")
|
|
|
.param("pageSize", "2"))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.pagination.total").value(5))
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(6))
|
|
|
.andExpect(jsonPath("$.data.pagination.totalPages").value(3))
|
|
|
.andExpect(jsonPath("$.data.pagination.hasMore").value(true))
|
|
|
.andExpect(jsonPath("$.data.sections.events.data", hasSize(2)))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-001"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[1].eventNo").value("W-002"));
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-006"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].eventNo").value("W-001"))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.deviceCodes").value(
|
|
|
+ contains("D-DR-1", "D-GAS-1", "D-GAS-2", "D-LEGACY", "D-WS-1", "D-WS-2")));
|
|
|
|
|
|
mockMvc.perform(get(ENDPOINT)
|
|
|
.param("mode", "WARNING")
|
|
|
.param("page", "3")
|
|
|
.param("pageSize", "2"))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data", hasSize(1)))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-005"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data", hasSize(2)))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-004"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].eventNo").value("W-005"))
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(6))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.deviceCodes").value(
|
|
|
+ contains("D-DR-1", "D-GAS-1", "D-GAS-2", "D-LEGACY", "D-WS-1", "D-WS-2")))
|
|
|
.andExpect(jsonPath("$.data.pagination.hasMore").value(false));
|
|
|
}
|
|
|
|
|
|
@@ -242,15 +276,21 @@ class CockpitCurrentEventsControllerTest {
|
|
|
.param("industry", "WATER_SUPPLY"))
|
|
|
.andExpect(status().isOk())
|
|
|
.andExpect(jsonPath("$.data.pagination.total").value(2))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[*].eventNo").value(contains("W-003", "W-005")))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[?(@.eventNo == 'W-006')]", hasSize(0)))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.deviceCodes").value(contains("D-WS-1", "D-WS-2")))
|
|
|
.andExpect(jsonPath("$.data.mapFilter.industry").value("WATER_SUPPLY"));
|
|
|
|
|
|
mockMvc.perform(get(ENDPOINT)
|
|
|
.param("mode", "WARNING")
|
|
|
.param("status", "ACTIVE"))
|
|
|
.andExpect(status().isOk())
|
|
|
- .andExpect(jsonPath("$.data.pagination.total").value(3))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-001"))
|
|
|
- .andExpect(jsonPath("$.data.sections.events.data[2].eventNo").value("W-005"))
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(4))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[0].eventNo").value("W-006"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[1].eventNo").value("W-001"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[3].eventNo").value("W-005"))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[*].eventNo").value(contains("W-006", "W-001", "W-002", "W-005")))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.deviceCodes").value(contains("D-GAS-1", "D-GAS-2", "D-LEGACY", "D-WS-2")))
|
|
|
.andExpect(jsonPath("$.data.mapFilter.status").value("ACTIVE"));
|
|
|
}
|
|
|
|
|
|
@@ -324,14 +364,16 @@ class CockpitCurrentEventsControllerTest {
|
|
|
.andExpect(status().isOk())
|
|
|
.andExpect(jsonPath("$.data.filters.district").value(nullValue()))
|
|
|
.andExpect(jsonPath("$.data.filters.districtName").value("未分区"))
|
|
|
- .andExpect(jsonPath("$.data.pagination.total").value(2));
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(3))
|
|
|
+ .andExpect(jsonPath("$.data.sections.events.data[*].eventNo").value(contains("W-006", "W-004", "W-005")))
|
|
|
+ .andExpect(jsonPath("$.data.mapFilter.deviceCodes").value(contains("D-DR-1", "D-LEGACY", "D-WS-2")));
|
|
|
|
|
|
// 不传=全域
|
|
|
mockMvc.perform(get(ENDPOINT).param("mode", "WARNING"))
|
|
|
.andExpect(status().isOk())
|
|
|
.andExpect(jsonPath("$.data.filters.district").value(nullValue()))
|
|
|
.andExpect(jsonPath("$.data.filters.districtName").value(nullValue()))
|
|
|
- .andExpect(jsonPath("$.data.pagination.total").value(5));
|
|
|
+ .andExpect(jsonPath("$.data.pagination.total").value(6));
|
|
|
|
|
|
// 报警模式同一套语义(片区是事件族共同维度,不是预警专属)
|
|
|
mockMvc.perform(get(ENDPOINT).param("mode", "ALARM").param("district", "2"))
|